Skip to content
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

Fixed being unable to access class attributes on a NamedTuple #673

Merged
merged 1 commit into from
May 20, 2019

Conversation

AWhetter
Copy link
Contributor

Description

In the case of an assignment to a NamedTuple without a type, the attribute becomes a class attribute.

>>> from typing import NamedTuple
>>> class MyTuple(NamedTuple):
...     CLASS_ATTR = "class_attr"
...     instance_attr: str
...     default_attr: str = "default"
... 
>>> my_tuple = MyTuple("instance")
>>> my_tuple
MyTuple(instance_attr='instance', default_attr='default')
>>> my_tuple.CLASS_ATTR
'class_attr'
>>> MyTuple.CLASS_ATTR
'class_attr'

This pull request adds the copying of class attributes to subclasses of NamedTuple .

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Related Issue

Close pylint-dev/pylint#1628

@PCManticore
Copy link
Contributor

Thank you! The AppVeyor failure is unrelated, let's merge this.

@PCManticore PCManticore merged commit cee50e6 into master May 20, 2019
@PCManticore PCManticore deleted the fix_pylint_1628 branch May 20, 2019 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

typing.NamedTuple false positive no-member for methods
2 participants