Skip to content

Commit

Permalink
Merge branch 'pylint-dev:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
berkersal authored Jan 3, 2025
2 parents bb9d9d1 + c21276f commit fc701c4
Show file tree
Hide file tree
Showing 21 changed files with 91 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
$GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
key: >-
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
$GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
key: >-
Expand All @@ -71,7 +71,7 @@ jobs:
hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT
- name: Restore pre-commit environment
id: cache-precommit
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: ${{ env.PRE_COMMIT_CACHE }}
key: >-
Expand All @@ -98,7 +98,7 @@ jobs:
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
fail-on-cache-miss: true
Expand All @@ -107,7 +107,7 @@ jobs:
needs.prepare-base.outputs.python-key }}
- name: Restore pre-commit environment
id: cache-precommit
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: ${{ env.PRE_COMMIT_CACHE }}
fail-on-cache-miss: true
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
fail-on-cache-miss: true
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
fail-on-cache-miss: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/primer-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
$GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
key: >-
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
fail-on-cache-miss: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/primer_comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
# Restore cached Python environment
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
key:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/primer_run_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
# Create a re-usable virtual environment
- name: Restore Python virtual environment cache
id: cache-venv
uses: actions/cache/restore@v4.1.2
uses: actions/cache/restore@v4.2.0
with:
path: venv
key:
Expand All @@ -63,7 +63,7 @@ jobs:
# Save cached Python environment (explicit because cancel-in-progress: true)
- name: Save Python virtual environment to cache
if: steps.cache-venv.outputs.cache-hit != 'true'
uses: actions/cache/save@v4.1.2
uses: actions/cache/save@v4.2.0
with:
path: venv
key:
Expand All @@ -82,7 +82,7 @@ jobs:
echo "commitstring=$output" >> $GITHUB_OUTPUT
- name: Restore projects cache
id: cache-projects
uses: actions/cache/restore@v4.1.2
uses: actions/cache/restore@v4.2.0
with:
path: tests/.pylint_primer_tests/
key: >-
Expand All @@ -95,14 +95,14 @@ jobs:
python tests/primer/__main__.py prepare --clone
- name: Save projects cache
if: steps.cache-projects.outputs.cache-hit != 'true'
uses: actions/cache/save@v4.1.2
uses: actions/cache/save@v4.2.0
with:
path: tests/.pylint_primer_tests/
key: >-
${{ runner.os }}-${{ matrix.python-version }}-${{
steps.commitstring.outputs.commitstring }}-primer
- name: Upload commit string
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.5.0
if: matrix.batchIdx == 0
with:
name: primer_commitstring_${{ matrix.python-version }}
Expand All @@ -123,7 +123,7 @@ jobs:
then echo "::warning ::$WARNINGS"
fi
- name: Upload output
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.5.0
with:
name:
primer_output_main_${{ matrix.python-version }}_batch${{ matrix.batchIdx }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/primer_run_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
# Restore cached Python environment
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache/restore@v4.1.2
uses: actions/cache/restore@v4.2.0
with:
path: venv
key:
Expand All @@ -75,7 +75,7 @@ jobs:
# Save cached Python environment (explicit because cancel-in-progress: true)
- name: Save Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
uses: actions/cache/save@v4.1.2
uses: actions/cache/save@v4.2.0
with:
path: venv
key:
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
echo "commitstring=$output" >> $GITHUB_OUTPUT
- name: Restore projects cache
id: cache-projects
uses: actions/cache/restore@v4.1.2
uses: actions/cache/restore@v4.2.0
with:
path: tests/.pylint_primer_tests/
key: >-
Expand All @@ -164,7 +164,7 @@ jobs:
python tests/primer/__main__.py prepare --clone
- name: Save projects cache
if: steps.cache-projects.outputs.cache-hit != 'true'
uses: actions/cache/save@v4.1.2
uses: actions/cache/save@v4.2.0
with:
path: tests/.pylint_primer_tests/
key: >-
Expand Down Expand Up @@ -197,15 +197,15 @@ jobs:
then echo "::warning ::$WARNINGS"
fi
- name: Upload output of PR
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.5.0
with:
name:
primer_output_pr_${{ matrix.python-version }}_batch${{ matrix.batchIdx }}
path:
tests/.pylint_primer_tests/output_${{ matrix.python-version }}_pr_batch${{
matrix.batchIdx }}.txt
- name: Upload output of 'main'
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.5.0
with:
name:
primer_output_main_${{ matrix.python-version }}_batch${{ matrix.batchIdx }}
Expand All @@ -218,7 +218,7 @@ jobs:
- name: Upload PR number
if:
startsWith(steps.python.outputs.python-version, '3.9') && matrix.batchIdx == 0
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.5.0
with:
name: pr_number
path: pr_number.txt
16 changes: 8 additions & 8 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
$GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
key: >-
Expand All @@ -76,7 +76,7 @@ jobs:
pip list | grep 'astroid\|pylint'
python -m pytest -vv --minimal-messages-config tests/test_functional.py
- name: Upload coverage artifact
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.5.0
with:
name: coverage-${{ matrix.python-version }}
include-hidden-files: true
Expand All @@ -98,7 +98,7 @@ jobs:
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
fail-on-cache-miss: true
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
fail-on-cache-miss: true
Expand All @@ -161,7 +161,7 @@ jobs:
run: >-
echo "datetime="$(date "+%Y%m%d_%H%M") >> $GITHUB_OUTPUT
- name: Upload benchmark artifact
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.5.0
with:
name:
benchmark-${{ runner.os }}-${{ matrix.python-version }}_${{
Expand Down Expand Up @@ -199,7 +199,7 @@ jobs:
}}" >> $env:GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
key: >-
Expand Down Expand Up @@ -245,7 +245,7 @@ jobs:
}}" >> $GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
key: >-
Expand Down Expand Up @@ -289,7 +289,7 @@ jobs:
}}" >> $GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v4.1.2
uses: actions/cache@v4.2.0
with:
path: venv
key: >-
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
doc/data/messages/m/missing-final-newline/bad/crlf.py
)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.1"
rev: "v0.8.4"
hooks:
- id: ruff
args: ["--fix"]
Expand Down Expand Up @@ -125,7 +125,7 @@ repos:
files: ^(doc/(.*/)*.*\.rst)
additional_dependencies: [Sphinx==7.4.3]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.14.0
hooks:
- id: mypy
name: mypy
Expand All @@ -140,11 +140,11 @@ repos:
"platformdirs==2.2.0",
"py==1.11",
"tomlkit>=0.10.1",
"types-pkg_resources==0.1.3",
"types-setuptools==75.6.0.20241126",
]
exclude: tests(/\w*)*/functional/|tests/input|tests(/.*)+/conftest.py|doc/data/messages|tests(/\w*)*data/
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.1
rev: v3.4.2
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tox
You can also *optionally* install tox_ and run our tests using the tox_ package, as in::

