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

Add additional stdlib deprecations (mostly 3.13) #134

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aea868c
Fix `invalid-name` regression for class attributes in subclasses (#97…
github-actions[bot] Jul 7, 2024
9882537
Bump astroid to 3.2.3 (#9787)
jacobtylerwalls Jul 12, 2024
8eb2c4d
Fix FP for `unexpected-keyword-arg` with ambiguous constructors (#978…
github-actions[bot] Jul 12, 2024
bd4c8f1
Handle assert_never() when imported from typing_extensions (#9782) (#…
jacobtylerwalls Jul 12, 2024
8410f57
Fix a false positive for ``missing-param-doc`` (#9740) (#9793)
github-actions[bot] Jul 15, 2024
1d877de
Fix consider-using-min-max-builtin (#9802) (#9803)
github-actions[bot] Jul 16, 2024
60bd230
Update setuptools to >=71.0.4 (#9812)
cdce8p Jul 20, 2024
c0b1d22
Bump astroid to 3.2.4 (#9816) (#9821)
jacobtylerwalls Jul 20, 2024
5f19cd5
Fix a crash when a subclass extends `__slots__` (#9817) (#9822)
jacobtylerwalls Jul 20, 2024
810c59c
Update setuptools to >=71.0.4 (#9812) (#9824)
github-actions[bot] Jul 20, 2024
d2c7fbc
Sync Sphinx version in pre-commit config (#9826)
jacobtylerwalls Jul 21, 2024
da19566
Bump pylint to 3.2.6, update changelog (#9825)
jacobtylerwalls Jul 21, 2024
70bbec0
Merge branch 'maintenance/3.2.x' into post-3.2.6
jacobtylerwalls Jul 21, 2024
2d484f5
Post 3.2.6 (#9827)
jacobtylerwalls Jul 21, 2024
42fac79
Update pytest requirement from ~=8.2 to ~=8.3 (#9828)
dependabot[bot] Jul 22, 2024
969a78b
Bump sphinx from 7.4.3 to 7.4.7 (#9830)
dependabot[bot] Jul 22, 2024
54141dc
Bump furo from 2024.5.6 to 2024.7.18 (#9829)
dependabot[bot] Jul 22, 2024
9ddb1a4
[pre-commit.ci] pre-commit autoupdate (#9831)
pre-commit-ci[bot] Jul 23, 2024
9491f93
Update repo for pylint-sonarjson
jacobtylerwalls Jul 28, 2024
9f63895
Add unsupported version checks for Python 3.8+ syntax (#9838)
jacobtylerwalls Jul 28, 2024
e64d453
Fix: [unknown-option-value] False negative after --disable=all (#9491)
fellhorn Jul 29, 2024
c25bef3
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jul 29, 2024
83ade13
Fix a false positive `unreachable` for `NoReturn` coroutine functions…
tomasz-michalski Jul 31, 2024
de6e6fa
Implement `too-many-positional-arguments` (#9842)
jacobtylerwalls Aug 2, 2024
e608e9c
Add additional stdlib deprecations (mostly 3.13)
jacobtylerwalls Aug 5, 2024
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
doc/data/messages/m/missing-final-newline/bad/crlf.py
)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.5.2"
rev: "v0.5.5"
hooks:
- id: ruff
args: ["--fix"]
Expand Down Expand Up @@ -127,9 +127,9 @@ repos:
- id: rstcheck
args: ["--report-level=warning"]
files: ^(doc/(.*/)*.*\.rst)
additional_dependencies: [Sphinx==5.0.1]
additional_dependencies: [Sphinx==7.4.3]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
rev: v1.11.0
hooks:
- id: mypy
name: mypy
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:target: https://codecov.io/gh/pylint-dev/pylint

.. image:: https://img.shields.io/pypi/v/pylint.svg
:alt: Pypi Package version
:alt: PyPI Package version
:target: https://pypi.python.org/pypi/pylint

.. image:: https://readthedocs.org/projects/pylint/badge/?version=latest
Expand Down Expand Up @@ -81,7 +81,7 @@ It can also be integrated in most editors or IDEs. More information can be found
What differentiates Pylint?
---------------------------

Pylint is not trusting your typing and is inferring the actual value of nodes (for a
Pylint is not trusting your typing and is inferring the actual values of nodes (for a
start because there was no typing when pylint started off) using its internal code
representation (astroid). If your code is ``import logging as argparse``, Pylint
can check and know that ``argparse.error(...)`` is in fact a logging call and not an
Expand Down Expand Up @@ -123,7 +123,7 @@ ecosystem of existing plugins for popular frameworks and third-party libraries.
.. _`plugins`: https://pylint.readthedocs.io/en/latest/development_guide/how_tos/plugins.html#plugins
.. _`pylint-pydantic`: https://pypi.org/project/pylint-pydantic
.. _`pylint-django`: https://github.com/pylint-dev/pylint-django
.. _`pylint-sonarjson`: https://github.com/omegacen/pylint-sonarjson
.. _`pylint-sonarjson`: https://github.com/cnescatlab/pylint-sonarjson-catlab

Advised linters alongside pylint
--------------------------------
Expand Down
5 changes: 5 additions & 0 deletions doc/data/messages/t/too-many-positional-arguments/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class FiveArgumentMethods:
"""The max positional arguments default is 5."""

def take_five_args(self, a, b, c, d, e): # [too-many-positional-arguments]
pass
10 changes: 10 additions & 0 deletions doc/data/messages/t/too-many-positional-arguments/details.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Positional arguments work well for cases where the the use cases are
self-evident, such as unittest's ``assertEqual(first, second, msg=None)``.
Comprehensibility suffers beyond a handful of arguments, though, so for
functions that take more inputs, require that additional arguments be
passed by *keyword only* by preceding them with ``*``:

.. code-block:: python

def make_noise(self, volume, *, color=noise.PINK, debug=True):
...
5 changes: 5 additions & 0 deletions doc/data/messages/t/too-many-positional-arguments/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class FiveArgumentMethods:
"""The max positional arguments default is 5."""

def take_five_args(self, a, b, c, d, *, e=False):
pass
2 changes: 2 additions & 0 deletions doc/data/messages/t/too-many-positional-arguments/pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MESSAGES CONTROL]
disable=too-many-arguments
1 change: 0 additions & 1 deletion doc/data/messages/t/too-many-positional/details.rst

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import random

# +1: [using-assignment-expression-in-unsupported-version]
if zero_or_one := random.randint(0, 1):
assert zero_or_one == 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The assignment expression (walrus) operator (`:=`) was introduced in Python 3.8; to use it, please use a more recent version of Python.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import random

zero_or_one = random.randint(0, 1)
if zero_or_one:
assert zero_or_one == 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[main]
py-version=3.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def add(x, y, /): # [using-positional-only-args-in-unsupported-version]
return x + y
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Positional-only arguments were introduced in Python 3.8; to use them, please use a more recent version of Python.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# pylint: disable=missing-function-docstring, missing-module-docstring
def add(x, y):
return x + y
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[main]
py-version=3.7
4 changes: 2 additions & 2 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Sphinx==7.4.3
Sphinx==7.4.7
sphinx-reredirects<1
towncrier~=23.11
furo==2024.5.6
furo==2024.7.18
-e .
12 changes: 8 additions & 4 deletions doc/user_guide/checkers/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,8 @@ Design checker Messages
simpler (and so easier to use) class.
:too-many-locals (R0914): *Too many local variables (%s/%s)*
Used when a function or method has too many local variables.
:too-many-positional (R0917): *Too many positional arguments in a function call.*
Will be implemented in https://github.com/pylint-
dev/pylint/issues/9099,msgid/symbol pair reserved for compatibility with
ruff, see https://github.com/astral-sh/ruff/issues/8946.
:too-many-positional-arguments (R0917): *Too many positional arguments (%s/%s)*
Used when a function has too many positional arguments.
:too-many-public-methods (R0904): *Too many public methods (%s/%s)*
Used when class has too many public methods, try to reduce this to get a
simpler (and so easier to use) class.
Expand Down Expand Up @@ -1351,6 +1349,9 @@ Verbatim name of the checker is ``unsupported_version``.

Unsupported Version checker Messages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:using-assignment-expression-in-unsupported-version (W2605): *Assignment expression is not supported by all versions included in the py-version setting*
Used when the py-version set by the user is lower than 3.8 and pylint
encounters an assignment expression (walrus) operator.
:using-exception-groups-in-unsupported-version (W2603): *Exception groups are not supported by all versions included in the py-version setting*
Used when the py-version set by the user is lower than 3.11 and pylint
encounters ``except*`` or `ExceptionGroup``.
Expand All @@ -1360,6 +1361,9 @@ Unsupported Version checker Messages
:using-generic-type-syntax-in-unsupported-version (W2604): *Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting*
Used when the py-version set by the user is lower than 3.12 and pylint
encounters generic type syntax.
:using-positional-only-args-in-unsupported-version (W2606): *Positional-only arguments are not supported by all versions included in the py-version setting*
Used when the py-version set by the user is lower than 3.8 and pylint
encounters positional-only arguments.
:using-final-decorator-in-unsupported-version (W2602): *typing.final is not supported by all versions included in the py-version setting*
Used when the py-version set by the user is lower than 3.8 and pylint
encounters a ``typing.final`` decorator.
Expand Down
9 changes: 9 additions & 0 deletions doc/user_guide/configuration/all-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,13 @@ Standard Checkers
**Default:** ``7``


--max-positional-arguments
""""""""""""""""""""""""""
*Maximum number of positional arguments for function / method.*

**Default:** ``5``


--max-public-methods
""""""""""""""""""""
*Maximum number of public methods for a class (see R0904).*
Expand Down Expand Up @@ -822,6 +829,8 @@ Standard Checkers

max-parents = 7

max-positional-arguments = 5

max-public-methods = 20

max-returns = 6
Expand Down
4 changes: 3 additions & 1 deletion doc/user_guide/messages/messages_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,13 @@ All messages in the warning category:
warning/useless-parent-delegation
warning/useless-type-doc
warning/useless-with-lock
warning/using-assignment-expression-in-unsupported-version
warning/using-constant-test
warning/using-exception-groups-in-unsupported-version
warning/using-f-string-in-unsupported-version
warning/using-final-decorator-in-unsupported-version
warning/using-generic-type-syntax-in-unsupported-version
warning/using-positional-only-args-in-unsupported-version
warning/while-used
warning/wildcard-import
warning/wrong-exception-operation
Expand Down Expand Up @@ -537,7 +539,7 @@ All messages in the refactor category:
refactor/too-many-instance-attributes
refactor/too-many-locals
refactor/too-many-nested-blocks
refactor/too-many-positional
refactor/too-many-positional-arguments
refactor/too-many-public-methods
refactor/too-many-return-statements
refactor/too-many-statements
Expand Down
45 changes: 45 additions & 0 deletions doc/whatsnew/3/3.2/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,51 @@ Summary -- Release highlights

.. towncrier release notes start

What's new in Pylint 3.2.6?
---------------------------
Release date: 2024-07-21


False Positives Fixed
---------------------

- Quiet false positives for `unexpected-keyword-arg` when pylint cannot
determine which of two or more dynamically defined classes is being instantiated.

Closes #9672 (`#9672 <https://github.com/pylint-dev/pylint/issues/9672>`_)

- Fix a false positive for ``missing-param-doc`` where a method which is decorated with ``typing.overload`` was expected to have a docstring specifying its parameters.

Closes #9739 (`#9739 <https://github.com/pylint-dev/pylint/issues/9739>`_)

- Fix a regression that raised ``invalid-name`` on class attributes merely
overriding invalid names from an ancestor.

Closes #9765 (`#9765 <https://github.com/pylint-dev/pylint/issues/9765>`_)

- Treat `assert_never()` the same way when imported from `typing_extensions`.

Closes #9780 (`#9780 <https://github.com/pylint-dev/pylint/issues/9780>`_)

- Fix a false positive for `consider-using-min-max-builtin` when the assignment target is an attribute.

Refs #9800 (`#9800 <https://github.com/pylint-dev/pylint/issues/9800>`_)



Other Bug Fixes
---------------

- Fix an `AssertionError` arising from properties that return partial functions.

Closes #9214 (`#9214 <https://github.com/pylint-dev/pylint/issues/9214>`_)

- Fix a crash when a subclass extends ``__slots__``.

Closes #9814 (`#9814 <https://github.com/pylint-dev/pylint/issues/9814>`_)



What's new in Pylint 3.2.5?
---------------------------
Release date: 2024-06-28
Expand Down
8 changes: 8 additions & 0 deletions doc/whatsnew/fragments/9099.new_check
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Added `too-many-positional-arguments` to allow distinguishing the configuration for too many
total arguments (with keyword-only params specified after `*`) from the configuration
for too many positional-or-keyword or positional-only arguments.

As part of evaluating whether this check makes sense for your project, ensure you
adjust the value of `--max-positional-arguments`.

Closes #9099
3 changes: 0 additions & 3 deletions doc/whatsnew/fragments/9214.bugfix

This file was deleted.

3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/9403.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
`--enable` with `--disable=all` now produces an error, when an unknown msg code is used. Internal `pylint` messages are no longer affected by `--disable=all`.

Closes #9403
4 changes: 0 additions & 4 deletions doc/whatsnew/fragments/9672.false_positive

This file was deleted.

3 changes: 0 additions & 3 deletions doc/whatsnew/fragments/9739.false_positive

This file was deleted.

4 changes: 0 additions & 4 deletions doc/whatsnew/fragments/9765.false_positive

This file was deleted.

3 changes: 0 additions & 3 deletions doc/whatsnew/fragments/9780.false_positive

This file was deleted.

3 changes: 0 additions & 3 deletions doc/whatsnew/fragments/9800.false_negative

This file was deleted.

3 changes: 0 additions & 3 deletions doc/whatsnew/fragments/9814.bugfix

This file was deleted.

4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/9820.new_check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add `using-assignment-expression-in-unsupported-version` for uses of `:=` (walrus operator)
on Python versions below 3.8 provided with `--py-version`.

Closes #9820
4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/9823.new_check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add `using-positional-only-args-in-unsupported-version` for uses of positional-only args on
Python versions below 3.8 provided with `--py-version`.

Closes #9823
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/9840.false_positive
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed a false positive `unreachable` for `NoReturn` coroutine functions.

Closes #9840.
2 changes: 2 additions & 0 deletions examples/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=2

# Minimum number of public methods for a class (see R0903).
max-positional-arguments=5

[EXCEPTIONS]

Expand Down
3 changes: 3 additions & 0 deletions examples/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ max-statements = 50
# Minimum number of public methods for a class (see R0903).
min-public-methods = 2

# Maximum number of positional arguments (see R0917).
max-positional-arguments = 5

[tool.pylint.exceptions]
# Exceptions that will emit a warning when caught.
overgeneral-exceptions = ["builtins.BaseException", "builtins.Exception"]
Expand Down
Loading