Skip to content

Commit

Permalink
Merge pull request #204 from netromdk/py3.12
Browse files Browse the repository at this point in the history
Python 3.12 Support
  • Loading branch information
netromdk committed Nov 24, 2023
2 parents 1f0f9ee + e75a639 commit 6551ff5
Show file tree
Hide file tree
Showing 18 changed files with 741 additions and 28 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: Analyze

# On all pushes to branches and pull requests in general.
# On all pushes to PRs or pushes to specific branches. Not on ALL pushes in general because it will
# double if pushing to a PR.
on:
push:
pull_request:
push:
branches:
- 'master'
- 'dev'

permissions:
contents: read
Expand All @@ -14,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
python-version: ['3.12']

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: Test

# On all pushes to branches and pull requests in general.
# On all pushes to PRs or pushes to specific branches. Not on ALL pushes in general because it will
# double if pushing to a PR.
on:
push:
pull_request:
push:
branches:
- 'master'
- 'dev'

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

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

exclude:
# Only test on macOS and Windows with Python 3.11.
# Only test on macOS and Windows with Python 3.12.
# But do test 3.5 and 3.6 on macOS because they aren't compiled for x64 on Ubuntu 22.04.
# - os: macos-latest
# python-version: 3.5
Expand All @@ -44,6 +48,8 @@ jobs:
python-version: 3.9
- os: macos-latest
python-version: '3.10'
- os: macos-latest
python-version: '3.11'

- os: windows-latest
python-version: 3.5
Expand All @@ -57,6 +63,8 @@ jobs:
python-version: 3.9
- os: windows-latest
python-version: '3.10'
- os: windows-latest
python-version: '3.11'

# Ignore 3.5 and 3.6 on Linux because it isn't compiled for x64 on Ubuntu 22.04.
# Test on macOS instead.
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ bytearray, ``with`` statement, asynchronous ``with`` statement, multiple context
unpacking assignment, generalized unpacking, ellipsis literal (``...``) out of slices, dictionary
union (``{..} | {..}``), dictionary union merge (``a = {..}; a |= {..}``), builtin generic type
annotations (``list[str]``), function decorators, class decorators, relaxed decorators,
``metaclass`` class keyword, pattern matching with ``match``, and union types written as ``X | Y``.
It tries to detect and ignore user-defined functions, classes, arguments, and variables with names
that clash with library-defined symbols.
``metaclass`` class keyword, pattern matching with ``match``, union types written as ``X | Y``, and
type alias statements (``type X = SomeType``). It tries to detect and ignore user-defined functions,
classes, arguments, and variables with names that clash with library-defined symbols.

Caveats
=======
Expand Down
7 changes: 4 additions & 3 deletions misc/.analysis-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ pyparsing==3.0.9
pyproject_hooks==1.0.0
pyroma==4.2
python-lsp-jsonrpc==1.0.0
PyYAML==6.0
PyYAML==6.0.1
referencing==0.29.1
requests==2.31.0
rich==13.4.2
rpds-py==0.8.10
ruamel.yaml==0.17.32
ruamel.yaml.clib==0.2.7
ruamel.yaml==0.17.35
ruamel.yaml.clib==0.2.8
semgrep==1.31.1
setuptools==68.2.2
six==1.16.0
smmap==5.0.0
stevedore==5.1.0
Expand Down
4 changes: 4 additions & 0 deletions tests/builtin_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ def test_bit_count_of_int(self):
self.assertOnlyIn((3, 10), self.detect("(42).bit_count()"))
self.assertOnlyIn((3, 10), self.detect("n=42\nn.bit_count()"))

def test_is_integer_of_int(self):
self.assertOnlyIn((3, 12), self.detect("(42).is_integer()"))
self.assertOnlyIn((3, 12), self.detect("n=42\nn.is_integer()"))

def test_to_bytes_of_int(self):
self.assertOnlyIn((3, 2), self.detect("(42).to_bytes()"))
self.assertOnlyIn((3, 2), self.detect("n=42\nn.to_bytes()"))
Expand Down
15 changes: 15 additions & 0 deletions tests/class.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def test_TaskGroup_of_asyncio(self):
def test_Calendar_of_calendar(self):
self.assertOnlyIn(((2, 5), (3, 0)), self.detect("from calendar import Calendar"))

def test_Day_of_calendar(self):
self.assertOnlyIn((3, 12), self.detect("from calendar import Day"))

def test_HTMLCalendar_of_calendar(self):
self.assertOnlyIn(((2, 5), (3, 0)), self.detect("from calendar import HTMLCalendar"))

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

def test_Month_of_calendar(self):
self.assertOnlyIn((3, 12), self.detect("from calendar import Month"))

def test_TextCalendar_of_calendar(self):
self.assertOnlyIn(((2, 5), (3, 0)), self.detect("from calendar import TextCalendar"))

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

def test_Buffer_of_collections_abc(self):
self.assertOnlyIn((3, 12), self.detect("from collections.abc import Buffer"))

def test_AbstractContextManager_of_contextlib(self):
self.assertOnlyIn((3, 6), self.detect("from contextlib import AbstractContextManager"))

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

def test_BufferFlags_of_inspect(self):
self.assertOnlyIn((3, 12), self.detect("from inspect import BufferFlags"))

def test_LoggerAdapter_of_logging(self):
self.assertOnlyIn(((2, 6), (3, 0)), self.detect("from logging import LoggerAdapter"))

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

def test_TypeAliasType_of_typing(self):
self.assertOnlyIn((3, 12), self.detect("from typing import TypeAliasType"))

def test_SMTP_SSL_of_smtplib(self):
self.assertOnlyIn(((2, 6), (3, 0)), self.detect("from smtplib import SMTP_SSL"))

Expand Down
6 changes: 6 additions & 0 deletions tests/comment_exclusions.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,9 @@ def bar():
""")
self.assertIn(5, visitor.no_lines())
self.assertEqual([(0, 0), (0, 0)], visitor.minimum_versions())

@VerminTest.skipUnlessVersion(3, 12)
def test_type_alias_statement(self):
visitor = self.visit("type X = int #novm")
self.assertIn(1, visitor.no_lines())
self.assertEqual([(0, 0), (0, 0)], visitor.minimum_versions())

0 comments on commit 6551ff5

Please sign in to comment.