python -m tox
python -m tox -epy312 # for Python 3.12 suite only
python -m tox -epy313 # for Python 3.13 suite only
python -m tox -epylint # for running Pylint over Pylint's codebase
python -m tox -eformatting # for running formatting checks over Pylint's codebase

Expand Down
29 changes: 29 additions & 0 deletions doc/whatsnew/3/3.3/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,35 @@ Summary -- Release highlights

.. towncrier release notes start
What's new in Pylint 3.3.3?
---------------------------
Release date: 2024-12-23


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

- Fix false positives for ``undefined-variable`` for classes using Python 3.12
generic type syntax.

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

- Fix a false positive for `use-implicit-booleaness-not-len`. No lint should be emitted for
generators (`len` is not defined for generators).

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



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

- Fix ``Unable to import 'collections.abc' (import-error)`` on Python 3.13.1.

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



What's new in Pylint 3.3.2?
---------------------------
Release date: 2024-12-01
Expand Down
4 changes: 0 additions & 4 deletions doc/whatsnew/fragments/10100.false_positive

This file was deleted.

16 changes: 15 additions & 1 deletion pylint/checkers/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,11 @@ def _should_node_be_skipped(
if utils.is_ancestor_name(consumer.node, node) or (
not is_start_index and self._ignore_class_scope(node)
):
if any(
node.name == param.name.name for param in consumer.node.type_params
):
return False

return True

# Ignore inner class scope for keywords in class definition
Expand Down Expand Up @@ -1952,7 +1957,9 @@ def _check_consumer(
)
return (VariableVisitConsumerAction.RETURN, found_nodes)

elif isinstance(defstmt, nodes.ClassDef):
elif (
isinstance(defstmt, nodes.ClassDef) and defnode not in defframe.type_params
):
return self._is_first_level_self_reference(node, defstmt, found_nodes)

elif isinstance(defnode, nodes.NamedExpr):
Expand Down Expand Up @@ -2334,6 +2341,13 @@ def _is_variable_violation(
maybe_before_assign = defnode.value is node or any(
anc is defnode.value for anc in node.node_ancestors()
)
elif (
isinstance(defframe, nodes.ClassDef)
and defnode in defframe.type_params
):
# Generic on parent class:
# class Child[_T](Parent[_T])
maybe_before_assign = False

return maybe_before_assign, annotation_return, use_outer_definition

Expand Down
Loading

0 comments on commit fc701c4

Please sign in to comment.