Skip to content
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

[ci] Add jobs for python 3.12-beta following its release #8718

Merged
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7e2ab19
[ci] Add jobs for python 3.12-beta following its release
Pierre-Sassoulas May 26, 2023
5c474e3
Increase setuptools version above 66.1 see https://github.com/pypa/pi…
Pierre-Sassoulas Jun 7, 2023
28eb972
Do not upgrade the primer's upper bound yet
Pierre-Sassoulas Jun 7, 2023
42c18cd
Remove fragment, update doc
Pierre-Sassoulas Jun 7, 2023
39e8c4c
Restore news fragment
jacobtylerwalls Jul 10, 2023
98ad7db
Add python 3.12 classifier
jacobtylerwalls Jul 10, 2023
ee27fde
Apply dill patch for DeprecationWarnings on 3.12
jacobtylerwalls Jul 14, 2023
fd1f69d
Reflect better TokenError linenos in python 3.12
jacobtylerwalls Jul 14, 2023
20207a0
Simulate legacy editable_mode=compat
jacobtylerwalls Jul 14, 2023
bdde25a
Cope with DeprecationWarnings becoming SyntaxWarnings
jacobtylerwalls Jul 14, 2023
445e897
Rotate the deprecated module used in test
jacobtylerwalls Jul 14, 2023
fc9f69b
Add max_pyver
jacobtylerwalls Jul 14, 2023
f1560cf
Adapt unhashable-member tests for slices as dict keys
jacobtylerwalls Jul 14, 2023
dfc4df2
TypeAlias became a class in python 3.12
jacobtylerwalls Jul 14, 2023
b70c4bc
typing.Generic no longer has slots
jacobtylerwalls Jul 14, 2023
839fdda
Update news fragment
jacobtylerwalls Jul 14, 2023
0c68458
distutils was removed in 3.12
jacobtylerwalls Jul 15, 2023
a5a525c
Skip enum.__getattr__ test on Python 3.12 for now
jacobtylerwalls Jul 15, 2023
158f3a9
Remove double colon in fragment
jacobtylerwalls Jul 15, 2023
b7592e6
Bump astroid to 3.0.0a8
jacobtylerwalls Jul 15, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/primer-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
timeout-minutes: 5
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12-dev"]
outputs:
python-key: ${{ steps.generate-python-key.outputs.key }}
steps:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
needs: prepare-tests-linux
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12-dev"]
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12-dev"]
outputs:
python-key: ${{ steps.generate-python-key.outputs.key }}
steps:
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12-dev"]
steps:
- name: Set temp directory
run: echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
Expand Down
12 changes: 8 additions & 4 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ contributors:
- Tushar Sadhwani <[email protected]> (tusharsadhwani)
- Nicolas Chauvat <[email protected]>
- orSolocate <[email protected]>
- Zen Lee <[email protected]>
- Radu Ciorba <[email protected]>: not-context-manager and confusing-with-statement warnings.
- Holger Peters <[email protected]>
- Cosmin Poieană <[email protected]>: unichr-builtin and improvements to bad-open-mode.
- Zen Lee <[email protected]>
- Steven Myint <[email protected]>: duplicate-except.
- Peter Kolbus <[email protected]> (Garmin)
- Luigi Bertaco Cristofolini <[email protected]> (luigibertaco)
Expand All @@ -118,16 +118,17 @@ contributors:
- Julien Jehannet <[email protected]>
- Boris Feld <[email protected]>
- Anthony Sottile <[email protected]>
- Robert Hofer <[email protected]>
- Pedro Algarvio <[email protected]> (s0undt3ch)
- Julien Palard <[email protected]>
- David Liu <[email protected]> (david-yz-liu)
- Dan Goldsmith <[email protected]>: support for msg-template in HTML reporter.
- Buck Evan <[email protected]>
- Robert Hofer <[email protected]>
- Mariatta Wijaya <[email protected]>
* Added new check `logging-fstring-interpolation`
* Documentation typo fixes
- Jakub Wilk <[email protected]>
- Hugo van Kemenade <[email protected]>
- Eli Fine <[email protected]> (eli88fine): Fixed false positive duplicate code warning for lines with symbols only
- Andrew Haigh <[email protected]> (nelfin)
- Émile Crater <[email protected]>
Expand All @@ -138,10 +139,10 @@ contributors:
- Marianna Polatoglou <[email protected]>: minor contribution for wildcard import check
- Manuel Vázquez Acosta <[email protected]>
- Luis Escobar <[email protected]> (Vauxoo): Add bad-docstring-quotes and docstring-first-line-empty
- Lucas Cimon <[email protected]>
- Konstantina Saketou <[email protected]>
- Konstantin <[email protected]>
- Jim Robertson <[email protected]>
- Hugo van Kemenade <[email protected]>
- Ethan Leba <[email protected]>
- Enji Cooper <[email protected]>
- Drum Ogilvie <[email protected]>
Expand Down Expand Up @@ -219,7 +220,6 @@ contributors:
* Fixed ignored empty functions by similarities checker with "ignore-signatures" option enabled
* Ignore function decorators signatures as well by similarities checker with "ignore-signatures" option enabled
* Ignore class methods and nested functions signatures as well by similarities checker with "ignore-signatures" option enabled
- Lucas Cimon <[email protected]>
- Kylian <[email protected]>
- Konstantin Manna <[email protected]>
- Kai Mueller <[email protected]>
Expand Down Expand Up @@ -363,6 +363,7 @@ contributors:
- Viorel Știrbu <[email protected]>: intern-builtin warning.
- VictorT <[email protected]>
- Victor Jiajunsu <[email protected]>
- ViRuSTriNiTy <[email protected]>
- Trevor Bekolay <[email protected]>
* Added --list-msgs-enabled command
- Tomer Chachamu <[email protected]>: simplifiable-if-expression
Expand Down Expand Up @@ -428,6 +429,7 @@ contributors:
- Moody <[email protected]>
- Mitchell Young <[email protected]>: minor adjustment to docparams
- Mitar <[email protected]>
- Mikhail f. Shiryaev <[email protected]>
- Mike Fiedler <[email protected]> (miketheman)
- Mike Bryant <[email protected]>
- Michka Popoff <[email protected]>
Expand Down Expand Up @@ -476,6 +478,7 @@ contributors:
* Fixed `toml` dependency issue
- Jeremy Fleischman <[email protected]>
- Jason Owen <[email protected]>
- Jason Lau <[email protected]>
- Jared Garst <[email protected]>
- Jared Deckard <[email protected]>
- Janne Rönkkö <[email protected]>
Expand Down Expand Up @@ -553,6 +556,7 @@ contributors:
- Arun Persaud <[email protected]>
- Arthur Lutz <[email protected]>
- Antonio Ossa <[email protected]>
- Antonio <[email protected]>
- Anthony VEREZ <[email protected]>
- Anthony Tan <[email protected]>
- Anthony Foglia <[email protected]> (Google): Added simple string slots check.
Expand Down
3 changes: 3 additions & 0 deletions doc/user_guide/checkers/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ Basic checker Messages
Used when a break or a return statement is found inside the finally clause of
a try...finally block: the exceptions raised in the try clause will be
silently swallowed instead of being re-raised.
:return-in-finally (W0134): *'return' shadowed by the 'finally' clause.*
Emitted when a 'return' statement is found in a 'finally' block. This will
overwrite the return value of a function and should be avoided.
:assert-on-tuple (W0199): *Assert called on a populated tuple. Did you mean 'assert x,y'?*
A call of assert on a tuple will always evaluate to true if the tuple is not
empty, and will always evaluate to false if it is.
Expand Down
1 change: 1 addition & 0 deletions doc/user_guide/messages/messages_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ All messages in the warning category:
warning/redundant-unittest-assert
warning/redundant-yields-doc
warning/reimported
warning/return-in-finally
warning/self-assigning-variable
warning/self-cls-assignment
warning/shadowed-import
Expand Down
2 changes: 1 addition & 1 deletion doc/whatsnew/fragments/8416.breaking
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
``pyreverse``: Support for the ``.vcg`` output format (Visualaization of Compiler Graphs) has been dropped.
``pyreverse``: Support for the ``.vcg`` output format (Visualization of Compiler Graphs) has been dropped.

