Skip to content

Mypy complaining about invalid types #384

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
Strilanc opened this issue May 5, 2018 · 7 comments
Closed

Mypy complaining about invalid types #384

Strilanc opened this issue May 5, 2018 · 7 comments
Assignees

Comments

@Strilanc
Copy link
Contributor

Strilanc commented May 5, 2018

Couldn't figure this out

cirq/google/engine/engine.py:171: error: Invalid type "cirq.study.study.Sweepable"
cirq/google/engine/engine.py:434: error: Invalid type "cirq.study.study.Sweepable"
cirq/google/sim/xmon_simulator.py:169: error: Invalid type "cirq.study.study.Sweepable"
cirq/google/sim/xmon_simulator.py:236: error: Invalid type "cirq.study.study.Sweepable"
@Strilanc Strilanc self-assigned this May 5, 2018
@Strilanc
Copy link
Contributor Author

Strilanc commented May 5, 2018

Well, a couple hours later, I added this line to engine:

from cirq.study.study import Sweepable

And the type errors went away. I then removed the line, and the type errors stayed gone.

Quite frustrating. Worth knowing.

@Strilanc Strilanc closed this as completed May 5, 2018
@Strilanc Strilanc reopened this May 5, 2018
@Strilanc
Copy link
Contributor Author

Strilanc commented May 5, 2018

It just switched back to failing.

@Strilanc
Copy link
Contributor Author

Strilanc commented May 5, 2018

This is... literally impossible to debug. I delete some files, run mypy, it reports failures, I make a commit as a checkpoint, run a local check, run mypy again, and the failures are gone!

@Strilanc
Copy link
Contributor Author

Strilanc commented May 5, 2018

Doing nothing but run mypy can affect whether mypy reports failures.

$ bash continuous-integration/check-pull-request.sh --only=typecheck
[...]
cirq/google/engine/engine.py:172: error: Invalid type "cirq.study.study.Sweepable"
cirq/google/engine/engine.py:435: error: Invalid type "cirq.study.study.Sweepable"
cirq/google/sim/xmon_simulator.py:169: error: Invalid type "cirq.study.study.Sweepable"
cirq/google/sim/xmon_simulator.py:236: error: Invalid type "cirq.study.study.Sweepable"
[...]
('typecheck by maintainer', (False, '4 issues', None))


$ mypy --config-file=continuous-integration/mypy.ini .
[no failures]


$ bash continuous-integration/check-pull-request.sh --only=typecheck
[...]
('typecheck by maintainer', (True, 'Types look good!', None))

@Strilanc
Copy link
Contributor Author

Strilanc commented May 5, 2018

Okay, I've figured out the weird stateful thing. It's because I was accidentally copying .mypycache along with the source files when preparing the test environment. That's fixed now. Should go quicker.

@Strilanc
Copy link
Contributor Author

Strilanc commented May 5, 2018

When I run the exact same command as the one invoked by python, I get no results instead of some results. Maybe there's some kind of environment variable ruining everything...?

@Strilanc
Copy link
Contributor Author

Strilanc commented May 8, 2018

I managed to make a small repro and report it to mypy: python/mypy#5015

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

1 participant