Skip to content

Commit

Permalink
chore: drop python3.7&3.8. support 3.13. pre-commit update. allow myp…
Browse files Browse the repository at this point in the history
…y to run on tests/ dir with laxer rules
  • Loading branch information
jakkdl committed Feb 7, 2025
1 parent 985e632 commit a14b47d
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 41 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.13

- run: pip install pre-commit
- run: SKIP=mypy pre-commit run --all-files
Expand All @@ -39,7 +39,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.13

- run: pip install pre-commit
- run: pre-commit run mypy --all-files
Expand All @@ -50,20 +50,14 @@ jobs:
strategy:
matrix:
include:
- tox_job: py37
python: "3.7"
os_version: "ubuntu-latest"
- tox_job: py38
python: "3.8"
os_version: "ubuntu-latest"
- tox_job: py39
python: "3.9"
os_version: "ubuntu-latest"
- tox_job: no_pycurl
python: "3.8"
python: "3.9"
os_version: "ubuntu-latest"
- tox_job: vcr_431
python: "3.8"
python: "3.9"
os_version: "ubuntu-latest"
- tox_job: py310
python: "3.10"
Expand All @@ -74,6 +68,9 @@ jobs:
- tox_job: py312
python: "3.12"
os_version: "ubuntu-latest"
- tox_job: py313
python: "3.13"
os_version: "ubuntu-latest"

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.11
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.13

- run: pip install hatch

Expand Down
19 changes: 9 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
default_language_version:
python: python3.11
python: python3.13

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
Expand All @@ -20,34 +20,33 @@ repos:
- id: gitlint

- repo: https://github.com/adrienverge/yamllint
rev: v1.33.0
rev: v1.35.1
hooks:
- id: yamllint

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.37.0
rev: v0.44.0
hooks:
- id: markdownlint
language_version: system

- repo: https://github.com/codingjoe/relint
rev: 3.1.0
rev: 3.3.1
hooks:
- id: relint

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
rev: v1.15.0
hooks:
- id: mypy
exclude: ^(docs/|tests/|setup.py).*$
additional_dependencies: [ "types-pycurl" ]
additional_dependencies: [ "types-pycurl", "types-PyYAML" ]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
rev: v0.9.5
hooks:
- id: ruff-format

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
rev: v0.9.5
hooks:
- id: ruff
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Submitting Pull Requests
#. Follow **PEP-8** for naming and `ruff <https://github.com/astral-sh/ruff>`_ for formatting.
#. Tests are run using ``tox``::

tox -e py37
tox -e py39

The test environments above are usually enough to cover most cases locally.

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ Python support

Pytest-recording supports:

- CPython 3.7, 3.8, 3.9, 3.10, 3.11, and 3.12
- PyPy 7 (3.6)
- CPython 3.9, 3.10, 3.11, 3.12, and 3.13
- PyPy 7.3 (3.10)

License
-------
Expand Down
9 changes: 8 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.11
python_version = 3.13
show_error_context = true
verbosity = 0
ignore_missing_imports = false
Expand All @@ -14,3 +14,10 @@ disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_decorators = true

[mypy-tests.*]
disallow_untyped_calls = false
disallow_untyped_defs = false

[mypy-vcr.*]
ignore_missing_imports = True
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A pytest plugin that allows you recording of network interactions
keywords = ["pytest", "vcr", "network", "mock"]
authors = [{ name = "Dmitry Dygalo", email = "dmitry@dygalo.dev" }]
maintainers = [{ name = "Dmitry Dygalo", email = "dmitry@dygalo.dev" }]
requires-python = ">=3.7"
requires-python = ">=3.9"
license = "MIT"
readme = "README.rst"
classifiers = [
Expand All @@ -18,17 +18,15 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Topic :: Software Development :: Testing",
"Typing :: Typed",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"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",
"Operating System :: OS Independent",
Expand Down Expand Up @@ -80,7 +78,7 @@ ignore = [
"D213", # Multiline summary second line
"D401", # Imperative mood
]
target-version = "py37"
target-version = "py39"

[tool.ruff.format]
skip-magic-trailing-comma = false
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_recording/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def default_cassette_name(request: SubRequest) -> str:
marker = request.node.get_closest_marker("default_cassette")
if marker is not None:
assert marker.args, (
"You should pass the cassette name as an argument " "to the `pytest.mark.default_cassette` marker"
"You should pass the cassette name as an argument to the `pytest.mark.default_cassette` marker"
)
return marker.args[0]
return get_default_cassette_name(request.cls, request.node.name)
Expand Down
Empty file added src/pytest_recording/py.typed
Empty file.
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this file is only here so mypy can see it as a module and allow custom rules
6 changes: 3 additions & 3 deletions tests/test_blocking_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Case with different SSL backends should be loud and visible
# Could happen with development when environment is recreated (e.g. locally)
raise
pycurl = None
pycurl = None # type: ignore[assignment]


def assert_network_blocking(testdir, dirname):
Expand Down Expand Up @@ -419,9 +419,9 @@ def test_pycurl_setattr():
# When pycurl is used for network access
# And an attribute is set on an instance
curl = pycurl.Curl()
curl.attr = 42
curl.attr = 42 # type: ignore[attr-defined]
# Then it should be proxied to the original Curl instance itself
assert curl.handle.attr == 42
assert curl.handle.attr == 42 # type: ignore[attr-defined]


@pytest.mark.skipif(pycurl is None, reason="Requires pycurl installed.")
Expand Down
4 changes: 4 additions & 0 deletions tests/test_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import pytest
import yaml

from typing import Any


def test_cassette_recording(testdir):
testdir.makepyfile(
Expand Down Expand Up @@ -148,6 +150,7 @@ def test_with_network(self, httpbin):
test_function_size = test_function_cassette_path.size()
assert test_function_size
# Cassette should contain uuid as response
cassette: Any
with open(str(test_function_cassette_path), encoding="utf8") as cassette:
cassette = yaml.load(cassette, Loader=yaml.BaseLoader)
test_function_cassette_uuid = cassette["interactions"][0]["response"]["body"]["string"]
Expand Down Expand Up @@ -220,6 +223,7 @@ def test_with_network(httpbin):
# And writing will happen to the default cassette
cassette_size = cassette.size()
assert cassette_size
file: Any
with open(str(cassette), encoding="utf8") as file:
file = yaml.load(file, Loader=yaml.BaseLoader)
uuid = file["interactions"][0]["response"]["body"]["string"]
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{37,38,39,310,311,312,py3},no_pycurl,vcr_431,coverage-report
envlist = py{39,310,311,312,313,py3},no_pycurl,vcr_431,coverage-report

[testenv]
setenv =
Expand All @@ -19,7 +19,7 @@ commands =
coverage run --source=pytest_recording -m pytest {posargs:tests}

[testenv:no_pycurl]
basepython = python3.8
basepython = python3.9
deps =
coverage
pytest>=3.0
Expand All @@ -30,7 +30,7 @@ deps =
commands = coverage run --source=pytest_recording -m pytest {posargs:tests}

[testenv:vcr_431]
basepython = python3.8
basepython = python3.9
deps =
coverage
pytest>=3.0
Expand All @@ -44,10 +44,10 @@ commands =

[testenv:coverage-report]
description = Report coverage over all measured test runs.
basepython = python3.8
basepython = python3.9
deps = coverage
skip_install = true
depends = {py37,py38,py39,py310,py311,py312,pypy3}
depends = {py39,py310,py311,py312,py313,pypy3}
commands =
coverage combine
coverage report
Expand Down

0 comments on commit a14b47d

Please sign in to comment.