Skip to content

Original node wins in case of a redefinition (especially if it is a class) #5565

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 5 commits into from
Sep 4, 2018

Conversation

ilevkivskyi
Copy link
Member

@ilevkivskyi ilevkivskyi commented Sep 3, 2018

Fixes #5534

In principle we can be even more strict (see a little exception for class scope) but then we need to work on python/typeshed#2423 first.

@ilevkivskyi ilevkivskyi requested a review from JukkaL September 3, 2018 15:18
@JelleZijlstra
Copy link
Member

I submitted python/typeshed#2424 to fix the bad stub. Probably better to get that fix in first so mypy can be more consistent.

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.

Looks good, just one question about a test.

self.globals[name] = node

def add_local(self, node: Union[Var, FuncDef, OverloadedFuncDef], ctx: Context) -> None:
assert self.locals[-1] is not None, "Should not add locals outside a function"
name = node.name()
if name in self.locals[-1]:
self.name_already_defined(name, ctx, self.locals[-1][name])
return
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a test case for this?

@ilevkivskyi ilevkivskyi mentioned this pull request Sep 4, 2018
@ilevkivskyi ilevkivskyi mentioned this pull request Sep 4, 2018
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.

3 participants