Skip to content

Commit

Permalink
Enforce ruff/refurb rule FURB118
Browse files Browse the repository at this point in the history
FURB118 Use `operator.itemgetter(0)` instead of defining a lambda
  • Loading branch information
DimitriPapadopoulos committed May 23, 2024
1 parent 178c529 commit f9fdfcb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion setuptools/command/build_ext.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import operator
import os
import sys
import itertools
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion setuptools/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down
3 changes: 2 additions & 1 deletion setuptools/command/editable_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import logging
import io
import operator
import os
import shutil
import traceback
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit f9fdfcb

Please sign in to comment.