Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions misc/upload-pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ def item_ok_for_pypi(name: str) -> bool:
if not is_whl_or_tar(name):
return False

if name.endswith(".tar.gz"):
name = name[:-7]
if name.endswith(".whl"):
name = name[:-4]
name = name.removesuffix(".tar.gz")
name = name.removesuffix(".whl")

if name.endswith("wasm32"):
return False
Expand Down Expand Up @@ -123,8 +121,7 @@ def upload_to_pypi(version: str, dry_run: bool = True) -> None:
assert re.match(r"v?[1-9]\.[0-9]+\.[0-9](\+\S+)?$", version)
if "dev" in version:
assert dry_run, "Must use --dry-run with dev versions of mypy"
if version.startswith("v"):
version = version[1:]
version = version.removeprefix("v")

target_dir = tempfile.mkdtemp()
dist = Path(target_dir) / "dist"
Expand Down
3 changes: 1 addition & 2 deletions mypy/find_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def _crawl_up_helper(self, dir: str) -> tuple[str, str] | None:
return "", dir

parent, name = os.path.split(dir)
if name.endswith("-stubs"):
name = name[:-6] # PEP-561 stub-only directory
name = name.removesuffix("-stubs") # PEP-561 stub-only directory

# recurse if there's an __init__.py
init_file = self.get_init_file(dir)
Expand Down
2 changes: 1 addition & 1 deletion mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def _verify_arg_name(
return

def strip_prefix(s: str, prefix: str) -> str:
return s[len(prefix) :] if s.startswith(prefix) else s
return s.removeprefix(prefix)

if strip_prefix(stub_arg.variable.name, "__") == runtime_arg.name:
return
Expand Down
3 changes: 1 addition & 2 deletions mypy/test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ def check_test_output_files(
testcase: DataDrivenTestCase, step: int, strip_prefix: str = ""
) -> None:
for path, expected_content in testcase.output_files:
if path.startswith(strip_prefix):
path = path[len(strip_prefix) :]
path = path.removeprefix(strip_prefix)
if not os.path.exists(path):
raise AssertionError(
"Expected file {} was not produced by test case{}".format(
Expand Down
6 changes: 2 additions & 4 deletions mypyc/irbuild/ll_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,8 +1345,7 @@ def binary_op(self, lreg: Value, rreg: Value, op: str, line: int) -> Value:
return self.translate_instance_contains(rreg, lreg, op, line)
if is_fixed_width_rtype(ltype):
if op in FIXED_WIDTH_INT_BINARY_OPS:
if op.endswith("="):
op = op[:-1]
op = op.removesuffix("=")
if op != "//":
op_id = int_op_to_id[op]
else:
Expand All @@ -1372,8 +1371,7 @@ def binary_op(self, lreg: Value, rreg: Value, op: str, line: int) -> Value:
return self.comparison_op(lreg, self.coerce(rreg, ltype, line), op_id, line)
elif is_fixed_width_rtype(rtype):
if op in FIXED_WIDTH_INT_BINARY_OPS:
if op.endswith("="):
op = op[:-1]
op = op.removesuffix("=")
if op != "//":
op_id = int_op_to_id[op]
else:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ select = [
"UP", # pyupgrade
"C4", # flake8-comprehensions
"SIM201", "SIM202", "SIM222", "SIM223", # flake8-simplify
"FURB188", # use str.remove(pre|suf)fix
"ISC001", # implicitly concatenated string
"RET501", "RET502", # better return None handling
]
Expand Down