Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Python 3.7 compatibility #2

Closed
cryzed opened this issue Sep 7, 2018 · 13 comments
Closed

Python 3.7 compatibility #2

cryzed opened this issue Sep 7, 2018 · 13 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@cryzed
Copy link

cryzed commented Sep 7, 2018

It would be great if this was fully compatible with Python 3.7, but it unfortunately isn't. The problem seems mostly linked with accessing private members of the typingmodule:

>>> import nubia
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/__init__.py", line 12, in <module>
    from .internal.deprecation import deprecated
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/deprecation.py", line 15, in <module>
    from nubia.internal.typing import inspect_object
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/typing/__init__.py", line 68, in <module>
    from nubia.internal.helpers import (
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/helpers.py", line 17, in <module>
    from typing import _Union, Any, Iterable  # noqa T484
ImportError: cannot import name '_Union' from 'typing' (/usr/lib/python3.7/typing.py)

After importing Union instead (which I'm sure doesn't really fix the problem), it seemingly works fine, however there might be hiding more incompatibilities. For example, I suspect this is one:

user> pick code=14 stuff=red style=toast                                                                                                      Error: 3
Traceback (most recent call last):
  File "nubia_example.py", line 17, in <module>
    sys.exit(shell.run())
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/nubia.py", line 296, in run
    return self.start_interactive(args)
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/nubia.py", line 196, in start_interactive
    io_loop.run()
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/interactive.py", line 181, in run
    self.parse_and_evaluate(stdout, text)
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/interactive.py", line 127, in parse_and_evaluate
    return self.evaluate_command(stdout, cmd, args, input)
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/interactive.py", line 159, in evaluate_command
    result = cmd_instance.run_interactive(cmd, args, raw)
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/cmdbase.py", line 340, in run_interactive
    new_value = apply_typing(value, target_type)
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/typing/builder.py", line 34, in apply_typing
    return get_typing_function(type)(value)
  File "/home/user/.virtualenvs/toolbox/lib/python3.7/site-packages/nubia/internal/typing/builder.py", line 195, in wrapped
    return function(string, *args_builders)
  File "/usr/lib/python3.7/typing.py", line 668, in __call__
    raise TypeError(f"Type {self._name} cannot be instantiated; "
TypeError: Type List cannot be instantiated; use list() instead
@AhmedSoliman AhmedSoliman added good first issue Good for newcomers bug Something isn't working labels Sep 7, 2018
@motohedgehog
Copy link

Thanks @cryzed for reporting this. Importing _Union is an ugly hack that we use for inferring types for optional arguments. I think it's never been tested against Python 3.7, good catch!

@asamolion
Copy link

Hi there, I would like to test this for Python 3.7 compatibility.

Can someone please point me in the right direction?

@motohedgehog
Copy link

@asamolion I think you can start with changing the required Python version in Pipfile.

@asamolion
Copy link

Alright.

@motohedgehog
Copy link

@asamolion, sorry for not making it clear enough. Please see my last comment in #6 for more details.
You can use pipenv install --python 3.7 to use Python 3.7 interpreter with our Pipfile (just ignore the warnings).

@motohedgehog
Copy link

motohedgehog commented Sep 10, 2018

OK, just for the record: it's tricky. The 3.7 version changes some important bits of typing mechanism which break our introspection.

@motohedgehog motohedgehog removed good first issue Good for newcomers labels Sep 11, 2018
@motohedgehog
Copy link

I've made some progress on this, but it'll be a pretty big PR, TBH.
Unfortunately, Python 3.7 is not our top priority at the moment, so I'll be working on this mostly during my spare time. Anyway, I plan to address this soonish :)

@motohedgehog
Copy link

@DMArens will pick this up :)

@calebmarchent
Copy link

Reading the comment, the reference implementation for type inference has been updated to support Python3.7: ilevkivskyi/typing_inspect@7aa7bb5#diff-faac2f2c6bc2bfba052313740ae107e8

The new behaviour is Python version dependent. I think the next action is to integrate the method above into Python-nubia.

calebmarchent pushed a commit to calebmarchent/python-nubia that referenced this issue Dec 14, 2018
@calebmarchent
Copy link

I have added the port in my 3.7 PR #19; which certainly moved things forward a bit by breaking the failure to import _Union. We then fail on some of the unit tests; which probably means more of the fixes need to be imported.

@cdluminate
Copy link

Any update on python3.7 compat?

@calebmarchent calebmarchent added the help wanted Extra attention is needed label Feb 19, 2019
@calebmarchent
Copy link

No update at present as we are working on other priorities; We would welcome assistance offered in resolving the Python3.7 integration issues.

@motohedgehog motohedgehog self-assigned this Apr 28, 2019
@motohedgehog
Copy link

Hi everyone,
I'm happy to announce that I finished working on Python 3.7 support.

It will take a few days to land it as I'm waiting for #28 and also need to test our internal builds.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants