Skip to content

Commit ac0302c

Browse files
Enforce ruff/refurb rule FURB118
FURB118 Use `operator.itemgetter(0)` instead of defining a lambda
1 parent e9bc9c4 commit ac0302c

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

setuptools/command/build_ext.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import itertools
4+
import operator
45
import os
56
import sys
67
from importlib.machinery import EXTENSION_SUFFIXES
@@ -319,7 +320,7 @@ def get_outputs(self) -> list[str]:
319320
def get_output_mapping(self) -> dict[str, str]:
320321
"""See :class:`setuptools.commands.build.SubCommand`"""
321322
mapping = self._get_output_mapping()
322-
return dict(sorted(mapping, key=lambda x: x[0]))
323+
return dict(sorted(mapping, key=operator.itemgetter(0)))
323324

324325
def __get_stubs_outputs(self):
325326
# assemble the base name for each extension that needs a stub

setuptools/command/build_py.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import fnmatch
44
import itertools
5+
import operator
56
import os
67
import stat
78
import textwrap
@@ -153,7 +154,7 @@ def get_output_mapping(self) -> dict[str, str]:
153154
self._get_package_data_output_mapping(),
154155
self._get_module_mapping(),
155156
)
156-
return dict(sorted(mapping, key=lambda x: x[0]))
157+
return dict(sorted(mapping, key=operator.itemgetter(0)))
157158

158159
def _get_module_mapping(self) -> Iterator[tuple[str, str]]:
159160
"""Iterate over all modules producing (dest, src) pairs."""

setuptools/command/editable_wheel.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io
1616
import logging
1717
import os
18+
import operator
1819
import shutil
1920
import traceback
2021
from contextlib import suppress
@@ -865,7 +866,7 @@ def _finder_template(
865866
"""Create a string containing the code for the``MetaPathFinder`` and
866867
``PathEntryFinder``.
867868
"""
868-
mapping = dict(sorted(mapping.items(), key=lambda p: p[0]))
869+
mapping = dict(sorted(mapping.items(), key=operator.itemgetter(0)))
869870
return _FINDER_TEMPLATE.format(name=name, mapping=mapping, namespaces=namespaces)
870871

871872

0 commit comments

Comments
 (0)