Skip to content

Commit

Permalink
Add support for python version up to 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
dbatten5 committed Jan 19, 2024
1 parent e467fe0 commit a22cb2e
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 62 deletions.
2 changes: 0 additions & 2 deletions .darglint

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==21.3.1
nox==2021.10.1
nox-poetry==0.8.6
poetry==1.3.1
virtualenv==20.10.0
pip==23.0.1
nox==2022.11.21
nox-poetry==1.0.3
poetry==1.4.2
virtualenv==20.15.0
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v2.3.1
uses: actions/setup-python@v4.6.1
with:
python-version: "3.9"
python-version: "3.11"

- name: Upgrade pip
run: |
Expand Down
74 changes: 46 additions & 28 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,38 @@ on:

jobs:
tests:
name: ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }}
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { python-version: 3.9, os: ubuntu-latest, session: "pre-commit" }
# - { python-version: 3.9, os: ubuntu-latest, session: "safety" }
- { python-version: 3.9, os: ubuntu-latest, session: "mypy" }
- { python-version: 3.8, os: ubuntu-latest, session: "mypy" }
- { python-version: 3.9, os: ubuntu-latest, session: "tests" }
- { python-version: 3.8, os: ubuntu-latest, session: "tests" }
- { python-version: 3.9, os: windows-latest, session: "tests" }
- { python-version: 3.9, os: macos-latest, session: "tests" }
- { python-version: 3.9, os: ubuntu-latest, session: "typeguard" }
- { python-version: 3.9, os: ubuntu-latest, session: "xdoctest" }
- { python: "3.11", os: ubuntu-latest, session: "pre-commit" }
- { python: "3.11", os: ubuntu-latest, session: "safety" }
- { python: "3.11", os: ubuntu-latest, session: "mypy" }
- { python: "3.10", os: ubuntu-latest, session: "mypy" }
- { python: "3.9", os: ubuntu-latest, session: "mypy" }
- { python: "3.8", os: ubuntu-latest, session: "mypy" }
- { python: "3.11", os: ubuntu-latest, session: "tests" }
- { python: "3.10", os: ubuntu-latest, session: "tests" }
- { python: "3.9", os: ubuntu-latest, session: "tests" }
- { python: "3.8", os: ubuntu-latest, session: "tests" }
- { python: "3.11", os: windows-latest, session: "tests" }
# - { python: "3.11", os: macos-latest, session: "tests" }
- { python: "3.11", os: ubuntu-latest, session: "typeguard" }
- { python: "3.11", os: "ubuntu-latest", session: "docs-build" }

env:
NOXSESSION: ${{ matrix.session }}
TMDB_API_KEY: ${{secrets.TMDB_API_KEY}}
FORCE_COLOR: "1"
PRE_COMMIT_COLOR: "always"

steps:
- name: Check out the repository
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -47,14 +53,24 @@ jobs:
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Upgrade pip in virtual environments
shell: python
run: |
import os
import pip
with open(os.environ["GITHUB_ENV"], mode="a") as io:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
pipx install --pip-args --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Compute pre-commit cache key
Expand All @@ -73,7 +89,7 @@ jobs:
print("::set-output name=result::{}".format(result))
- name: Restore pre-commit cache
uses: actions/cache@v3.2.3
uses: actions/cache@v3
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
Expand All @@ -83,11 +99,11 @@ jobs:
- name: Run Nox
run: |
nox --force-color --python=${{ matrix.python-version }}
nox --python=${{ matrix.python }}
- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/upload-artifact@v3.1.2"
uses: "actions/upload-artifact@v3"
with:
name: coverage-data
path: ".coverage.*"
Expand All @@ -97,12 +113,12 @@ jobs:
needs: tests
steps:
- name: Check out the repository
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3

- name: Set up Python 3.9
uses: actions/setup-python@v2.3.1
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.9
python-version: "3.11"

- name: Upgrade pip
run: |
Expand All @@ -111,26 +127,28 @@ jobs:
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Download coverage data
uses: actions/download-artifact@v3.0.2
uses: actions/download-artifact@v3
with:
name: coverage-data

