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 Aug 19, 2024
1 parent c63346f commit e15d1e9
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,6 +1,7 @@
from __future__ import annotations

import itertools
import operator
import os
import sys
from importlib.machinery import EXTENSION_SUFFIXES
Expand Down Expand Up @@ -319,7 +320,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 @@

import fnmatch
import itertools
import operator
import os
import stat
import textwrap
Expand Down Expand Up @@ -153,7 +154,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 @@ -14,6 +14,7 @@

import io
import logging
import operator
import os
import shutil
import traceback
Expand Down Expand Up @@ -865,7 +866,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 e15d1e9

Please sign in to comment.