Skip to content

Commit 2630b12

Browse files
Add regression test for pylint-dev#5982
1 parent 556304e commit 2630b12

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

ChangeLog

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ What's New in Pylint 2.13.2?
3636
============================
3737
Release date: TBA
3838

39+
* Fix crash when subclassing a ``namedtuple``.
40+
41+
Closes #5982
3942

4043

4144
What's New in Pylint 2.13.1?

tests/functional/u/used/used_before_assignment_type_annotations.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests for annotation of variables and potential use before assignment"""
22
# pylint: disable=too-few-public-methods, global-variable-not-assigned
3+
from __future__ import annotations
34
from collections import namedtuple
45
from typing import List
56

@@ -88,3 +89,9 @@ def my_method(self) -> Coords:
8889
pass
8990

9091
print(MyObject)
92+
93+
94+
class NamedTupleSubclass(namedtuple("NamedTupleSubclass", [])):
95+
"""Taken from https://github.com/PyCQA/pylint/issues/5982"""
96+
def method(self) -> NamedTupleSubclass:
97+
"""Variables checker crashed when astroid did not supply a lineno"""
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
used-before-assignment:15:10:15:18:only_type_assignment:Using variable 'variable' before assignment:HIGH
2-
used-before-assignment:28:10:28:18:value_assignment_after_access:Using variable 'variable' before assignment:HIGH
3-
undefined-variable:62:14:62:17:decorator_returning_incorrect_function.wrapper_with_type_and_no_value:Undefined variable 'var':HIGH
1+
used-before-assignment:16:10:16:18:only_type_assignment:Using variable 'variable' before assignment:HIGH
2+
used-before-assignment:29:10:29:18:value_assignment_after_access:Using variable 'variable' before assignment:HIGH
3+
undefined-variable:63:14:63:17:decorator_returning_incorrect_function.wrapper_with_type_and_no_value:Undefined variable 'var':HIGH

0 commit comments

Comments
 (0)