Skip to content

Commit

Permalink
Declare 3.13 support
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Sep 8, 2024
1 parent 2645b32 commit a874188
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 83 deletions.
48 changes: 26 additions & 22 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,36 @@ concurrency:

jobs:
test:
name: test with ${{ matrix.py }}
name: test ${{ matrix.py }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
- "3.9"
steps:
- uses: actions/checkout@v4
- name: setup uv for tox
uses: yezz123/setup-uv@v4
- name: setup python for tox
uses: actions/setup-python@v5
with:
fetch-depth: 0
- name: Setup python for test ${{ matrix.py }}
python-version: "3.12"
- name: install tox
run: uv pip install tox tox-uv --system
- uses: actions/checkout@v4
- name: setup python for test ${{ matrix.py }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- name: Install tox
run: python -m pip install tox-uv
- name: Setup test suite
run: tox -e py -vv --notest
- name: Run test suite
run: tox -e py --skip-pkg-install
env:
PYTEST_ADDOPTS: "-vv --durations=20"
allow-prereleases: true
- name: setup test suite
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }}
- name: run test suite
run: tox run --skip-pkg-install -e ${{ matrix.py }}

check:
name: tox env ${{ matrix.tox_env }}
Expand All @@ -50,18 +54,18 @@ jobs:
tox_env:
- type
- dev
- pkg_meta
- readme
steps:
- name: setup uv for tox
uses: yezz123/setup-uv@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python 3.12
- name: setup Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install tox
run: python -m pip install tox
- name: Run check for ${{ matrix.tox_env }}
run: tox -e ${{ matrix.tox_env }}
env:
UPGRADE_ADVISORY: "yes"
- name: install tox
run: uv pip install tox tox-uv --system
- name: Setup test suite
run: tox -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }}
- name: Run test suite
run: tox --skip-pkg-install -e ${{ matrix.tox_env }}
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ jobs:
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/pypi-changes
url: https://pypi.org/p/pytest-print
permissions:
id-token: write
steps:
- name: Setup python to build package
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: setup uv for tox
uses: yezz123/setup-uv@v4
- name: Install build
run: python -m pip install build
run: uv pip install build[uv] --system
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build package
run: pyproject-build -s -w . -o dist
run: pyproject-build --installer uv --sdist --wheel . --outdir dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.10.1
12 changes: 8 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@ repos:
rev: 0.29.2
hooks:
- id: check-github-workflows
args: [ "--verbose" ]
args: ["--verbose"]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies: ["tomli>=2.0.1"]
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.3.1"
rev: "1.3.2"
hooks:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.2.1"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.13"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.3"
rev: "v0.6.4"
hooks:
- id: ruff-format
- id: ruff
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.3.3"
hooks:
- id: prettier
args: ["--print-width=120", "--prose-wrap=always"]
- repo: meta
hooks:
- id: check-hooks-apply
Expand Down
62 changes: 37 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "hatchling.build"
requires = [
"hatch-vcs>=0.4",
"hatchling>=1.21.1",
"hatchling>=1.25",
]

