Skip to content

Declare support for Python 3.12 #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ jobs:
max-parallel: 4
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: |
3.7
3.11
- name: Install dependencies
run: |
python -m pip install -c constraints.txt pip
Expand All @@ -30,13 +31,13 @@ jobs:
inv mkdir build/coverage-data
inv tox -e "py37-*"

test-py38-py39-py310:
test-py38-py39-py310-py311-py312:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 8
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -61,7 +62,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.10"]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ decorators are extracted from the ast.
-U -r requirements.txt`.
* Start developing.
* To run all tests with [tox](https://tox.readthedocs.io/en/latest/),
Python 3.7, 3.8, 3.9, 3.10 and 3.11 must be available. You might want to look
into using [pyenv](https://github.com/pyenv/pyenv).
Python 3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 must be available. You
might want to look into using
[pyenv](https://github.com/pyenv/pyenv).


# Changelog
Expand All @@ -141,8 +142,10 @@ decorators are extracted from the ast.

* Add support for pytest 8 (no actual change, but declare support)
([#46][i46], [#47][p47])
* Declare support for Python 3.12 ([#50][p50])
* Update GitHub actions ([#48][p48])
* Update development dependencies ([#49][p49])
* In GitHub PRs run tests with Python 3.11 and 3.12 ([#50][p50])

## v0.1.1

Expand Down Expand Up @@ -233,3 +236,4 @@ decorators are extracted from the ast.
[p47]: https://github.com/davidfritzsche/pytest-mypy-testing/pull/47
[p48]: https://github.com/davidfritzsche/pytest-mypy-testing/pull/48
[p49]: https://github.com/davidfritzsche/pytest-mypy-testing/pull/49
[p50]: https://github.com/davidfritzsche/pytest-mypy-testing/pull/50
9 changes: 9 additions & 0 deletions constraints.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: David Fritzsche
# SPDX-License-Identifier: CC0-1.0
atomicwrites==1.4.0
filelock <3.12.3; python_version < "3.8"
importlib-metadata <6.8; python_version < "3.8"
platformdirs <4.1; python_version < "3.8"
pluggy <1.3; python_version < "3.8"
typing-extensions <4.8; python_version < "3.8"
zipp <3.16; python_version < "3.8"
21 changes: 13 additions & 8 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dflit-core==2.3.0.1
distlib==0.3.8
docutils==0.20.1
exceptiongroup==1.2.0
filelock==3.12.2
filelock==3.13.1
flake8==7.0.0
flake8-bugbear==24.2.6
flake8-comprehensions==3.14.0
Expand All @@ -32,7 +32,6 @@ flake8-mutable==1.2.0
flake8-pyi==24.1.0
fsfe-reuse==1.0.0
idna==3.6
importlib-metadata==6.7.0
iniconfig==2.0.0
invoke==2.2.0
isort==5.13.2
Expand All @@ -44,16 +43,16 @@ mypy==1.8.0
mypy-extensions==1.0.0
packaging==23.2
pathspec==0.12.1
pip==23.1.2
pip==24.0
pip-tools==7.4.0
platformdirs==4.0.0
pluggy==1.2.0
platformdirs==4.2.0
pluggy==1.4.0
py==1.11.0
pycodestyle==2.11.1
pyflakes==3.2.0
pygments==2.17.2
pyproject-hooks==1.0.0
pytest==7.4.4
pytest==8.0.2
pytest-cov==4.1.0
pytest-html==4.1.1
pytest-metadata==3.1.1
Expand All @@ -67,8 +66,14 @@ tomli==2.0.1
tox==3.28.0
tox-pyenv==1.1.0
types-invoke==2.0.0.10
typing-extensions==4.7.1
typing-extensions==4.10.0
urllib3==2.2.1
virtualenv==20.25.1
wheel==0.42.0
zipp==3.15.0
atomicwrites==1.4.0
filelock <3.12.3; python_version < "3.8"
importlib-metadata <6.8; python_version < "3.8"
platformdirs <4.1; python_version < "3.8"
pluggy <1.3; python_version < "3.8"
typing-extensions <4.8; python_version < "3.8"
zipp <3.16; python_version < "3.8"
14 changes: 12 additions & 2 deletions lock-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@

export CUSTOM_COMPILE_COMMAND="./lock-requirements.sh"

PYTHONWARNINGS=ignore pip-compile --unsafe-package='' --no-emit-index-url --resolver=backtracking "$@"
export PYTHONWARNINGS=ignore

pip-compile \
--unsafe-package='' \
--no-emit-index-url \
--resolver=backtracking \
-o requirements.txt \
requirements.in \
"$@"

cat >constraints.txt <<EOF
# SPDX-FileCopyrightText: David Fritzsche
# SPDX-License-Identifier: CC0-1.0
Expand All @@ -16,4 +25,5 @@ cat >constraints.txt <<EOF
# ./lock-requirements.sh
#
EOF
sed -E -e 's/(\[.*\])//g' -e '/^ *#/d' -e '/^$/d' requirements.txt >> constraints.txt
sed -E -e 's/(\[.*\])//g' -e '/^ *#/d' -e '/^$/d' requirements.txt >>constraints.txt
cat constraints.in | grep -v -E '^#' >>constraints.txt
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Typing :: Typed",
]
description-file = "README.md"
Expand All @@ -43,7 +44,7 @@ include = ["src/pytest_mypy_testing/_version.py"]

[tool.black]
line-length = 88
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312']
include = '\.pyi?$'
extend-exclude = '''
(
Expand Down
7 changes: 7 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
testpaths =
tests mypy_tests pytest_mypy_testing
addopts =
--durations=20
--doctest-continue-on-failure
--doctest-modules
--failed-first
--pyargs
--showlocals
-p no:mypy-testing
--verbose
--verbose
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ELLIPSIS
log_level = DEBUG
junit_family = xunit2

# By default report warnings as errors
filterwarnings =
error
# Ignore some Python 3.12 related deprecations
ignore:datetime.datetime.utc.* is deprecated
ignore:ast.[A-Za-z]* is deprecated
ignore:Attribute s is deprecated
11 changes: 3 additions & 8 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@ isort
mypy ~=1.8
pip
pip-tools
pytest <8
pytest
pytest-cov
pytest-html
setuptools >=69
tox <4
tox-pyenv
types-invoke

# to let the tox setup stay compatible with Python 3.7
filelock <3.12.3
importlib-metadata <6.8
platformdirs <4.1
pluggy <1.3
typing-extensions <4.8
zipp <3.16
# Consider constraints constraints.in
-c constraints.in
22 changes: 6 additions & 16 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ docutils==0.20.1
# via dflit
exceptiongroup==1.2.0
# via pytest
filelock==3.12.2
filelock==3.13.1
# via
# -r requirements.in
# tox
# virtualenv
flake8==7.0.0
Expand All @@ -72,8 +71,6 @@ fsfe-reuse==1.0.0
# via -r requirements.in
idna==3.6
# via requests
importlib-metadata==6.7.0
# via -r requirements.in
iniconfig==2.0.0
# via pytest
invoke==2.2.0
Expand Down Expand Up @@ -105,20 +102,18 @@ packaging==23.2
# tox
pathspec==0.12.1
# via black
pip==23.1.2
pip==24.0
# via
# -r requirements.in
# pip-tools
pip-tools==7.4.0
# via -r requirements.in
platformdirs==4.0.0
platformdirs==4.2.0
# via
# -r requirements.in
# black
# virtualenv
pluggy==1.2.0
pluggy==1.4.0
# via
# -r requirements.in
# pytest
# tox
py==1.11.0
Expand All @@ -135,7 +130,7 @@ pyproject-hooks==1.0.0
# via
# build
# pip-tools
pytest==7.4.4
pytest==8.0.2
# via
# -r requirements.in
# pytest-cov
Expand Down Expand Up @@ -181,9 +176,8 @@ tox-pyenv==1.1.0
# via -r requirements.in
types-invoke==2.0.0.10
# via -r requirements.in
typing-extensions==4.7.1
typing-extensions==4.10.0
# via
# -r requirements.in
# black
# mypy
urllib3==2.2.1
Expand All @@ -192,7 +186,3 @@ virtualenv==20.25.1
# via tox
wheel==0.42.0
# via pip-tools
zipp==3.15.0
# via
# -r requirements.in
# importlib-metadata
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def mkdir(ctx, dirname):

@task
def pth(ctx):
import distutils.sysconfig
import sysconfig

site_packages_dir = distutils.sysconfig.get_python_lib()
site_packages_dir = sysconfig.get_path("purelib")
pth_filename = os.path.join(site_packages_dir, "subprojects.pth")
with open(pth_filename, "w", encoding="utf-8") as f:
print(os.path.abspath("src"), file=f)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_basics.mypy-testing
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@ import pytest


@pytest.mark.mypy_testing
def mypy_test_invalid_assginment():
def mypy_test_invalid_assignment():
foo = "abc"
foo = 123 # E: Incompatible types in assignment (expression has type "int", variable has type "str")


@pytest.mark.mypy_testing
def mypy_test_invalid_assginment_with_error_code():
def mypy_test_invalid_assignment_with_error_code():
foo = "abc"
foo = 123 # E: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment]


@pytest.mark.xfail
@pytest.mark.mypy_testing
def mypy_test_invalid_assginment_with_error_code__message_does_not_match():
def mypy_test_invalid_assignment_with_error_code__message_does_not_match():
foo = "abc"
foo = 123 # E: Invalid assignment [assignment]


@pytest.mark.mypy_testing
def mypy_test_invalid_assginment_only_error_code():
def mypy_test_invalid_assignment_only_error_code():
foo = "abc"
foo = 123 # E: [assignment]


@pytest.mark.xfail
@pytest.mark.mypy_testing
def mypy_test_invalid_assginment_only_error_code__error_code_does_not_match():
def mypy_test_invalid_assignment_only_error_code__error_code_does_not_match():
foo = "abc"
foo = 123 # E: [baz]


@pytest.mark.xfail
@pytest.mark.mypy_testing
def mypy_test_invalid_assginment_no_message_and_no_error_code():
def mypy_test_invalid_assignment_no_message_and_no_error_code():
foo = "abc"
foo = 123 # E:

Expand Down
20 changes: 19 additions & 1 deletion tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import ast
import sys
import typing as _typing
from tokenize import COMMENT, ENDMARKER, NAME, NEWLINE, NL, TokenInfo
from unittest.mock import Mock

Expand Down Expand Up @@ -52,7 +53,7 @@ def test_iter_comments():
actual = list(generate_per_line_token_lists(source))

# fmt: off
expected = [
expected:_typing.List[_typing.List[TokenInfo]] = [
[], # line 0
[
TokenInfo(type=COMMENT, string="# foo", start=(1, 0), end=(1, 5), line="# foo\n",),
Expand All @@ -70,6 +71,23 @@ def test_iter_comments():
]
# fmt: on

# some patching due to differences between Python versions...
for lineno, line_toks in enumerate(actual):
for i, tok in enumerate(line_toks):
if tok.type == NEWLINE:
try:
expected_tok = expected[lineno][i]
if expected_tok.type == NEWLINE:
expected[lineno][i] = TokenInfo(
type=expected_tok.type,
string=expected_tok.string,
start=expected_tok.start,
end=expected_tok.end,
line=tok.line,
)
except IndexError:
pass

assert actual == expected


Expand Down
Loading