Closes #8416
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/8718.other
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Pylint now supports python 3.12.

Refs #8718
7 changes: 6 additions & 1 deletion pylint/checkers/base/name_checker/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,17 @@ def _assigns_typealias(node: nodes.NodeNG | None) -> bool:
"""Check if a node is assigning a TypeAlias."""
inferred = utils.safe_infer(node)
if isinstance(inferred, nodes.ClassDef):
if inferred.qname() == ".Union":
qname = inferred.qname()
if qname == "typing.TypeAlias":
return True
if qname == ".Union":
# Union is a special case because it can be used as a type alias
# or as a type annotation. We only want to check the former.
assert node is not None
return not isinstance(node.parent, nodes.AnnAssign)
elif isinstance(inferred, nodes.FunctionDef):
# TODO: when py3.12 is minimum, remove this condition
# TypeAlias became a class in python 3.12
if inferred.qname() == "typing.TypeAlias":
return True
return False
Expand Down
3 changes: 2 additions & 1 deletion pylint/checkers/classes/class_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,8 @@ def _check_in_slots(self, node: nodes.AssignAttr) -> None:
# If any ancestor doesn't use slots, the slots
# defined for this class are superfluous.
if any(
"__slots__" not in ancestor.locals and ancestor.name != "object"
"__slots__" not in ancestor.locals
and ancestor.name not in ("Generic", "object")
for ancestor in klass.ancestors()
):
return
Expand Down
1 change: 1 addition & 0 deletions pylint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
PY38_PLUS = sys.version_info[:2] >= (3, 8)
PY39_PLUS = sys.version_info[:2] >= (3, 9)
PY310_PLUS = sys.version_info[:2] >= (3, 10)
PY312_PLUS = sys.version_info[:2] >= (3, 12)