[project]
Expand Down Expand Up @@ -37,6 +37,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Testing",
"Topic :: Utilities",
Expand All @@ -45,22 +46,22 @@ dynamic = [
"version",
]
dependencies = [
"humanize>=4.9",
"packaging>=23.2",
"platformdirs>=4.2",
"pypi-simple>=1.5",
"requests>=2.31",
"requests-cache>=1.2",
"rich>=13.7",
"humanize>=4.10",
"packaging>=24.1",
"platformdirs>=4.3.1",
"pypi-simple>=1.6",
"requests>=2.32.3",
"requests-cache>=1.2.1",
"rich>=13.8",
]
optional-dependencies.testing = [
"covdefaults>=2.3",
"pytest>=8.0.2",
"pytest-cov>=4.1",
"pytest-mock>=3.12",
"pytest>=8.3.2",
"pytest-cov>=5",
"pytest-mock>=3.14",
"urllib3<2",
"vcrpy>=6.0.1",
"virtualenv>=20.25.1",
"virtualenv>=20.26.4",
]
urls.Homepage = "https://github.com/gaborbernat/pypi_changes"
urls.Source = "https://github.com/gaborbernat/pypi_changes"
Expand All @@ -74,37 +75,48 @@ version.source = "vcs"
[tool.ruff]
target-version = "py39"
line-length = 120
select = [
format.preview = true
format.docstring-code-line-length = 100
format.docstring-code-format = true
lint.select = [
"ALL",
]
isort = { known-first-party = [
"pypi_changes",
], required-imports = [
"from __future__ import annotations",
] }
ignore = [
"CPY", # No copyright header
"INP001", # no implicit namespaces here
lint.ignore = [
"ANN101", # no type annotation for self
"ANN401", # allow Any as type annotation
"COM812", # Conflict with formatter
"CPY", # No copyright statements
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
"DOC", # no support
"ISC001", # Conflict with formatter
"S104", # Possible binding to all interface
]
per-file-ignores."tests/**/*.py" = [
"S101", # asserts allowed in tests...
lint.per-file-ignores."tests/**/*.py" = [
"D", # don't care about documentation in tests
"FBT", # don't care about booleans as positional arguments in tests
"D", # don"t care about documentation in tests
"S603", # `subprocess` call: check for execution of untrusted input
"INP001", # no implicit namespace
"PLC2701", # allow private import
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
"S101", # asserts allowed in tests≈
"S603", # `subprocess` call: check for execution of untrusted input
]
lint.isort = { known-first-party = [
"pypi_changes",
], required-imports = [
"from __future__ import annotations",
] }
lint.preview = true

[tool.codespell]
builtin = "clear,usage,en-GB_to_en-US"
write-changes = true
count = true
skip = "*.yaml"

[tool.pyproject-fmt]
max_supported_python = "3.13"

[tool.coverage]
html.show_contexts = true
html.skip_covered = false
Expand Down
2 changes: 1 addition & 1 deletion src/pypi_changes/_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
from importlib.metadata import Distribution, PathDistribution
from pathlib import Path
from subprocess import check_output
from subprocess import check_output # noqa: S404
from typing import TYPE_CHECKING

from rich.console import Console
Expand Down
4 changes: 2 additions & 2 deletions src/pypi_changes/_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class SpeedColumn(TextColumn):
def __init__(self) -> None:
super().__init__("[bold cyan]")

def render(self, task: Task) -> Text:
def render(self, task: Task) -> Text: # noqa: PLR6301
if task.speed is None:
return Text("no speed")
return Text(f"{task.speed:.3f} steps/s")
Expand Down Expand Up @@ -135,6 +135,6 @@ def _merge_with_index_server(


__all__ = [
"pypi_info",
"Package",
"pypi_info",
]
6 changes: 3 additions & 3 deletions src/pypi_changes/_pkg.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import annotations

from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast

from packaging.version import Version

if TYPE_CHECKING:
from importlib.metadata import PathDistribution
from pathlib import Path


class Package:
Expand Down Expand Up @@ -43,7 +43,7 @@ def version(self) -> str:

@property
def path(self) -> Path:
return self.dist._path # noqa: SLF001
return cast(Path, self.dist._path) # noqa: SLF001

@property
def current_release(self) -> dict[str, Any]:
Expand Down
4 changes: 2 additions & 2 deletions src/pypi_changes/_print/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pypi_changes._pkg import Package


class _Reversor:
class _Reversor: # noqa: PLW1641
def __init__(self, obj: str) -> None:
self.obj = obj

Expand All @@ -22,7 +22,7 @@ def __lt__(self, other: _Reversor) -> bool:


def get_sorted_pkg_list(distributions: Iterable[Package], options: Options, now: datetime) -> Iterable[Package]:
if options.sort in ["a", "alphabetic"]:
if options.sort in {"a", "alphabetic"}:
return sorted(distributions, key=lambda v: v.name.lower())
return sorted(distributions, key=lambda v: (v.last_release_at or now, _Reversor(v.name)), reverse=True)

Expand Down
2 changes: 1 addition & 1 deletion src/pypi_changes/_print/json.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations
from __future__ import annotations # noqa: A005

import json
from datetime import datetime, timezone
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
MakeDist = Callable[[Path, str, str], MagicMock]

__all__ = [
"PathDistribution",
"MakeDist",
"PathDistribution",
]
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

import subprocess
import subprocess # noqa: S404
import sys
from pathlib import Path

Expand Down
2 changes: 1 addition & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


def test_version() -> None:
from pypi_changes import __version__
from pypi_changes import __version__ # noqa: PLC0415

assert __version__
Loading

0 comments on commit a874188

Please sign in to comment.