FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-104683: Modernise `clinic.py` using `str.removeprefix` and `str.removesuffix` by AlexWaygood · Pull Request #104685 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 5 additions & 5 deletions Tools/clinic/clinic.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ def is_stop_line(line):
# make sure to recognize stop line even if it
# doesn't end with EOL (it could be the very end of the file)
if line.startswith(stop_line):
remainder = line[len(stop_line):]
remainder = line.removeprefix(stop_line)
if remainder and not remainder.isspace():
fail(f"Garbage after stop line: {remainder!r}")
return True
Expand All @@ -1765,7 +1765,7 @@ def is_stop_line(line):
if body_prefix:
line = line.lstrip()
assert line.startswith(body_prefix)
line = line[len(body_prefix):]
line = line.removeprefix(body_prefix)
input_add(line)

# consume output and checksum line, if present.
Expand Down Expand Up @@ -2570,7 +2570,7 @@ def add_c_converter(f, name=None):
name = f.__name__
if not name.endswith('_converter'):
return f
name = name[:-len('_converter')]
name = name.removesuffix('_converter')
converters[name] = f
return f

Expand Down Expand Up @@ -3977,7 +3977,7 @@ def add_c_return_converter(f, name=None):
name = f.__name__
if not name.endswith('_return_converter'):
return f
name = name[:-len('_return_converter')]
name = name.removesuffix('_return_converter')
return_converters[name] = f
return f

Expand Down Expand Up @@ -5369,7 +5369,7 @@ def main(argv):
if name in ignored:
continue
if name.endswith(suffix):
ids.append((name, name[:-len(suffix)]))
ids.append((name, name.removesuffix(suffix)))
break
print()

Expand Down

Back | FazBrowse Home | New Git URL