IS_PYPY = platform.python_implementation() == "PyPy"

Expand Down
8 changes: 7 additions & 1 deletion pylint/lint/pylinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,13 @@ def _check_astroid_module(
try:
tokens = utils.tokenize_module(node)
except tokenize.TokenError as ex:
self.add_message("syntax-error", line=ex.args[1][0], args=ex.args[0])
self.add_message(
"syntax-error",
line=ex.args[1][0],
col_offset=ex.args[1][1],
args=ex.args[0],
confidence=HIGH,
)
return None

if not node.pure_python:
Expand Down
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools~=62.6", "wheel~=0.37.1"]
requires = ["setuptools~=66.1", "wheel~=0.37.1"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -24,6 +24,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Debuggers",
Expand All @@ -35,6 +36,7 @@ requires-python = ">=3.8.0"
dependencies = [
"dill>=0.2;python_version<'3.11'",
"dill>=0.3.6;python_version>='3.11'",
"dill @ git+https://github.com/uqfoundation/dill.git@83ab36ce3e8cfcc0224aa99d5249a5e8f1c22590 ; python_version>='3.12'",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slowly becoming very ugly :(

"platformdirs>=2.2.0",
# Also upgrade requirements_test_min.txt.
# Pinned to dev of second minor update to allow editable installs and fix primer issues,
Expand Down Expand Up @@ -74,6 +76,13 @@ license-files = ["LICENSE", "CONTRIBUTORS.txt"] # Keep in sync with setup.cfg
[tool.setuptools.packages.find]
include = ["pylint*"]

[tool.setuptools.package-dir]
# Simulate editable_mode=compat, described at:
# https://github.com/pypa/setuptools/issues/3767
# TODO: remove after solving root cause described at:
# https://github.com/pylint-dev/pylint/issues/8854
"" = "."

[tool.setuptools.package-data]
pylint = ["testutils/testing_pylintrc", "py.typed"]

Expand Down
1 change: 1 addition & 0 deletions tests/functional/d/deprecated/deprecated_module_py310.rc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[testoptions]
min_pyver = 3.10
max_pyver = 3.12
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""This deprecated stdlib module is redundantly given by the user in the config."""
# pylint: disable-next=unused-import
import imp # [deprecated-module]
import optparse # [deprecated-module]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[Imports]
deprecated-modules=imp
deprecated-modules=optparse
Original file line number Diff line number Diff line change
@@ -1 +1 @@
deprecated-module:3:0:3:10::Deprecated module 'imp':UNDEFINED
deprecated-module:3:0:3:15::Deprecated module 'optparse':UNDEFINED
3 changes: 3 additions & 0 deletions tests/functional/e/enum_self_defined_member_5138.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[testoptions]
# https://github.com/python/cpython/issues/106762
max_pyver=3.12
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
max_pyver=3.12
4 changes: 1 addition & 3 deletions tests/functional/t/tokenize_error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""A module that is accepted by Python but rejected by tokenize.

The problem is the trailing line continuation at the end of the line,
"""The problem is the trailing line continuation at the end of the line,
which produces a TokenError."""
# +2: [syntax-error]
""\
1 change: 1 addition & 0 deletions tests/functional/t/tokenize_error.rc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
[testoptions]
max_pyver=3.12
2 changes: 1 addition & 1 deletion tests/functional/t/tokenize_error.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
syntax-error:7:0:None:None::EOF in multi-line statement:UNDEFINED
syntax-error:5:0:None:None::EOF in multi-line statement:HIGH
4 changes: 4 additions & 0 deletions tests/functional/t/tokenize_error_py312.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""The problem is the trailing line continuation at the end of the line,
which produces a TokenError."""
# +1: [syntax-error]
""\
2 changes: 2 additions & 0 deletions tests/functional/t/tokenize_error_py312.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
min_pyver=3.12
1 change: 1 addition & 0 deletions tests/functional/t/tokenize_error_py312.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
syntax-error:4:4:None:None::unexpected EOF in multi-line statement:HIGH
1 change: 0 additions & 1 deletion tests/functional/u/unhashable_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Unhashable:
{}[[1, 2, 3]] # [unhashable-member]
{}[{}] # [unhashable-member]
{}[Unhashable()] # [unhashable-member]
{}[1:2] # [unhashable-member]
{'foo': 'bar'}['foo']
{'foo': 'bar'}[42]

Expand Down
9 changes: 4 additions & 5 deletions tests/functional/u/unhashable_member.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
unhashable-member:8:0:8:2::'[1, 2, 3]' is unhashable and can't be used as a key in a dict:INFERENCE
unhashable-member:9:0:9:2::'{}' is unhashable and can't be used as a key in a dict:INFERENCE
unhashable-member:10:0:10:2::'Unhashable()' is unhashable and can't be used as a key in a dict:INFERENCE
unhashable-member:11:0:11:2::"'1:2' is unhashable and can't be used as a key in a dict":INFERENCE
unhashable-member:16:1:16:10::'[1, 2, 3]' is unhashable and can't be used as a key in a dict:INFERENCE
unhashable-member:18:4:18:13::'[1, 2, 3]' is unhashable and can't be used as a key in a dict:INFERENCE
unhashable-member:19:4:19:13::'[4, 5, 6]' is unhashable and can't be used as a key in a dict:INFERENCE
unhashable-member:21:1:21:10::'[1, 2, 3]' is unhashable and can't be used as a member in a set:INFERENCE
unhashable-member:15:1:15:10::'[1, 2, 3]' is unhashable and can't be used as a key in a dict:INFERENCE
unhashable-member:17:4:17:13::'[1, 2, 3]' is unhashable and can't be used as a key in a dict:INFERENCE
unhashable-member:18:4:18:13::'[4, 5, 6]' is unhashable and can't be used as a key in a dict:INFERENCE
unhashable-member:20:1:20:10::'[1, 2, 3]' is unhashable and can't be used as a member in a set:INFERENCE
2 changes: 2 additions & 0 deletions tests/functional/u/unhashable_member_py312.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""slices can be used as dict keys from python 3.12"""
var = {}[1:2]
2 changes: 2 additions & 0 deletions tests/functional/u/unhashable_member_py312.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
min_pyver = 3.12
4 changes: 3 additions & 1 deletion tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from _pytest.config import Config

from pylint import testutils
from pylint.constants import PY312_PLUS
from pylint.testutils import UPDATE_FILE, UPDATE_OPTION
from pylint.testutils.functional import (
FunctionalTestFile,
Expand Down Expand Up @@ -50,7 +51,8 @@ def test_functional(test_file: FunctionalTestFile, pytestconfig: Config) -> None
lint_test.setUp()

if test_file.base in TEST_WITH_EXPECTED_DEPRECATION:
with pytest.warns(DeprecationWarning, match="invalid escape sequence"):
exception_type = SyntaxWarning if PY312_PLUS else DeprecationWarning
with pytest.warns(exception_type, match="invalid escape sequence"):
lint_test.runTest()
else:
lint_test.runTest()
Expand Down
Loading