Skip to content

Commit 1fe0c5d

Browse files
authored
Add ruff rules PIE (#5033)
2 parents 27df3f6 + a3ac226 commit 1fe0c5d

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

newsfragments/5033.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid repeated calls to ``str.startswith`` and ``str.endswith``.

ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extend-select = [
2929
"ISC", # flake8-implicit-str-concat
3030
"FURB", # refurb
3131
"PERF", # Perflint
32+
"PIE", # flake8-pie
3233
"PGH", # pygrep-hooks (blanket-* rules)
3334
"PT", # flake8-pytest-style
3435
"RUF10", # unused-noqa & redirected-noqa

setuptools/command/bdist_egg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ def analyze_egg(egg_dir, stubs):
348348
safe = True
349349
for base, dirs, files in walk_egg(egg_dir):
350350
for name in files:
351-
if name.endswith('.py') or name.endswith('.pyw'):
351+
if name.endswith(('.py', '.pyw')):
352352
continue
353-
elif name.endswith('.pyc') or name.endswith('.pyo'):
353+
elif name.endswith(('.pyc', '.pyo')):
354354
# always scan, even if we already know we're not safe
355355
safe = scan_module(egg_dir, base, name, stubs) and safe
356356
return safe

setuptools/command/egg_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _maybe_tag(self, version):
146146
def _already_tagged(self, version: str) -> bool:
147147
# Depending on their format, tags may change with version normalization.
148148
# So in addition the regular tags, we have to search for the normalized ones.
149-
return version.endswith(self.vtags) or version.endswith(self._safe_tags())
149+
return version.endswith((self.vtags, self._safe_tags()))
150150

151151
def _safe_tags(self) -> str:
152152
# To implement this we can rely on `safe_version` pretending to be version 0

0 commit comments

Comments
 (0)