Skip to content

Commit 963b16d

Browse files
Merge branch 'main' into tests
2 parents b9b43dc + 5e9d20d commit 963b16d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+427
-83
lines changed

.github/workflows/ci.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
env:
1111
CACHE_VERSION: 3
12-
DEFAULT_PYTHON: 3.6
12+
DEFAULT_PYTHON: 3.8
1313
PRE_COMMIT_CACHE: ~/.cache/pre-commit
1414

1515
jobs:
@@ -509,3 +509,37 @@ jobs:
509509
. venv/bin/activate
510510
pip install -e .
511511
pytest -m primer_stdlib -n auto
512+
513+
pytest-primer-external:
514+
name: Run primer tests on external libs Python ${{ matrix.python-version }} (Linux)
515+
runs-on: ubuntu-latest
516+
needs: prepare-tests-linux
517+
strategy:
518+
matrix:
519+
python-version: [3.8, 3.9, "3.10"]
520+
steps:
521+
- name: Check out code from GitHub
522+
uses: actions/checkout@v2.3.5
523+
- name: Set up Python ${{ matrix.python-version }}
524+
id: python
525+
uses: actions/setup-python@v2.2.2
526+
with:
527+
python-version: ${{ matrix.python-version }}
528+
- name: Restore Python virtual environment
529+
id: cache-venv
530+
uses: actions/cache@v2.1.6
531+
with:
532+
path: venv
533+
key:
534+
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
535+
needs.prepare-tests-linux.outputs.python-key }}
536+
- name: Fail job if Python cache restore failed
537+
if: steps.cache-venv.outputs.cache-hit != 'true'
538+
run: |
539+
echo "Failed to restore Python venv from cache"
540+
exit 1
541+
- name: Run pytest
542+
run: |
543+
. venv/bin/activate
544+
pip install -e .
545+
pytest -m primer_external -n auto

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ build-stamp
2020
.pytest_cache/
2121
.mypy_cache/
2222
.benchmarks/
23+
.pylint_primer_tests/

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ repos:
5757
"-rn",
5858
"-sn",
5959
"--rcfile=pylintrc",
60+
"--fail-on=I",
6061
"--load-plugins=pylint.extensions.docparams",
6162
]
6263
# disabled plugins: pylint.extensions.mccabe

ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ Release date: TBA
1515

1616
Closes #4982
1717

18+
* Introduced primer tests and a configuration tests framework. The helper classes available in
19+
``pylint/testutil/`` are still unstable and might be modified in the near future.
20+
21+
Closes #4412 #5287
22+
1823
* Fix ``install graphiz`` message which isn't needed for puml output format.
1924

25+
* Fix a crash in the ``check_elif`` extensions where an undetected if in a comprehension
26+
with an if statement within a f-string resulted in an out of range error. The checker no
27+
longer relies on counting if statements anymore and uses known if statements locations instead.
28+
It should not crash on badly parsed if statements anymore.
29+
2030
* Fix ``simplify-boolean-expression`` when condition can be inferred as False.
2131

2232
Closes #5200
@@ -284,6 +294,12 @@ Release date: TBA
284294
Closes #3507
285295
Closes #5087
286296

297+
* It is now recommended to do ``pylint`` development on ``Python`` 3.8 or higher. This
298+
allows using the latest ``ast`` parser.
299+
300+
* All standard jobs in the ``pylint`` CI now run on ``Python`` 3.8 by default. We still
301+
support python 3.6 and 3.7 and run tests for those interpreters.
302+
287303
* ``TypingChecker``
288304

289305
* Fix false-negative for ``deprecated-typing-alias`` and ``consider-using-alias``

doc/development_guide/contribute.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ You can clone Pylint and its dependencies from ::
6464
.. _git: https://git-scm.com/
6565

6666
Got a change for Pylint? Below are a few steps you should take to make sure
67-
your patch gets accepted.
67+
your patch gets accepted. We recommend using Python 3.8 or higher for development
68+
of Pylint as it gives you access to the latest ``ast`` parser.
6869

