Skip to content

Commit 6551ff5

Browse files
authored
Merge pull request #204 from netromdk/py3.12
Python 3.12 Support
2 parents 1f0f9ee + e75a639 commit 6551ff5

18 files changed

+741
-28
lines changed

.github/workflows/analyze.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
name: Analyze
22

3-
# On all pushes to branches and pull requests in general.
3+
# On all pushes to PRs or pushes to specific branches. Not on ALL pushes in general because it will
4+
# double if pushing to a PR.
45
on:
5-
push:
66
pull_request:
7+
push:
8+
branches:
9+
- 'master'
10+
- 'dev'
711

812
permissions:
913
contents: read
@@ -14,7 +18,7 @@ jobs:
1418
runs-on: ubuntu-latest
1519
strategy:
1620
matrix:
17-
python-version: ['3.11']
21+
python-version: ['3.12']
1822

1923
steps:
2024
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

.github/workflows/test.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
name: Test
22

3-
# On all pushes to branches and pull requests in general.
3+
# On all pushes to PRs or pushes to specific branches. Not on ALL pushes in general because it will
4+
# double if pushing to a PR.
45
on:
5-
push:
66
pull_request:
7+
push:
8+
branches:
9+
- 'master'
10+
- 'dev'
711

812
permissions:
913
contents: read
@@ -13,11 +17,11 @@ jobs:
1317
runs-on: ${{ matrix.os }}
1418
strategy:
1519
matrix:
16-
# Start Linux jobs last since they are fastest to start and complete, and start 3.11 first,
20+
# Start Linux jobs last since they are fastest to start and complete, and start 3.12 first,
1721
# since it pairs wiht macOS+Windows jobs, and 3.5 and 3.6 last since they only run tests and
1822
# don't use venv. 3.4 is not supported on GitHub anymore and 3.5 and 3.6 for x64 isn't
1923
# produced for ubuntu 22.04.
20-
python-version: ['3.11', '3.10', 3.7, 3.8, 3.9, 3.5, 3.6]
24+
python-version: ['3.12', '3.11', '3.10', 3.9, 3.8, 3.7, 3.6, 3.5]
2125
os: [windows-latest, macos-latest, ubuntu-latest]
2226

2327
# Choose test script depending on OS.
@@ -30,7 +34,7 @@ jobs:
3034
test_script_name: ./misc/actions/test.ps1
3135

3236
exclude:
33-
# Only test on macOS and Windows with Python 3.11.
37+
# Only test on macOS and Windows with Python 3.12.
3438
# But do test 3.5 and 3.6 on macOS because they aren't compiled for x64 on Ubuntu 22.04.
3539
# - os: macos-latest
3640
# python-version: 3.5
@@ -44,6 +48,8 @@ jobs:
4448
python-version: 3.9
4549
- os: macos-latest
4650
python-version: '3.10'
51+
- os: macos-latest
52+
python-version: '3.11'
4753

4854
- os: windows-latest
4955
python-version: 3.5
@@ -57,6 +63,8 @@ jobs:
5763
python-version: 3.9
5864
- os: windows-latest
5965
python-version: '3.10'
66+
- os: windows-latest
67+
python-version: '3.11'
6068

6169
# Ignore 3.5 and 3.6 on Linux because it isn't compiled for x64 on Ubuntu 22.04.
6270
# Test on macOS instead.

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ bytearray, ``with`` statement, asynchronous ``with`` statement, multiple context
147147
unpacking assignment, generalized unpacking, ellipsis literal (``...``) out of slices, dictionary
148148
union (``{..} | {..}``), dictionary union merge (``a = {..}; a |= {..}``), builtin generic type
149149
annotations (``list[str]``), function decorators, class decorators, relaxed decorators,
150-
``metaclass`` class keyword, pattern matching with ``match``, and union types written as ``X | Y``.
151-
It tries to detect and ignore user-defined functions, classes, arguments, and variables with names
152-
that clash with library-defined symbols.
150+
``metaclass`` class keyword, pattern matching with ``match``, union types written as ``X | Y``, and
151+
type alias statements (``type X = SomeType``). It tries to detect and ignore user-defined functions,
152+
classes, arguments, and variables with names that clash with library-defined symbols.
153153

154154
Caveats
155155
=======

misc/.analysis-requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ pyparsing==3.0.9
3838
pyproject_hooks==1.0.0
3939
pyroma==4.2
4040
python-lsp-jsonrpc==1.0.0
41-
PyYAML==6.0
41+
PyYAML==6.0.1
4242
referencing==0.29.1
4343
requests==2.31.0
4444
rich==13.4.2
4545
rpds-py==0.8.10
46-
ruamel.yaml==0.17.32
47-
ruamel.yaml.clib==0.2.7
46+
ruamel.yaml==0.17.35
47+
ruamel.yaml.clib==0.2.8
4848
semgrep==1.31.1
49+
setuptools==68.2.2
4950
six==1.16.0
5051
smmap==5.0.0
5152
stevedore==5.1.0

