Skip to content

Require typing in test-requirements.txt #893

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
wants to merge 1 commit into from

Conversation

gnprice
Copy link
Collaborator

@gnprice gnprice commented Oct 7, 2015

No description provided.

@o11c
Copy link
Contributor

o11c commented Oct 7, 2015

Mypy depends on its own local fork of typing, it does not work with python3.5's version yet.

@o11c
Copy link
Contributor

o11c commented Oct 7, 2015

Also we need to be able to say "use these requirements only if python < 3.5" (the infrastructure will be useful for enum too once we use that)

@o11c
Copy link
Contributor

o11c commented Oct 7, 2015

Also the typing package on pypi isn't available for 2.7, but mypy's is.

@gnprice
Copy link
Collaborator Author

gnprice commented Oct 7, 2015

@o11c thanks for the comments!

What are the right instructions for running tests, then? Following what's in the README, on my Ubuntu 14.04 Trusty machine, in a clean environment I get

gregprice@gregprice:~/w/mypy$ virtualenv -p python3 /tmp/asdf
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /tmp/asdf/bin/python3
Also creating executable in /tmp/asdf/bin/python
Installing setuptools, pip...done.
gregprice@gregprice:~/w/mypy$ . /tmp/asdf/bin/activate
(asdf)gregprice@gregprice:~/w/mypy$ pip install -r test-requirements.txt 
Downloading/unpacking flake8==2.4.1 (from -r test-requirements.txt (line 1))
  Downloading flake8-2.4.1-py2.py3-none-any.whl
Downloading/unpacking pep8>=1.5.7,!=1.6.0,!=1.6.1,!=1.6.2 (from flake8==2.4.1->-r test-requirements.txt (line 1))
  Downloading pep8-1.5.7-py2.py3-none-any.whl
Downloading/unpacking mccabe>=0.2.1,<0.4 (from flake8==2.4.1->-r test-requirements.txt (line 1))
  Downloading mccabe-0.3.1-py2.py3-none-any.whl
Downloading/unpacking pyflakes>=0.8.1,<0.9 (from flake8==2.4.1->-r test-requirements.txt (line 1))
  Downloading pyflakes-0.8.1-py2.py3-none-any.whl
Installing collected packages: flake8, pep8, mccabe, pyflakes
Successfully installed flake8 pep8 mccabe pyflakes
Cleaning up...
(asdf)gregprice@gregprice:~/w/mypy$ python3 tests.py
Traceback (most recent call last):
  File "tests.py", line 3, in <module>
    from mypy.myunit import Suite, run_test
  File "/home/gregprice/w/mypy/mypy/myunit.py", line 6, in <module>
    from typing import List, Tuple, Any, Callable, Union
ImportError: No module named 'typing'

With this change the tests pass. (My python3 is v3.4.3.)

@refi64
Copy link
Contributor

refi64 commented Oct 7, 2015

@gnprice

PYTHONPATH=`pwd`/lib-typing/3.2:`pwd` python3 tests.py

@gnprice
Copy link
Collaborator Author

gnprice commented Oct 7, 2015

@kirbyfan64 thanks, that works!

I'd love to adjust things so that the README gives instructions that will work totally smoothly. That particular command line, with PYTHONPATH, looks kind of messy and ideally I'd like to find something cleaner than that.

Looking at the Travis build instructions (in .travis.yml), it looks like another solution is to do python3 setup.py install before attempting the tests. So we could add a line to the running-tests section of the README saying to do that.

@o11c , @JukkaL , is that how you'd run tests in a fresh environment, or would you recommend something else?

@o11c
Copy link
Contributor

o11c commented Oct 7, 2015

@gnprice Everything about running the tests is about to change in #721 anyway.

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 9, 2015

We can probably wait until we have the new test driver in. Alternatively, maybe we should tweak sys.path in tests.py to include lib-typing/3.2? This way it would be less likely that people would accidentally use an incompatible version of typing.

@o11c, does the new test driver set up the environment correctly so that there is no need to tweak PYTHONPATH or install anything (other than test-requirements.txt)?

@o11c
Copy link
Contributor

o11c commented Oct 9, 2015

Yes, since tests.py no longer exists, travis.py contains the *PATH-setting logic that used to be in travis.sh. It even uses an if False branch to so that code can be typechecked before the typing module is actually importable.

@o11c
Copy link
Contributor

o11c commented Oct 9, 2015

It actually sets it to lib-typing/3.5:lib-typing/3.4:...:lib-typing/3.0 but stripping out directories that don't exist (so that the newest existing version would be used, though GvR's plan (at least for stubs) is to instead use if sys.version checks inside the module instead), and even has logic for 2.7 though that doesn't currently do anything, and probably won't be used with how I now intend to fix #732 and there are likely to be other changes with #884 and #887

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 12, 2015

Now we have a new test runner written by @o11c (runtests.py, renamed from travis.py) that can set up the path correctly for typing. Not sure what it does with Python 3.5 (haven't tried it yet) but I think that we can close this PR.

@gnprice Let me know if you still think that this is relevant. The longer-term goal would to migrate mypy to use typing installed using pip, probably.

@JukkaL JukkaL closed this Oct 12, 2015
@gnprice
Copy link
Collaborator Author

gnprice commented Oct 13, 2015

The instructions in the README WFM now out of the box. Thanks!

@gnprice gnprice deleted the tests branch October 14, 2015 21:52
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

Successfully merging this pull request may close these issues.

4 participants