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

Output may contain invalid import syntax when input file has leading ./ #47

Closed
gvanrossum opened this issue Feb 13, 2017 · 8 comments
Closed

Comments

@gvanrossum
Copy link

I have a module containing the line

from __future__ import print_function

and I invoke pytype as

pytype ./yo.py -o -

Now the generated stub has invalid imports:

import ..__future__

print_function = ...  # type: ..__future__._Feature
@matthiaskramm
Copy link
Contributor

Why is that stub invalid? You can totally do

import yo
yo.print_function

(I know the import __future__ in the pyi looks weird, but it's necessary to formulate the # type comment, and PEP 484 says that imports like this aren't re-exported)

@matthiaskramm
Copy link
Contributor

(Also, if you're testing pytype right now, I should probably export a new version)

@gvanrossum
Copy link
Author

Well, import ..__future__ is not valid Python syntax (note the two leading dots).

Also, yes I'm testing it, so would appreciate a new version.

@matthiaskramm
Copy link
Contributor

Oh, I thought those two dots meant "some other imports not relevant to this bug".

Odd. I didn't even know pytype could generate relative imports.

@matthiaskramm
Copy link
Contributor

Could you attach your yo.py?

Also, running an open-source export. It'll take a few hours (more if we hit a snag), we accumulated quite a few changes.

@gvanrossum
Copy link
Author

gvanrossum commented Feb 14, 2017 via email

@matthiaskramm
Copy link
Contributor

Ah, I missed that you're using ./yo.py as path name. Good catch!

Export is done - pytype is now the newest version. (Will now verify that typeshed's travis still works)

@gvanrossum
Copy link
Author

gvanrossum commented Feb 14, 2017 via email

martindemello referenced this issue Jun 19, 2017
--
PiperOrigin-RevId: 159140256
MOS_MIGRATED_REVID=159140256
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

No branches or pull requests

3 participants