Skip to content

try-except import results in error #2251

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

Closed
RitwikGupta opened this issue Oct 14, 2016 · 2 comments
Closed

try-except import results in error #2251

RitwikGupta opened this issue Oct 14, 2016 · 2 comments

Comments

@RitwikGupta
Copy link

try:
    # Python 3
    from urllib.request import urlopen
except ImportError:
    # Python 2
    from urllib2 import urlopen

results in file.py:X: error: Name 'urlopen' already defined

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 14, 2016

This looks like a special case of #1153. Currently you can add a # type: ignore on the line which mypy complains about.

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 14, 2016

Closing as a dupe. Any follow-up discussion can go to #1153.

@JukkaL JukkaL closed this as completed Oct 14, 2016
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

2 participants