tests/builtin_functions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ def test_bit_count_of_int(self):
347347
self.assertOnlyIn((3, 10), self.detect("(42).bit_count()"))
348348
self.assertOnlyIn((3, 10), self.detect("n=42\nn.bit_count()"))
349349

350+
def test_is_integer_of_int(self):
351+
self.assertOnlyIn((3, 12), self.detect("(42).is_integer()"))
352+
self.assertOnlyIn((3, 12), self.detect("n=42\nn.is_integer()"))
353+
350354
def test_to_bytes_of_int(self):
351355
self.assertOnlyIn((3, 2), self.detect("(42).to_bytes()"))
352356
self.assertOnlyIn((3, 2), self.detect("n=42\nn.to_bytes()"))

tests/class.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def test_TaskGroup_of_asyncio(self):
4646
def test_Calendar_of_calendar(self):
4747
self.assertOnlyIn(((2, 5), (3, 0)), self.detect("from calendar import Calendar"))
4848

49+
def test_Day_of_calendar(self):
50+
self.assertOnlyIn((3, 12), self.detect("from calendar import Day"))
51+
4952
def test_HTMLCalendar_of_calendar(self):
5053
self.assertOnlyIn(((2, 5), (3, 0)), self.detect("from calendar import HTMLCalendar"))
5154

@@ -55,6 +58,9 @@ def test_LocaleHTMLCalendar_of_calendar(self):
5558
def test_LocaleTextCalendar_of_calendar(self):
5659
self.assertOnlyIn(((2, 5), (3, 0)), self.detect("from calendar import LocaleTextCalendar"))
5760

61+
def test_Month_of_calendar(self):
62+
self.assertOnlyIn((3, 12), self.detect("from calendar import Month"))
63+
5864
def test_TextCalendar_of_calendar(self):
5965
self.assertOnlyIn(((2, 5), (3, 0)), self.detect("from calendar import TextCalendar"))
6066

@@ -284,6 +290,9 @@ def test_AsyncIterator_of_collections_abc(self):
284290
def test_AsyncGenerator_of_collections_abc(self):
285291
self.assertOnlyIn((3, 6), self.detect("from collections.abc import AsyncGenerator"))
286292

293+
def test_Buffer_of_collections_abc(self):
294+
self.assertOnlyIn((3, 12), self.detect("from collections.abc import Buffer"))
295+
287296
def test_AbstractContextManager_of_contextlib(self):
288297
self.assertOnlyIn((3, 6), self.detect("from contextlib import AbstractContextManager"))
289298

@@ -332,6 +341,9 @@ def test_Parameter_of_inspect(self):
332341
def test_BoundArguments_of_inspect(self):
333342
self.assertOnlyIn((3, 3), self.detect("from inspect import BoundArguments"))
334343

344+
def test_BufferFlags_of_inspect(self):
345+
self.assertOnlyIn((3, 12), self.detect("from inspect import BufferFlags"))
346+
335347
def test_LoggerAdapter_of_logging(self):
336348
self.assertOnlyIn(((2, 6), (3, 0)), self.detect("from logging import LoggerAdapter"))
337349

@@ -635,6 +647,9 @@ def test_TypedDict_of_typing(self):
635647
def test_ParamSpec_of_typing(self):
636648
self.assertOnlyIn((3, 10), self.detect("from typing import ParamSpec"))
637649

650+
def test_TypeAliasType_of_typing(self):
651+
self.assertOnlyIn((3, 12), self.detect("from typing import TypeAliasType"))
652+
638653
def test_SMTP_SSL_of_smtplib(self):
639654
self.assertOnlyIn(((2, 6), (3, 0)), self.detect("from smtplib import SMTP_SSL"))
640655

tests/comment_exclusions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,3 +501,9 @@ def bar():
501501
""")
502502
self.assertIn(5, visitor.no_lines())
503503
self.assertEqual([(0, 0), (0, 0)], visitor.minimum_versions())
504+
505+
@VerminTest.skipUnlessVersion(3, 12)
506+
def test_type_alias_statement(self):
507+
visitor = self.visit("type X = int #novm")
508+
self.assertIn(1, visitor.no_lines())
509+
self.assertEqual([(0, 0), (0, 0)], visitor.minimum_versions())

0 commit comments

Comments
 (0)