Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Don't let -s silence .py imports from stubs. Fix #1364. #1372

Merged
merged 1 commit into from
Apr 13, 2016

Conversation

gvanrossum
Copy link
Member

Implement the idea in the issue by Ben Darnell. (However, this
implementation still silences the case where main.py -> stub.pyi ->
x.py -> y.py. Hopefully that doesn't matter.)

Implement the idea in the issue by Ben Darnell.  (However, this
implementation still silences the case where main.py -> stub.pyi ->
x.py -> y.py. Hopefully that doesn't matter.)
@JukkaL
Copy link
Collaborator

JukkaL commented Apr 13, 2016

LGTM. It's unclear to me whether it would be better to follow imports from stub files recursively -- they could bring in a lot of code. This hopefully fixes Ben Darnell's immediate issue.

@gvanrossum gvanrossum merged commit bfedd4a into master Apr 13, 2016
gvanrossum pushed a commit that referenced this pull request Apr 13, 2016
@gvanrossum gvanrossum deleted the incremental-silent branch April 13, 2016 17:50
@gvanrossum
Copy link
Member Author

I've found a flaw in this idea.

Consider a .py file that's not mentioned on the command line but is imported both by a stub and by one of the initial sources. Now depending on processing order it may end up being referenced inconsistently -- one of the initial sources may have a silenced reference to it (i.e. it's equated to Any) but in the stub it's imported. It would be better if, given that we load the file anyway, its definitions are used everywhere, and a user might reasonably expect that behavior.

The consequences are probably minor -- maybe this use case is uncommon, and at worst it would suppress some useful errors, but those could be revealed by adding it to the command line.

@bdarnell beware of this.

@bdarnell
Copy link
Contributor

Noted. I'm not currently planning to use -s any more. I'll just stubgen things as I need them or use # type: ignore.

This also ties in to #1190: I need to be able to specify that my .py files contain annotations that should be considered as valid as .pyi files. -s categorically considers .py files as inferior which undermines the rationale for inline annotations.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants