Skip to content

Add regression test for #5982 #5988

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

Merged
merged 4 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ What's New in Pylint 2.13.2?
============================
Release date: TBA

* Fix crash when subclassing a ``namedtuple``.

Closes #5982


What's New in Pylint 2.13.1?
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 .[testutil]
# astroid dependency is also defined in setup.cfg
astroid==2.11.0 # Pinned to a specific version for tests
astroid==2.11.2 # Pinned to a specific version for tests
typing-extensions~=4.1
pytest~=7.0
pytest-benchmark~=3.4
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ install_requires =
# Also upgrade requirements_test_min.txt if you are bumping astroid.
# Pinned to dev of next minor update to allow editable installs,
# see https://github.com/PyCQA/astroid/issues/1341
astroid>=2.11.0,<=2.12.0-dev0
astroid>=2.11.2,<=2.12.0-dev0
isort>=4.2.5,<6
mccabe>=0.6,<0.8
tomli>=1.1.0;python_version<"3.11"
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/u/used/used_before_assignment_py37.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for used-before-assignment with functions added in python 3.7"""
# pylint: disable=missing-function-docstring
from __future__ import annotations
from collections import namedtuple
from typing import List


Expand All @@ -26,3 +27,9 @@ def inner_method(self, other: MyClass) -> bool:
return self == other

return inner_method(self, MyClass())


class NamedTupleSubclass(namedtuple("NamedTupleSubclass", [])):
"""Taken from https://github.com/PyCQA/pylint/issues/5982"""
def method(self) -> NamedTupleSubclass:
"""Variables checker crashed when astroid did not supply a lineno"""
2 changes: 1 addition & 1 deletion tests/functional/u/used/used_before_assignment_py37.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
undefined-variable:17:20:17:27:MyClass.incorrect_default_method:Undefined variable 'MyClass':UNDEFINED
undefined-variable:18:20:18:27:MyClass.incorrect_default_method:Undefined variable 'MyClass':UNDEFINED