Skip to content

Commit cb030a3

Browse files
author
David Fritzsche
committed
Declare support for Python 3.12
1 parent ac65d16 commit cb030a3

13 files changed

+97
-63
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
max-parallel: 4
1212
matrix:
1313
os: [ubuntu-latest, macos-latest, windows-latest]
14-
python-version: ["3.7"]
14+
python-version: ["3.11"]
1515

1616
steps:
1717
- uses: actions/checkout@v4
@@ -21,22 +21,22 @@ jobs:
2121
python-version: ${{ matrix.python-version }}
2222
- name: Install dependencies
2323
run: |
24-
python -m pip install -c constraints.txt pip
25-
python -m pip install -c constraints.txt invoke tox
24+
python3.11 -m pip install -c constraints.txt pip
25+
python3.11 -m pip install -c constraints.txt invoke tox
2626
- name: Run tox
2727
env:
2828
TOX_PARALLEL_NO_SPINNER: "1"
2929
run: |
3030
inv mkdir build/coverage-data
3131
inv tox -e "py37-*"
3232
33-
test-py38-py39-py310:
33+
test-py38-py39-py310-py311-py312:
3434
runs-on: ${{ matrix.os }}
3535
strategy:
3636
max-parallel: 8
3737
matrix:
3838
os: [ubuntu-latest, macos-latest, windows-latest]
39-
python-version: ["3.8", "3.9", "3.10"]
39+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
4040

4141
steps:
4242
- uses: actions/checkout@v4
@@ -61,7 +61,7 @@ jobs:
6161
strategy:
6262
max-parallel: 4
6363
matrix:
64-
python-version: ["3.10"]
64+
python-version: ["3.11"]
6565

