From 04109012ae8e3c262a252cf91d01db88c18f57d1 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Thu, 7 Nov 2024 11:47:33 -0800 Subject: [PATCH] Make min python 3.9+ --- .drone.star | 3 +-- pseudo_builder.py | 5 ++--- pyproject.toml | 4 ++-- release_gitter.py | 20 +------------------- release_gitter_test.py | 9 --------- 5 files changed, 6 insertions(+), 35 deletions(-) diff --git a/.drone.star b/.drone.star index 4c5cf0b..36863ad 100644 --- a/.drone.star +++ b/.drone.star @@ -1,12 +1,11 @@ # Build pipelines PYTHON_VERSIONS = [ - "3.7", - "3.8", "3.9", "3.10", "3.11", "3.12", + "3.13", "latest", ] diff --git a/pseudo_builder.py b/pseudo_builder.py index 6d9e0e4..245c464 100644 --- a/pseudo_builder.py +++ b/pseudo_builder.py @@ -14,7 +14,6 @@ import toml from wheel.wheelfile import WheelFile import release_gitter as rg -from release_gitter import removeprefix @dataclass @@ -96,7 +95,7 @@ class _PseudoBuildBackend: print("Prepare meta", metadata_directory, config_settings) metadata = read_metadata() - version = removeprefix(metadata.version, "v") if metadata.version else "0.0.0" + version = metadata.version.removeprefix("v") if metadata.version else "0.0.0" # Returns distinfo dir? dist_info = Path(metadata_directory) / f"{metadata.name}-{version}.dist-info" @@ -145,7 +144,7 @@ class _PseudoBuildBackend: metadata_directory = Path(metadata_directory) metadata = read_metadata() - version = removeprefix(metadata.version, "v") if metadata.version else "0.0.0" + version = metadata.version.removeprefix("v") if metadata.version else "0.0.0" wheel_directory = Path(wheel_directory) wheel_directory.mkdir(exist_ok=True) diff --git a/pyproject.toml b/pyproject.toml index c115e3b..a941b53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ authors = [ maintainers = [ { name = "Ian Fijolek", email = "iamthefij@gmail.com" } ] -requires-python = ">=3.7" +requires-python = ">=3.9" dependencies = ["requests"] [project.optional-dependencies] @@ -53,7 +53,7 @@ run = [ ] [[tool.hatch.envs.test.matrix]] -python = ["3", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] +python = ["3", "3.9", "3.10", "3.11", "3.12", "3.13"] [tool.hatch.envs.lint] detached = true diff --git a/release_gitter.py b/release_gitter.py index 6f4a28e..f6047a4 100755 --- a/release_gitter.py +++ b/release_gitter.py @@ -31,24 +31,6 @@ class InvalidRemoteError(ValueError): pass -def removeprefix(s: str, pre: str) -> str: - # Duplicate str.removeprefix for py<3.9 - try: - return s.removeprefix(pre) # type: ignore - except AttributeError: - # Py < 3.9 - return s[len(pre) :] if s and s.startswith(pre) else s - - -def removesuffix(s: str, suf: str) -> str: - # Duplicate str.removesuffix for py<3.9 - try: - return s.removesuffix(suf) # type: ignore - except AttributeError: - # Py < 3.9 - return s[: -len(suf)] if s and s.endswith(suf) else s - - SYSTEM_SYNONYMS: list[list[str]] = [ ["Darwin", "darwin", "MacOS", "macos", "macOS"], ["Windows", "windows", "win", "win32", "win64"], @@ -147,7 +129,7 @@ def parse_git_remote(git_url: str | None = None) -> GitRemoteInfo: f"{path[1:3]} Could not parse owner and repo from URL {git_url}" ) - return GitRemoteInfo(u.hostname, path[1], removesuffix(path[2], ".git")) + return GitRemoteInfo(u.hostname, path[1], path[2].removesuffix(".git")) def parse_cargo_version(p: Path) -> str: diff --git a/release_gitter_test.py b/release_gitter_test.py index 431266c..1857c16 100644 --- a/release_gitter_test.py +++ b/release_gitter_test.py @@ -41,15 +41,6 @@ class TestExpression(NamedTuple): raise -class TestGeneral(unittest.TestCase): - def test_removesuffix(self): - for test_case in ( - TestExpression(self, ["repo.git", ".git"], {}, "repo"), - TestExpression(self, ["repo", ".git"], {}, "repo"), - ): - test_case.run(release_gitter.removesuffix) - - class TestRemoteInfo(unittest.TestCase): def test_parse_remote_info(self): for test_case in (