Skip to content

Commit 2c8d48e

Browse files
authored
Fix lint and remove support for Python 3.9 (#151)
1 parent 53a1ab5 commit 2c8d48e

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ jobs:
1818
strategy:
1919
matrix:
2020
python:
21-
- "3.9"
2221
- "3.10"
2322
- "3.11"
2423
- "3.12"
2524
- "3.13"
25+
- "3.14"
2626
runs-on: ubuntu-latest
2727
steps:
2828
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -52,7 +52,7 @@ jobs:
5252

5353
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
5454
with:
55-
python-version: 3.13
55+
python-version: 3.14
5656
cache: "pip"
5757
cache-dependency-path: pyproject.toml
5858
allow-prereleases: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
env/
2+
.venv/
23
pip-wheel-metadata/
34
*.egg-info/
45
__pycache__/

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ALL_PY_SRCS := $(shell find src -name '*.py') \
66
$(shell find test -name '*.py')
77

88
# Optionally overriden by the user, if they're using a virtual environment manager.
9-
VENV ?= env
9+
VENV ?= .venv
1010

1111
# On Windows, venv scripts/shims are under `Scripts` instead of `bin`.
1212
VENV_BIN := $(VENV)/bin
@@ -45,7 +45,7 @@ dev: $(VENV)/pyvenv.cfg
4545

4646
$(VENV)/pyvenv.cfg: pyproject.toml
4747
# Create our Python 3 virtual environment
48-
python3 -m venv env
48+
python3 -m venv $(VENV)
4949
$(VENV_BIN)/python -m pip install --upgrade pip
5050
$(VENV_BIN)/python -m pip install -e .[$(INSTALL_EXTRA)]
5151

pyproject.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies = [
2222
"sigstore >= 4.0, < 5.0",
2323
"sigstore-models",
2424
]
25-
requires-python = ">=3.9"
25+
requires-python = ">=3.10"
2626

2727
[tool.setuptools.dynamic]
2828
version = { attr = "pypi_attestations.__version__" }
@@ -64,7 +64,7 @@ omit = ["src/pypi_attestations/__main__.py"]
6464
mypy_path = "src"
6565
packages = "pypi_attestations"
6666
plugins = ["pydantic.mypy"]
67-
python_version = "3.9"
67+
python_version = "3.10"
6868
allow_redefinition = true
6969
check_untyped_defs = true
7070
disallow_incomplete_defs = true
@@ -83,17 +83,14 @@ warn_unused_ignores = true
8383

8484
[tool.ruff]
8585
line-length = 100
86-
target-version = "py39"
86+
target-version = "py310"
8787

8888
[tool.ruff.lint]
8989
select = ["E", "F", "I", "W", "UP", "ANN", "D", "COM", "ISC", "TCH", "SLF"]
9090
# D203 and D213 are incompatible with D211 and D212 respectively.
9191
# COM812 and ISC001 can cause conflicts when using ruff as a formatter.
9292
# See https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules.
9393
ignore = ["D203", "D213", "COM812", "ISC001"]
94-
# Needed since Pydantic relies on runtime type annotations, and we target Python versions
95-
# < 3.10. See https://docs.astral.sh/ruff/rules/non-pep604-annotation/#why-is-this-bad
96-
pyupgrade.keep-runtime-typing = true
9794

9895
[tool.ruff.lint.per-file-ignores]
9996

@@ -107,6 +104,6 @@ pyupgrade.keep-runtime-typing = true
107104
[tool.interrogate]
108105
# don't enforce documentation coverage for packaging, testing, the virtual
109106
# environment, or the CLI (which is documented separately).
110-
exclude = ["env", "test", "src/pypi_attestations/__main__.py"]
107+
exclude = [".venv", "test", "src/pypi_attestations/__main__.py"]
111108
ignore-semiprivate = true
112109
fail-under = 100

src/pypi_attestations/_impl.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import base64
99
import json
1010
from enum import Enum
11-
from typing import TYPE_CHECKING, Annotated, Any, Literal, NewType, Optional, Union, get_args
11+
from typing import TYPE_CHECKING, Annotated, Any, Literal, NewType
1212

1313
import packaging
1414
import packaging.tags
@@ -238,7 +238,7 @@ def verify(
238238
*,
239239
staging: bool = False,
240240
offline: bool = False,
241-
) -> tuple[str, Optional[dict[str, Any]]]:
241+
) -> tuple[str, dict[str, Any] | None]:
242242
"""Verify against an existing Python distribution.
243243
244244
The `identity` can be an object confirming to
@@ -257,8 +257,7 @@ def verify(
257257
# NOTE: Can't do `isinstance` with `Publisher` since it's
258258
# a `_GenericAlias`; instead we punch through to the inner
259259
# `_Publisher` union.
260-
# Use of typing.get_args is needed for Python < 3.10
261-
if isinstance(identity, get_args(_Publisher)):
260+
if isinstance(identity, _Publisher):
262261
policy = identity._as_policy() # noqa: SLF001
263262
else:
264263
policy = identity
@@ -412,7 +411,7 @@ def _der_decode_utf8string(der: bytes) -> str:
412411
packaging.utils.BuildTag,
413412
frozenset[packaging.tags.Tag],
414413
]
415-
_DistName = Union[_SdistName, _BdistName]
414+
_DistName = _SdistName | _BdistName
416415

417416

418417
def _check_dist_filename(dist: str) -> _DistName:
@@ -544,7 +543,7 @@ class GitHubPublisher(_PublisherBase):
544543
action.
545544
"""
546545

547-
environment: Optional[str] = None
546+
environment: str | None = None
548547
"""
549548
The optional name GitHub Actions environment that the publishing
550549
action was performed from.
@@ -637,7 +636,7 @@ class GitLabPublisher(_PublisherBase):
637636
but can be customized.
638637
"""
639638

640-
environment: Optional[str] = None
639+
environment: str | None = None
641640
"""
642641
The optional environment that the publishing action was performed from.
643642
"""
@@ -661,7 +660,7 @@ def _as_policy(self) -> VerificationPolicy:
661660
return policy.Identity(identity=self.email, issuer="https://accounts.google.com")
662661

663662

664-
_Publisher = Union[GitHubPublisher, GitLabPublisher, GooglePublisher]
663+
_Publisher = GitHubPublisher | GitLabPublisher | GooglePublisher
665664
Publisher = Annotated[_Publisher, Field(discriminator="kind")]
666665

667666

0 commit comments

Comments
 (0)