6666
steps:
6767
- uses: actions/checkout@v4

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ decorators are extracted from the ast.
131131
-U -r requirements.txt`.
132132
* Start developing.
133133
* To run all tests with [tox](https://tox.readthedocs.io/en/latest/),
134-
Python 3.7, 3.8, 3.9, 3.10 and 3.11 must be available. You might want to look
135-
into using [pyenv](https://github.com/pyenv/pyenv).
134+
Python 3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 must be available. You
135+
might want to look into using
136+
[pyenv](https://github.com/pyenv/pyenv).
136137

137138

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

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

147150
## v0.1.1
148151

@@ -233,3 +236,4 @@ decorators are extracted from the ast.
233236
[p47]: https://github.com/davidfritzsche/pytest-mypy-testing/pull/47
234237
[p48]: https://github.com/davidfritzsche/pytest-mypy-testing/pull/48
235238
[p49]: https://github.com/davidfritzsche/pytest-mypy-testing/pull/49
239+
[p50]: https://github.com/davidfritzsche/pytest-mypy-testing/pull/50

constraints.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-FileCopyrightText: David Fritzsche
2+
# SPDX-License-Identifier: CC0-1.0
3+
atomicwrites==1.4.0
4+
filelock <3.12.3; python_version < "3.8"
5+
importlib-metadata <6.8; python_version < "3.8"
6+
platformdirs <4.1; python_version < "3.8"
7+
pluggy <1.3; python_version < "3.8"
8+
typing-extensions <4.8; python_version < "3.8"
9+
zipp <3.16; python_version < "3.8"

constraints.txt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dflit-core==2.3.0.1
2222
distlib==0.3.8
2323
docutils==0.20.1
2424
exceptiongroup==1.2.0
25-
filelock==3.12.2
25+
filelock==3.13.1
2626
flake8==7.0.0
2727
flake8-bugbear==24.2.6
2828
flake8-comprehensions==3.14.0
@@ -32,7 +32,6 @@ flake8-mutable==1.2.0
3232
flake8-pyi==24.1.0
3333
fsfe-reuse==1.0.0
3434
idna==3.6
35-
importlib-metadata==6.7.0
3635
iniconfig==2.0.0
3736
invoke==2.2.0
3837
isort==5.13.2
@@ -44,16 +43,16 @@ mypy==1.8.0
4443
mypy-extensions==1.0.0
4544
packaging==23.2
4645
pathspec==0.12.1
47-
pip==23.1.2
46+
pip==24.0
4847
pip-tools==7.4.0
49-
platformdirs==4.0.0
50-
pluggy==1.2.0
48+
platformdirs==4.2.0
49+
pluggy==1.4.0
5150
py==1.11.0
5251
pycodestyle==2.11.1
5352
pyflakes==3.2.0
5453
pygments==2.17.2
5554
pyproject-hooks==1.0.0
56-
pytest==7.4.4
55+
pytest==8.0.2
5756
pytest-cov==4.1.0
5857
pytest-html==4.1.1
5958
pytest-metadata==3.1.1
@@ -67,8 +66,14 @@ tomli==2.0.1
6766
tox==3.28.0
6867
tox-pyenv==1.1.0
6968
types-invoke==2.0.0.10
70-
typing-extensions==4.7.1
69+
typing-extensions==4.10.0
7170
urllib3==2.2.1
7271
virtualenv==20.25.1
7372
wheel==0.42.0
74-
zipp==3.15.0
73+
atomicwrites==1.4.0
74+
filelock <3.12.3; python_version < "3.8"
75+
importlib-metadata <6.8; python_version < "3.8"
76+
platformdirs <4.1; python_version < "3.8"
77+
pluggy <1.3; python_version < "3.8"
78+
typing-extensions <4.8; python_version < "3.8"
79+
zipp <3.16; python_version < "3.8"

lock-requirements.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55

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

8-
PYTHONWARNINGS=ignore pip-compile --unsafe-package='' --no-emit-index-url --resolver=backtracking "$@"
8+
export PYTHONWARNINGS=ignore
9+
10+
pip-compile \
11+
--unsafe-package='' \
12+
--no-emit-index-url \
13+
--resolver=backtracking \
14+
-o requirements.txt \
15+
requirements.in \
16+
"$@"
17+
918
cat >constraints.txt <<EOF
1019
# SPDX-FileCopyrightText: David Fritzsche
1120
# SPDX-License-Identifier: CC0-1.0
@@ -16,4 +25,5 @@ cat >constraints.txt <<EOF
1625
# ./lock-requirements.sh
1726
#
1827
EOF
19-
sed -E -e 's/(\[.*\])//g' -e '/^ *#/d' -e '/^$/d' requirements.txt >> constraints.txt
28+
sed -E -e 's/(\[.*\])//g' -e '/^ *#/d' -e '/^$/d' requirements.txt >>constraints.txt
29+
cat constraints.in | grep -v -E '^#' >>constraints.txt

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ classifiers = [
2323
"Programming Language :: Python :: 3.9",
2424
"Programming Language :: Python :: 3.10",
2525
"Programming Language :: Python :: 3.11",
26+
"Programming Language :: Python :: 3.12",
2627
"Typing :: Typed",
2728
]
2829
description-file = "README.md"
@@ -43,7 +44,7 @@ include = ["src/pytest_mypy_testing/_version.py"]
4344

4445
[tool.black]
4546
line-length = 88
46-
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
47+
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312']
4748
include = '\.pyi?$'
4849
extend-exclude = '''
4950
(

pytest.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@
44
testpaths =
55
tests mypy_tests pytest_mypy_testing
66
addopts =
7+
--durations=20
78
--doctest-continue-on-failure
89
--doctest-modules
910
--failed-first
1011
--pyargs
1112
--showlocals
1213
-p no:mypy-testing
14+
--verbose
15+
--verbose
1316
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ELLIPSIS
1417
log_level = DEBUG
1518
junit_family = xunit2
1619

1720
# By default report warnings as errors
1821
filterwarnings =
1922
error
23+
# Ignore some Python 3.12 related deprecations
24+
ignore:datetime.datetime.utc.* is deprecated
25+
ignore:ast.[A-Za-z]* is deprecated
26+
ignore:Attribute s is deprecated

requirements.in

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,13 @@ isort
1616
mypy ~=1.8
1717
pip
1818
pip-tools
19-
pytest <8
19+
pytest
2020
pytest-cov
2121
pytest-html
2222
setuptools >=69
2323
tox <4
2424
tox-pyenv
2525
types-invoke
2626

27-
# to let the tox setup stay compatible with Python 3.7
28-
filelock <3.12.3
29-
importlib-metadata <6.8
30-
platformdirs <4.1
31-
pluggy <1.3
32-
typing-extensions <4.8
33-
zipp <3.16
27+
# Consider constraints constraints.in
28+
-c constraints.in

requirements.txt

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ docutils==0.20.1
4444
# via dflit
4545
exceptiongroup==1.2.0
4646
# via pytest
47-
filelock==3.12.2
47+
filelock==3.13.1
4848
# via
49-
# -r requirements.in
5049
# tox
5150
# virtualenv
5251
flake8==7.0.0
@@ -72,8 +71,6 @@ fsfe-reuse==1.0.0
7271
# via -r requirements.in
7372
idna==3.6
7473
# via requests
75-
importlib-metadata==6.7.0
76-
# via -r requirements.in
7774
iniconfig==2.0.0
7875
# via pytest
7976
invoke==2.2.0
@@ -105,20 +102,18 @@ packaging==23.2
105102
# tox
106103
pathspec==0.12.1
107104
# via black
108-
pip==23.1.2
105+
pip==24.0
109106
# via
110107
# -r requirements.in
111108
# pip-tools
112109
pip-tools==7.4.0
113110
# via -r requirements.in
114-
platformdirs==4.0.0
111+
platformdirs==4.2.0
115112
# via
116-
# -r requirements.in
117113
# black
118114
# virtualenv
119-
pluggy==1.2.0
115+
pluggy==1.4.0
120116
# via
121-
# -r requirements.in
122117
# pytest
123118
# tox
124119
py==1.11.0
@@ -135,7 +130,7 @@ pyproject-hooks==1.0.0
135130
# via
136131
# build
137132
# pip-tools
138-
pytest==7.4.4
133+
pytest==8.0.2
139134
# via
140135
# -r requirements.in
141136
# pytest-cov
@@ -181,9 +176,8 @@ tox-pyenv==1.1.0
181176
# via -r requirements.in
182177
types-invoke==2.0.0.10
183178
# via -r requirements.in
184-
typing-extensions==4.7.1
179+
typing-extensions==4.10.0
185180
# via
186-
# -r requirements.in
187181
# black
188182
# mypy
189183
urllib3==2.2.1
@@ -192,7 +186,3 @@ virtualenv==20.25.1
192186
# via tox
193187
wheel==0.42.0
194188
# via pip-tools
195-
zipp==3.15.0
196-
# via
197-
# -r requirements.in
198-
# importlib-metadata

tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def mkdir(ctx, dirname):
1717

1818
@task
1919
def pth(ctx):
20-
import distutils.sysconfig
20+
import sysconfig
2121

22-
site_packages_dir = distutils.sysconfig.get_python_lib()
22+
site_packages_dir = sysconfig.get_path("purelib")
2323
pth_filename = os.path.join(site_packages_dir, "subprojects.pth")
2424
with open(pth_filename, "w", encoding="utf-8") as f:
2525
print(os.path.abspath("src"), file=f)

tests/test_basics.mypy-testing

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@ import pytest
66

77

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

1313

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

1919

2020
@pytest.mark.xfail
2121
@pytest.mark.mypy_testing
22-
def mypy_test_invalid_assginment_with_error_code__message_does_not_match():
22+
def mypy_test_invalid_assignment_with_error_code__message_does_not_match():
2323
foo = "abc"
2424
foo = 123 # E: Invalid assignment [assignment]
2525

2626

2727
@pytest.mark.mypy_testing
28-
def mypy_test_invalid_assginment_only_error_code():
28+
def mypy_test_invalid_assignment_only_error_code():
2929
foo = "abc"
3030
foo = 123 # E: [assignment]
3131

3232

3333
@pytest.mark.xfail
3434
@pytest.mark.mypy_testing
35-
def mypy_test_invalid_assginment_only_error_code__error_code_does_not_match():
35+
def mypy_test_invalid_assignment_only_error_code__error_code_does_not_match():
3636
foo = "abc"
3737
foo = 123 # E: [baz]
3838

3939

4040
@pytest.mark.xfail
4141
@pytest.mark.mypy_testing
42-
def mypy_test_invalid_assginment_no_message_and_no_error_code():
42+
def mypy_test_invalid_assignment_no_message_and_no_error_code():
4343
foo = "abc"
4444
foo = 123 # E:
4545

tests/test_parser.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import ast
55
import sys
6+
import typing as _typing
67
from tokenize import COMMENT, ENDMARKER, NAME, NEWLINE, NL, TokenInfo
78
from unittest.mock import Mock
89

@@ -52,7 +53,7 @@ def test_iter_comments():
5253
actual = list(generate_per_line_token_lists(source))
5354

5455
# fmt: off
55-
expected = [
56+
expected:_typing.List[_typing.List[TokenInfo]] = [
5657
[], # line 0
5758
[
5859
TokenInfo(type=COMMENT, string="# foo", start=(1, 0), end=(1, 5), line="# foo\n",),
@@ -70,6 +71,23 @@ def test_iter_comments():
7071
]
7172
# fmt: on
7273

74+
# some patching due to differences between Python versions...
75+
for lineno, line_toks in enumerate(actual):
76+
for i, tok in enumerate(line_toks):
77+
if tok.type == NEWLINE:
78+
try:
79+
expected_tok = expected[lineno][i]
80+
if expected_tok.type == NEWLINE:
81+
expected[lineno][i] = TokenInfo(
82+
type=expected_tok.type,
83+
string=expected_tok.string,
84+
start=expected_tok.start,
85+
end=expected_tok.end,
86+
line=tok.line,
87+
)
88+
except IndexError:
89+
pass
90+
7391
assert actual == expected
7492

7593

0 commit comments

Comments
 (0)