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

New analyser: Fix crash in plugins when star import blocks adding a symbol #7136

Merged
merged 3 commits into from
Jul 3, 2019

Conversation

ilevkivskyi
Copy link
Member

Fixes #7076

The fix is pretty straightforward. I also add a comment about missing_names being per-module, not per namespace.

@ilevkivskyi ilevkivskyi requested a review from JukkaL July 2, 2019 19:22
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.

The fix looks good, but I'm wondering if there are other improvements we could do to processing of missing names and star imports (no need to address them here).

# Note that missing names are per module, _not_ per namespace. This means that e.g.
# a missing name at global scope will block adding same name at a class scope.
# This should not affect correctness and is purely a performance issue,
# since it can cause unnecessary deferrals.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also document * in missing_names. Actually, I'm not sure if anything other than * needs to be supported here, since otherwise we should just be able to add a placeholder. If that's the case, this could be replaced with a boolean flag. (If this is feasible, this change should be made in a separate PR.)

Copy link
Member Author

Choose a reason for hiding this comment

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

It is hard to tell how easy it is. I can try it after landing this.

C() # E: Too few arguments for "C"
C('no') # E: Argument 1 to "C" has incompatible type "str"; expected "int"
[file other.py]
import lib
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like in this case it should be possible to process the star import without a deferral. Maybe create an issue about this if you agree with that, and add a comment here.

import lib
[file lib.py]
from dataclasses import dataclass
from other import *
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar to above, maybe we should be able to process this import without adding anything to missing_names.

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened #7141 for these two.

if info[attr.name].type is None and not ctx.api.final_iteration:
node = info.get(attr.name)
if node is None:
return
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add comment. Discuss why we don't defer here.

@ilevkivskyi ilevkivskyi merged commit 00ccb78 into python:master Jul 3, 2019
@ilevkivskyi ilevkivskyi deleted the fix-attrs-crash-newan branch July 3, 2019 13:48
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.

New Semantic Analyzer: INTERNAL ERROR on aiohttp
2 participants