From f9fdfcb7ad927aeae94dd257db64d2344d00959e Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Thu, 23 May 2024 10:35:11 +0300 Subject: [PATCH] Enforce ruff/refurb rule FURB118 FURB118 Use `operator.itemgetter(0)` instead of defining a lambda --- setuptools/command/build_ext.py | 3 ++- setuptools/command/build_py.py | 3 ++- setuptools/command/editable_wheel.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py index 6056fe9b24b..d0b13876d09 100644 --- a/setuptools/command/build_ext.py +++ b/setuptools/command/build_ext.py @@ -1,3 +1,4 @@ +import operator import os import sys import itertools @@ -314,7 +315,7 @@ def get_outputs(self) -> List[str]: def get_output_mapping(self) -> Dict[str, str]: """See :class:`setuptools.commands.build.SubCommand`""" mapping = self._get_output_mapping() - return dict(sorted(mapping, key=lambda x: x[0])) + return dict(sorted(mapping, key=operator.itemgetter(0))) def __get_stubs_outputs(self): # assemble the base name for each extension that needs a stub diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 3f40b060b3a..41a6530fa2e 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -2,6 +2,7 @@ from glob import glob from distutils.util import convert_path import distutils.command.build_py as orig +import operator import os import fnmatch import textwrap @@ -142,7 +143,7 @@ def get_output_mapping(self) -> Dict[str, str]: self._get_package_data_output_mapping(), self._get_module_mapping(), ) - return dict(sorted(mapping, key=lambda x: x[0])) + return dict(sorted(mapping, key=operator.itemgetter(0))) def _get_module_mapping(self) -> Iterator[Tuple[str, str]]: """Iterate over all modules producing (dest, src) pairs.""" diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index a835a8194b3..c80dda8a4c9 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -12,6 +12,7 @@ import logging import io +import operator import os import shutil import traceback @@ -888,7 +889,7 @@ def _finder_template( """Create a string containing the code for the``MetaPathFinder`` and ``PathEntryFinder``. """ - mapping = dict(sorted(mapping.items(), key=lambda p: p[0])) + mapping = dict(sorted(mapping.items(), key=operator.itemgetter(0))) return _FINDER_TEMPLATE.format(name=name, mapping=mapping, namespaces=namespaces)