Skip to content

Commit

Permalink
Add regression test for pylint-dev#5982
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Mar 26, 2022
1 parent 556304e commit 2630b12
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for annotation of variables and potential use before assignment"""
# pylint: disable=too-few-public-methods, global-variable-not-assigned
from __future__ import annotations
from collections import namedtuple
from typing import List

Expand Down Expand Up @@ -88,3 +89,9 @@ def my_method(self) -> Coords:
pass

print(MyObject)


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"""
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
used-before-assignment:15:10:15:18:only_type_assignment:Using variable 'variable' before assignment:HIGH
used-before-assignment:28:10:28:18:value_assignment_after_access:Using variable 'variable' before assignment:HIGH
undefined-variable:62:14:62:17:decorator_returning_incorrect_function.wrapper_with_type_and_no_value:Undefined variable 'var':HIGH
used-before-assignment:16:10:16:18:only_type_assignment:Using variable 'variable' before assignment:HIGH
used-before-assignment:29:10:29:18:value_assignment_after_access:Using variable 'variable' before assignment:HIGH
undefined-variable:63:14:63:17:decorator_returning_incorrect_function.wrapper_with_type_and_no_value:Undefined variable 'var':HIGH

0 comments on commit 2630b12

Please sign in to comment.