Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8f8bcc

Browse files
authored
Merge pull request#4386 from DimitriPapadopoulos/FURB
Enforce ruff/refurb rules (FURB)
2 parentsd126744 +be06d67 commitb8f8bcc

File tree

15 files changed

+36
-27
lines changed

15 files changed

+36
-27
lines changed

‎pkg_resources/__init__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ class _ZipLoaderModule(Protocol):
131131
__loader__:zipimport.zipimporter
132132

133133

134-
_PEP440_FALLBACK=re.compile(r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)",re.I)
134+
_PEP440_FALLBACK=re.compile(
135+
r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)",re.IGNORECASE
136+
)
135137

136138

137139
classPEP440Warning(RuntimeWarning):

‎ruff.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extend-select = [
2727
# local
2828
"ANN2",# missing-return-type-*
2929
"ISC",# flake8-implicit-str-concat
30+
"FURB",# refurb
3031
"PERF",# Perflint
3132
"PGH",# pygrep-hooks (blanket-* rules)
3233
"PT",# flake8-pytest-style

‎setuptools/_normalization.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
importpackaging
1010

1111
# https://packaging.python.org/en/latest/specifications/core-metadata/#name
12-
_VALID_NAME=re.compile(r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$",re.I)
13-
_UNSAFE_NAME_CHARS=re.compile(r"[^A-Z0-9._-]+",re.I)
14-
_NON_ALPHANUMERIC=re.compile(r"[^A-Z0-9]+",re.I)
15-
_PEP440_FALLBACK=re.compile(r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)",re.I)
12+
_VALID_NAME=re.compile(r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$",re.IGNORECASE)
13+
_UNSAFE_NAME_CHARS=re.compile(r"[^A-Z0-9._-]+",re.IGNORECASE)
14+
_NON_ALPHANUMERIC=re.compile(r"[^A-Z0-9]+",re.IGNORECASE)
15+
_PEP440_FALLBACK=re.compile(
16+
r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)",re.IGNORECASE
17+
)
1618

1719

1820
defsafe_identifier(name:str)->str:

‎setuptools/command/bdist_egg.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def _get_purelib():
3737
defstrip_module(filename):
3838
if'.'infilename:
3939
filename=os.path.splitext(filename)[0]
40-
iffilename.endswith('module'):
41-
filename=filename[:-6]
40+
filename=filename.removesuffix('module')
4241
returnfilename
4342

4443

‎setuptools/command/build_ext.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__importannotations
22

33
importitertools
4+
importoperator
45
importos
56
importsys
67
importtextwrap
@@ -323,7 +324,7 @@ def get_outputs(self) -> list[str]:
323324
defget_output_mapping(self)->dict[str,str]:
324325
"""See :class:`setuptools.commands.build.SubCommand`"""
325326
mapping=self._get_output_mapping()
326-
returndict(sorted(mapping,key=lambdax:x[0]))
327+
returndict(sorted(mapping,key=operator.itemgetter(0)))
327328

328329
def__get_stubs_outputs(self):
329330
# assemble the base name for each extension that needs a stub

‎setuptools/command/build_py.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
importfnmatch
44
importitertools
5+
importoperator
56
importos
67
importstat
78
importtextwrap
@@ -149,7 +150,7 @@ def get_output_mapping(self) -> dict[str, str]:
149150
self._get_package_data_output_mapping(),
150151
self._get_module_mapping(),
151152
)
152-
returndict(sorted(mapping,key=lambdax:x[0]))
153+
returndict(sorted(mapping,key=operator.itemgetter(0)))
153154

154155
def_get_module_mapping(self)->Iterator[tuple[str,str]]:
155156
"""Iterate over all modules producing (dest, src) pairs."""

‎setuptools/command/editable_wheel.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
importio
1616
importlogging
17+
importoperator
1718
importos
1819
importshutil
1920
importtraceback
@@ -665,7 +666,7 @@ def _parent_path(pkg, pkg_path):
665666
>>> _parent_path("b", "src/c")
666667
'src/c'
667668
"""
668-
parent=pkg_path[:-len(pkg)]ifpkg_path.endswith(pkg)elsepkg_path
669+
parent=pkg_path.removesuffix(pkg)
669670
returnparent.rstrip("/"+os.sep)
670671

671672

@@ -906,7 +907,7 @@ def _finder_template(
906907
"""Create a string containing the code for the``MetaPathFinder`` and
907908
``PathEntryFinder``.
908909
"""
909-
mapping=dict(sorted(mapping.items(),key=lambdap:p[0]))
910+
mapping=dict(sorted(mapping.items(),key=operator.itemgetter(0)))
910911
return_FINDER_TEMPLATE.format(name=name,mapping=mapping,namespaces=namespaces)
911912

912913

‎setuptools/command/egg_info.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,7 @@ def global_exclude(self, pattern):
477477
returnself._remove_files(match.match)
478478

479479
defappend(self,item)->None:
480-
ifitem.endswith('\r'):# Fix older sdists built on Windows
481-
item=item[:-1]
480+
item=item.removesuffix('\r')# Fix older sdists built on Windows
482481
path=convert_path(item)
483482

484483
ifself._safe_path(path):

‎setuptools/dist.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,8 +1068,7 @@ def iter_distribution_names(self) -> Iterator[str]:
10681068
name,_buildinfo=ext
10691069
else:
10701070
name=ext.name
1071-
ifname.endswith('module'):
1072-
name=name[:-6]
1071+
name=name.removesuffix('module')
10731072
yieldname
10741073

10751074
defhandle_display_options(self,option_order):

‎setuptools/msvc.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def _find_latest_available_vs_ver(self):
402402

403403
vc_vers=set(reg_vc_vers)
404404
vc_vers.update(self.known_vs_paths)
405-
returnsorted(vc_vers)[-1]
405+
returnmax(vc_vers)
406406

407407
deffind_reg_vs_vers(self)->list[float]:
408408
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp