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 all 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/checkout@v3.5.3
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 <tushar.sadhwani000@gmail.com> (tusharsadhwani)
- Nicolas Chauvat <nicolas.chauvat@logilab.fr>
- orSolocate <38433858+orSolocate@users.noreply.github.com>
- Zen Lee <53538590+zenlyj@users.noreply.github.com>
- Radu Ciorba <radu@devrandom.ro>: not-context-manager and confusing-with-statement warnings.
- Holger Peters <email@holger-peters.de>
- Cosmin Poieană <cmin@ropython.org>: unichr-builtin and improvements to bad-open-mode.
- Zen Lee <53538590+zenlyj@users.noreply.github.com>
- Steven Myint <hg@stevenmyint.com>: duplicate-except.
- Peter Kolbus <peter.kolbus@gmail.com> (Garmin)
- Luigi Bertaco Cristofolini <lucristofolini@gmail.com> (luigibertaco)
Expand All @@ -118,16 +118,17 @@ contributors:
- Julien Jehannet <julien.jehannet@logilab.fr>
- Boris Feld <lothiraldan@gmail.com>
- Anthony Sottile <asottile@umich.edu>
- Robert Hofer <hofrob@protonmail.com>
- Pedro Algarvio <pedro@algarvio.me> (s0undt3ch)
- Julien Palard <julien@palard.fr>
- David Liu <david@cs.toronto.edu> (david-yz-liu)
- Dan Goldsmith <djgoldsmith@googlemail.com>: support for msg-template in HTML reporter.
- Buck Evan <buck.2019@gmail.com>
- Robert Hofer <hofrob@protonmail.com>
- Mariatta Wijaya <Mariatta@users.noreply.github.com>
* Added new check `logging-fstring-interpolation`
* Documentation typo fixes
- Jakub Wilk <jwilk@jwilk.net>
- Hugo van Kemenade <hugovk@users.noreply.github.com>
- Eli Fine <ejfine@gmail.com> (eli88fine): Fixed false positive duplicate code warning for lines with symbols only
- Andrew Haigh <nelfin@gmail.com> (nelfin)
- Émile Crater <emile@crater.logilab.fr>
Expand All @@ -138,10 +139,10 @@ contributors:
- Marianna Polatoglou <mpolatoglou@bloomberg.net>: minor contribution for wildcard import check
- Manuel Vázquez Acosta <mva.led@gmail.com>
- Luis Escobar <lescobar@vauxoo.com> (Vauxoo): Add bad-docstring-quotes and docstring-first-line-empty
- Lucas Cimon <lucas.cimon@gmail.com>
- Konstantina Saketou <56515303+ksaketou@users.noreply.github.com>
- Konstantin <Github@pheanex.de>
- Jim Robertson <jrobertson98atx@gmail.com>
- Hugo van Kemenade <hugovk@users.noreply.github.com>
- Ethan Leba <ethanleba5@gmail.com>
- Enji Cooper <yaneurabeya@gmail.com>
- Drum Ogilvie <me@daogilvie.com>
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 <lucas.cimon@gmail.com>
- Kylian <development@goudcode.nl>
- Konstantin Manna <Konstantin@Manna.uno>
- Kai Mueller <15907922+kasium@users.noreply.github.com>
Expand Down Expand Up @@ -363,6 +363,7 @@ contributors:
- Viorel Știrbu <viorels@gmail.com>: intern-builtin warning.
- VictorT <victor.taix@gmail.com>
- Victor Jiajunsu <16359131+jiajunsu@users.noreply.github.com>
- ViRuSTriNiTy <cradle-of-mail@gmx.de>
- Trevor Bekolay <tbekolay@gmail.com>
* Added --list-msgs-enabled command
- Tomer Chachamu <tomer.chachamu@gmail.com>: simplifiable-if-expression
Expand Down Expand Up @@ -428,6 +429,7 @@ contributors:
- Moody <mooodyhunter@outlook.com>
- Mitchell Young <mitchelly@gmail.com>: minor adjustment to docparams
- Mitar <mitar.github@tnode.com>
- Mikhail f. Shiryaev <mr.felixoid@gmail.com>
- Mike Fiedler <miketheman@gmail.com> (miketheman)
- Mike Bryant <leachim@leachim.info>
- Michka Popoff <michkapopoff@gmail.com>
Expand Down Expand Up @@ -476,6 +478,7 @@ contributors:
* Fixed `toml` dependency issue
- Jeremy Fleischman <jeremyfleischman@gmail.com>
- Jason Owen <jason.a.owen@gmail.com>
- Jason Lau <github.com@dotkr.nl>
- Jared Garst <cultofjared@gmail.com>
- Jared Deckard <jared.deckard@gmail.com>
- Janne Rönkkö <jannero@users.noreply.github.com>
Expand Down Expand Up @@ -553,6 +556,7 @@ contributors:
- Arun Persaud <arun@nubati.net>
- Arthur Lutz <arthur.lutz@logilab.fr>
- Antonio Ossa <aaossa@uc.cl>
- Antonio <antonioglez-23@hotmail.com>
- Anthony VEREZ <anthony.verez.external@cassidian.com>
- Anthony Tan <tanant@users.noreply.github.com>
- Anthony Foglia <afoglia@users.noreply.github.com> (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/3696.breaking
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Enabling or disabling individual messages will now take effect even if an
``--enable=all`` or ``disable=all`` follows in the same configuration file
(or on the command line).

This means for the following example, ``fixme`` messages will now be emitted::
This means for the following example, ``fixme`` messages will now be emitted:

.. code-block::

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
13 changes: 11 additions & 2 deletions 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,11 +36,12 @@ 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,
# see https://github.com/pylint-dev/astroid/issues/1341
"astroid>=3.0.0a7,<=3.1.0-dev0",
"astroid>=3.0.0a8,<=3.1.0-dev0",
"isort>=4.2.5,<6",
"mccabe>=0.6,<0.8",
"tomli>=1.1.0;python_version<'3.11'",
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
2 changes: 1 addition & 1 deletion requirements_test_min.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-e .[testutils,spelling]
# astroid dependency is also defined in pyproject.toml
astroid==3.0.0a7 # Pinned to a specific version for tests
astroid==3.0.0a8 # Pinned to a specific version for tests
typing-extensions~=4.7
py~=1.11.0
pytest~=7.4
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