- name: Combine coverage data and display human readable report
run: |
nox --force-color --session=coverage
nox --session=coverage
- name: Create coverage report
run: |
nox --force-color --session=coverage -- xml
nox --session=coverage -- xml
- name: Upload coverage report
uses: codecov/codecov-action@v2.0.2
uses: codecov/codecov-action@v3
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ git clone [email protected]:<your username>/phylm.git
cd phylm
```

You'll need `python` 3.8 or 3.9 to run this package. You can follow
You'll need `python` 3.8+ to run this package. You can follow
the instructions [here](https://cookiecutter-hypermodern-python.readthedocs.io/en/2021.6.15/guide.html#getting-python)
to install and use these versions.

Expand Down
30 changes: 11 additions & 19 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@


package = "phylm"
python_versions = ["3.9", "3.8"]
python_versions = ["3.11", "3.10", "3.9", "3.8"]
nox.needs_version = ">= 2021.6.6"
nox.options.sessions = (
"pre-commit",
# "safety",
"mypy",
"tests",
"typeguard",
"xdoctest",
)


Expand Down Expand Up @@ -82,25 +81,27 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
hook.write_text("\n".join(lines))


@session(name="pre-commit", python="3.9")
@session(name="pre-commit", python=python_versions[0])
def precommit(session: Session) -> None:
"""Lint using pre-commit."""
args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"]
args = session.posargs or [
"run",
"--all-files",
"--hook-stage=manual",
"--show-diff-on-failure",
]
session.install(
"black",
"darglint",
"ruff",
"pep8-naming",
"pre-commit",
"pre-commit-hooks",
"reorder-python-imports",
)
session.run("pre-commit", *args)
if args and args[0] == "install":
activate_virtualenv_in_precommit_hooks(session)


@session(python="3.9")
@session(python=python_versions[0])
def safety(session: Session) -> None:
"""Scan dependencies for insecure packages."""
requirements = session.poetry.export_requirements()
Expand Down Expand Up @@ -131,7 +132,7 @@ def tests(session: Session) -> None:
session.notify("coverage", posargs=[])


@session
@session(python=python_versions[0])
def coverage(session: Session) -> None:
"""Produce the coverage report."""
args = session.posargs or ["report"]
Expand All @@ -144,18 +145,9 @@ def coverage(session: Session) -> None:
session.run("coverage", *args)


@session(python=python_versions)
@session(python=python_versions[0])
def typeguard(session: Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".")
session.install("pytest", "typeguard", "pygments", "vcrpy")
session.run("pytest", f"--typeguard-packages={package}", *session.posargs)


@session(python=python_versions)
def xdoctest(session: Session) -> None:
"""Run examples with xdoctest."""
args = session.posargs or ["all"]
session.install(".")
session.install("xdoctest[colors]")
session.run("python", "-m", "xdoctest", package, *args)
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]

[tool.poetry.urls]
Expand All @@ -26,7 +28,7 @@ aiohttp = "^3.8.1"
cinemagoer = "^2023.05.01"

[tool.poetry.group.test.dependencies]
pytest = "^6.2.4"
pytest = "^7.4.4"
coverage = {extras = ["toml"], version = "^6.1"}
vcrpy = "^4.1.1"
pytest-aiohttp = "^0.3.0"
Expand All @@ -36,12 +38,8 @@ pytest-asyncio = "^0.16.0"
safety = "^2.2.0"
mypy = "^0.910"
typeguard = "^2.12.1"
xdoctest = {extras = ["colors"], version = "^0.15.5"}
pre-commit = "^2.13.0"
black = "^22.12.0"
pep8-naming = "^0.12.0"
darglint = "^1.8.0"
reorder-python-imports = "^2.6.0"
pre-commit-hooks = "^4.0.1"
Pygments = "^2.9.0"
types-requests = "^2.25.11"
Expand Down

0 comments on commit a22cb2e

Please sign in to comment.