Skip to content

Commit 552aab6

Browse files
author
Release Manager
committed
gh-40415: Remove precisely the prefix instead of strip <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Hello, I am a first time contributor, still navigating the `sage` huge codebase. Please let me know if I am not aware of something. This PR resolves a few occurrences of the error [B005](https://docs.astral.sh/ruff/rules/strip-with-multi-characters/) from `ruff`. It looks pretty clear to me that that intent of the code is to remove precisely these prefixes rather than, for example, removing all the leading occurrences of the letters d, e, f, a, u, l, t. I think the example in the docs of `ruff` illustrates quite well the difference. Tested with `ruff check src/sage --select B005` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40415 Reported by: Trinh Quoc Anh Reviewer(s): Frédéric Chapoton
2 parents 4174d17 + db9d077 commit 552aab6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/sage/interfaces/singular.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@ def sage_global_ring(self):
16541654
is_extension = False
16551655
else:
16561656
# it ought to be a finite field
1657-
q = ZZ(charstr[0].lstrip('ZZ/'))
1657+
q = ZZ(charstr[0].removeprefix('ZZ/'))
16581658
from sage.rings.finite_rings.finite_field_constructor import GF
16591659
if q.is_prime():
16601660
br = GF(q)

src/sage/plot/misc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,20 +420,20 @@ def get_matplotlib_linestyle(linestyle, return_type):
420420
return None
421421

422422
if linestyle.startswith("default"):
423-
return get_matplotlib_linestyle(linestyle.strip("default"), "short")
423+
return get_matplotlib_linestyle(linestyle.removeprefix("default"), "short")
424424
elif linestyle.startswith("steps"):
425425
if linestyle.startswith("steps-mid"):
426426
return "steps-mid" + get_matplotlib_linestyle(
427-
linestyle.strip("steps-mid"), "short")
427+
linestyle.removeprefix("steps-mid"), "short")
428428
elif linestyle.startswith("steps-post"):
429429
return "steps-post" + get_matplotlib_linestyle(
430-
linestyle.strip("steps-post"), "short")
430+
linestyle.removeprefix("steps-post"), "short")
431431
elif linestyle.startswith("steps-pre"):
432432
return "steps-pre" + get_matplotlib_linestyle(
433-
linestyle.strip("steps-pre"), "short")
433+
linestyle.removeprefix("steps-pre"), "short")
434434
else:
435435
return "steps" + get_matplotlib_linestyle(
436-
linestyle.strip("steps"), "short")
436+
linestyle.removeprefix("steps"), "short")
437437

438438
if return_type == 'short':
439439
if linestyle in short_to_long_dict.keys():

0 commit comments

Comments
 (0)