Skip to content

"from typing import Type" (works in Debian, not working under Arch) #1838

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
ttsiodras opened this issue Jul 9, 2016 · 3 comments
Closed

Comments

@ttsiodras
Copy link

I installed typing via pip3 in both my Debian and Arch environments, and see this:

Under Debian:

$ pip3 freeze | grep typing
typing==3.5.2.2

$ python3
Python 3.4.2 (default, Oct  8 2014, 13:14:40) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import Type
>>> 

Under Arch:

$ pip3 freeze | grep typing
typing==3.5.2.2

$ python3
Python 3.5.1 (default, Mar  3 2016, 09:29:07) 
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import Type
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Type'
>>> 

Have I messed up or is there some difference due to 3.4 -> 3.5?

P.S. In case there's a way around it - I use Type, because I have annotated code like this:

U = TypeVar('U', int, float)

def GetRange(newModule: Module, lineNo: int, nodeWithMinAndMax: Element, valueType: Type[U]) -> Tuple[U, U]:
    ...
    rangel = valueType(mmin)
    rangeh = valueType(mmax)
    return (rangel, rangeh)

...so I can create the appropriate type at runtime in my AST.

@refi64
Copy link
Contributor

refi64 commented Jul 9, 2016

Python 3.5 comes with its own version of typing, which was added before the introduction of typing.Type. In the latter example, Python is picking up the standard library version instead of the version from pip.

@ttsiodras
Copy link
Author

I see!

Is there any way to "give priority" to the pip3-installed version under python 3.5?

@ttsiodras
Copy link
Author

ttsiodras commented Jul 9, 2016

Never mind - got it:

$ PYTHONPATH=$HOME/.local/lib/python3.5/site-packages python3
Python 3.5.1 (default, Mar  3 2016, 09:29:07) 
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/home/ttsiod/.local/lib/python3.5/site-packages', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-linux', '/usr/lib/python3.5/lib-dynload', '/usr/lib/python3.5/site-packages']
>>> import typing
>>> typing.__file__
'/home/ttsiod/.local/lib/python3.5/site-packages/typing.py'
>>> from typing import Type
>>> 

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