Skip to content

Commit a360364

Browse files
Apply ruff/flake8-bugbear rule B005
B005 Using `.strip()` with multi-character strings is misleading
1 parent d7ce405 commit a360364

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

numpy/f2py/crackfortran.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2539,7 +2539,7 @@ def get_parameters(vars, global_params={}):
25392539
outmess(f'get_parameters[TODO]: '
25402540
f'implement evaluation of complex expression {v}\n')
25412541

2542-
dimspec = ([s.lstrip('dimension').strip()
2542+
dimspec = ([s.removeprefix('dimension').strip()
25432543
for s in vars[n]['attrspec']
25442544
if s.startswith('dimension')] or [None])[0]
25452545

numpy/lib/_datasource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def _sanitize_relative_path(self, path):
420420
last = path
421421
# Note: os.path.join treats '/' as os.sep on Windows
422422
path = path.lstrip(os.sep).lstrip('/')
423-
path = path.lstrip(os.pardir).lstrip('..')
423+
path = path.lstrip(os.pardir).removeprefix('..')
424424
drive, path = os.path.splitdrive(path) # for Windows
425425
return path
426426

numpy/lib/tests/test_loadtxt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ def test_str_dtype_unit_discovery_with_converter():
10041004
expected = np.array(
10051005
["spam-a-lot"] * 60000 + ["tis_but_a_scratch"], dtype="U17"
10061006
)
1007-
conv = lambda s: s.strip("XXX")
1007+
conv = lambda s: s.removeprefix("XXX")
10081008

10091009
# file-like path
10101010
txt = StringIO("\n".join(data))

0 commit comments

Comments
 (0)