6970
- Test your code
7071

doc/whatsnew/2.12.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ New checkers
3535

3636
* Fix ``useless-super-delegation`` false positive when default keyword argument is a variable.
3737

38-
* Added new checker `use-implicit-booleanness``: Emitted when using collection
38+
* Added new checker ``use-implicit-booleanness``: Emitted when using collection
3939
literals for boolean comparisons
4040

4141
* Added new checker ``use-implicit-booleaness-not-comparison``: Emitted when
@@ -204,6 +204,17 @@ Other Changes
204204
* Added the ``--enable-all-extensions`` command line option. It will load all available extensions
205205
which can be listed by running ``--list-extensions``
206206

207+
* It is now recommended to do ``pylint`` development on ``Python`` 3.8 or higher. This
208+
allows using the latest ``ast`` parser.
209+
210+
* All standard jobs in the ``pylint`` CI now run on ``Python`` 3.8 by default. We still
211+
support python 3.6 and 3.7 and run tests for those interpreters.
212+
207213
* Fix crash on ``open()`` calls when the ``mode`` argument is not a simple string.
208214

209215
Partially closes #5321
216+
217+
* Introduced primer tests and a configuration tests framework. The helper classes available in
218+
``pylint/testutil/`` are still unstable and might be modified in the near future.
219+
220+
Closes #4412 #5287

pylint/checkers/classes.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,20 +1848,18 @@ def _check_first_arg_for_type(self, node, metaclass=0):
18481848
"bad-mcs-method-argument",
18491849
node.name,
18501850
)
1851-
# regular class
1852-
else: # pylint: disable=else-if-used
1853-
# class method
1854-
if node.type == "classmethod" or node.name == "__class_getitem__":
1855-
self._check_first_arg_config(
1856-
first,
1857-
self.config.valid_classmethod_first_arg,
1858-
node,
1859-
"bad-classmethod-argument",
1860-
node.name,
1861-
)
1862-
# regular method without self as argument
1863-
elif first != "self":
1864-
self.add_message("no-self-argument", node=node)
1851+
# regular class with class method
1852+
elif node.type == "classmethod" or node.name == "__class_getitem__":
1853+
self._check_first_arg_config(
1854+
first,
1855+
self.config.valid_classmethod_first_arg,
1856+
node,
1857+
"bad-classmethod-argument",
1858+
node.name,
1859+
)
1860+
# regular class with regular method without self as argument
1861+
elif first != "self":
1862+
self.add_message("no-self-argument", node=node)
18651863

18661864
def _check_first_arg_config(self, first, config, node, message, method_name):
18671865
if first not in config:

pylint/checkers/exceptions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ def visit_const(self, node: nodes.Const) -> None:
232232
)
233233

234234
def visit_instance(self, instance: objects.ExceptionInstance) -> None:
235-
# pylint: disable=protected-access
236235
cls = instance._proxied
237236
self.visit_classdef(cls)
238237

@@ -535,7 +534,6 @@ def visit_tryexcept(self, node: nodes.TryExcept) -> None:
535534
if isinstance(exc, astroid.Instance) and utils.inherit_from_std_ex(
536535
exc
537536
):
538-
# pylint: disable=protected-access
539537
exc = exc._proxied
540538

541539
self._check_catching_non_exception(handler, exc, part)

pylint/checkers/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"""
5353

5454
import tokenize
55-
from functools import reduce # pylint: disable=redefined-builtin
55+
from functools import reduce
5656
from typing import List
5757

5858
from astroid import nodes

pylint/checkers/similar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
2727
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
2828

29-
# pylint: disable=redefined-builtin
3029
"""a similarities / code duplication command line tool and pylint checker
3130
3231
The algorithm is based on comparing the hash value of n successive lines of a file.

0 commit comments

Comments
 (0)