Skip to content

Commit

Permalink
Adds support for Python 3.11+. Drops Python 3.7 support.
Browse files Browse the repository at this point in the history
Uses trusted publishers for PyPI workflow.
  • Loading branch information
Daverball committed Aug 21, 2024
1 parent b1bf0d1 commit 48e5a0e
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
30 changes: 19 additions & 11 deletions .github/workflows/python-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@ jobs:

runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/project/ais2-py

permissions:
id-token: write

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build -s -w
twine upload dist/*
pip install build
- name: Build package distributions
run: python -m build -s -w

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
7 changes: 4 additions & 3 deletions .github/workflows/python-tox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Get branch name (merge)
if: github.event_name != 'pull_request'
Expand All @@ -28,9 +28,10 @@ jobs:
>> $GITHUB_ENV
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install dependencies
run: |
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
Expand All @@ -15,17 +15,17 @@ repos:
additional_dependencies:
- types_requests
- repo: https://github.com/seantis/pre-commit-hooks
rev: v1.0.1
rev: v1.1.0
hooks:
- id: nocheckin
exclude: .pre-commit-config.yaml
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 7.1.1
hooks:
- id: flake8
files: '^(AIS/.*|tests/.*|setup)\.py$'
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
rev: v1.11.1
hooks:
- id: mypy
files: '^AIS/.*\.py$'
Expand Down
13 changes: 7 additions & 6 deletions AIS/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


from typing import overload
from typing import BinaryIO
from typing import IO
from typing import Optional
from typing import TYPE_CHECKING
if TYPE_CHECKING:
Expand All @@ -40,7 +40,7 @@ def __init__(
self,
input_file: 'FileLike',
*,
out_stream: Optional[BinaryIO] = ...,
out_stream: Optional[IO[bytes]] = ...,
sig_name: str = ...,
sig_size: int = ...
): ...
Expand All @@ -49,7 +49,7 @@ def __init__(
def __init__(
self,
*,
inout_stream: BinaryIO,
inout_stream: IO[bytes],
sig_name: str = ...,
sig_size: int = ...
): ...
Expand All @@ -58,8 +58,8 @@ def __init__(
self,
input_file: Optional['FileLike'] = None,
*,
inout_stream: Optional[BinaryIO] = None,
out_stream: Optional[BinaryIO] = None,
inout_stream: Optional[IO[bytes]] = None,
out_stream: Optional[IO[bytes]] = None,
sig_name: str = 'Signature',
sig_size: int = 64*1024, # 64 KiB
):
Expand Down Expand Up @@ -149,8 +149,9 @@ def __init__(
"""Signing I/O setup to be passed to pyHanko"""

@property
def out_stream(self) -> BinaryIO:
def out_stream(self) -> IO[bytes]:
"""Output stream for the signed PDF."""
assert self.sig_io_setup.output is not None
return self.sig_io_setup.output

def digest(self) -> str:
Expand Down
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Release History
---------------

- Add Python 3.11, 3.12, 3.13 support
- Remove Python 3.7 support

2.2.1 (2022-09-02)
++++++++++++++++++

Expand Down
20 changes: 11 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exclude_lines = [
]

[tool.mypy]
python_version = "3.10"
python_version = "3.8"
follow_imports = "silent"
warn_redundant_casts = true
warn_unreachable = true
Expand All @@ -46,19 +46,21 @@ ignore_missing_imports = true
legacy_tox_ini = """
[tox]
isolated_build = True
envlist = py37,py38,py39,py310,pypy,lint,bandit,mypy
envlist = py38,py39,py310,py311,py312,py313,pypy,lint,bandit,mypy
[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310,lint,bandit,mypy
3.10: py310
3.11: py311,lint,bandit,mypy
3.12: py312
3.13: py313
[testenv]
setenv =
py{37,38,39,310}: COVERAGE_FILE = .coverage.{envname}
passenv = AIS_CUSTOMER AIS_KEY_STATIC AIS_CERT_FILE AIS_CERT_KEY AIS_SSL_CA
py{38,39,310,311,312,313}: COVERAGE_FILE = .coverage.{envname}
passenv = AIS_CUSTOMER,AIS_KEY_STATIC,AIS_CERT_FILE,AIS_CERT_KEY,AIS_SSL_CA
deps =
pytest>=2.8.0
vcrpy>=1.7.0
Expand All @@ -67,20 +69,20 @@ deps =
commands = py.test --cov={envsitepackagesdir}/AIS --cov-report= {posargs}
[testenv:lint]
basepython = python3.10
basepython = python3.11
deps =
flake8
commands = flake8 AIS/ tests/
[testenv:mypy]
basepython = python3.10
basepython = python3.11
deps =
mypy
types-requests
commands = mypy -p AIS
[testenv:bandit]
basepython = python3.10
basepython = python3.11
deps =
bandit[toml]
commands = bandit -c pyproject.toml -r AIS/
Expand Down
6 changes: 4 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ classifiers =
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy

[options]
include_package_data = True
packages =
AIS
python_requires = >=3.7
python_requires = >=3.8
install_requires =
requests >=2.0
pyHanko >=0.9.0
Expand Down

0 comments on commit 48e5a0e

Please sign in to comment.