Skip to content

Commit

Permalink
Apply ruff/refurb rule FURB188
Browse files Browse the repository at this point in the history
FURB188 Prefer `removesuffix` over conditionally replacing with slice.
  • Loading branch information
DimitriPapadopoulos committed Jan 1, 2025
1 parent 43a20f2 commit 181b596
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions setuptools/command/bdist_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def _get_purelib():
def strip_module(filename):
if '.' in filename:
filename = os.path.splitext(filename)[0]
if filename.endswith('module'):
filename = filename[:-6]
filename = filename.removesuffix('module')
return filename


Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/editable_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def _parent_path(pkg, pkg_path):
>>> _parent_path("b", "src/c")
'src/c'
"""
parent = pkg_path[: -len(pkg)] if pkg_path.endswith(pkg) else pkg_path
parent = pkg_path.removesuffix(pkg)
return parent.rstrip("/" + os.sep)


Expand Down
3 changes: 1 addition & 2 deletions setuptools/command/egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ def global_exclude(self, pattern):
return self._remove_files(match.match)

def append(self, item) -> None:
if item.endswith('\r'): # Fix older sdists built on Windows
item = item[:-1]
item = item.removesuffix('\r')
path = convert_path(item)

if self._safe_path(path):
Expand Down
3 changes: 1 addition & 2 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,7 @@ def iter_distribution_names(self):
name, _buildinfo = ext
else:
name = ext.name
if name.endswith('module'):
name = name[:-6]
name = name.removesuffix('module')
yield name

def handle_display_options(self, option_order):
Expand Down

0 comments on commit 181b596

Please sign in to comment.