KEMBAR78
Produce error when NamedTuple is assigned to attribute by AFanaei · Pull Request #7662 · python/mypy · GitHub
Skip to content

Conversation

@AFanaei
Copy link
Contributor

@AFanaei AFanaei commented Oct 9, 2019

Fixes #7531

@AFanaei AFanaei force-pushed the namedtuple-as-attr branch from fe9ac72 to 3c062be Compare October 9, 2019 06:30
@AFanaei
Copy link
Contributor Author

AFanaei commented Oct 11, 2019

hi @JukkaL , could you review this PR?

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Looks mostly good. I have a suggestion about tests.

@AFanaei AFanaei force-pushed the namedtuple-as-attr branch from f8df8c9 to 6651401 Compare October 12, 2019 06:59
return False
if isinstance(s.lvalues[0], MemberExpr):
self.fail("NamedTuple type as an attribute is not supported", lvalue)
return False
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this block to start but then a NamedTuple type as an attrib ... error was generated on every attribute assignment statement.
as the error should raise only if RHS is NamedTuple, i think this block is better at the end.

@AFanaei AFanaei requested a review from JukkaL October 25, 2019 11:44
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good.

@JukkaL JukkaL merged commit e2d2c11 into python:master Oct 28, 2019
ilevkivskyi pushed a commit that referenced this pull request Dec 9, 2019
…me for variable (#8112)

Followed the discussion in #8107 (comment), refine the code merged in #7662 by:

- move testcase from `pythoneval.test` to `check-namedtuple.test` and rename it from `testNamedTupleAtRunTime` to `testAssignNamedTupleAsAttribute`
- change `s.lvalues[0]` to `lvalue` to make it more concise
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.

NamedTuple triggered mypy error inside a class

3 participants