Skip to content

Fix mypy_mypyc crash caused by "complex" interaction #6169

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

Merged
merged 1 commit into from
Jan 9, 2019
Merged

Conversation

msullivan
Copy link
Collaborator

The type of Num.n is complex, though it can in practice also be an
int or a float, and we case on the actual type to determine which
sort of mypy ast node to use.

In #6114, promotions were disabled in isinstance checks, which
caused mypy to decide that the isinstance checks for int and float
won't match. Fix this by giving the value the type object instead of
complex.

Typeshed does actually annotate n as Union[float, int, complex],
but mypy simplifies that into complex. (It does not do this
simplification for local variables with such an annotation; see
issue #6168.)

The type of Num.n is `complex`, though it can in practice also be an
`int` or a `float`, and we case on the actual type to determine which
sort of mypy ast node to use.

In #6114, promotions were disabled in `isinstance` checks, which
caused mypy to decide that the `isinstance` checks for int and float
won't match. Fix this by giving the value the type object instead of
complex.

Typeshed *does* actually annotate `n` as `Union[float, int, complex]`,
but mypy simplifies that into `complex`. (It does *not* do this
simplification for local variables with such an annotation; see
issue #6168.)
@msullivan
Copy link
Collaborator Author

(mypy_mypyc is currently completely busted until this goes in.)

@msullivan msullivan merged commit 307949a into master Jan 9, 2019
@msullivan msullivan deleted the fix-complex branch January 9, 2019 00:11
@msullivan
Copy link
Collaborator Author

Argh! There's still a failure left that causes some tests to fail.

I've also opened #6170 for running mypyc in CI.

(The way this snuck in was that I ran runtests.py on a compiled mypy, it passed the self check, failed linting, and then I forgot to re-run it after.)

msullivan added a commit that referenced this pull request Jan 9, 2019
This is just a case I missed in #6169.
msullivan added a commit that referenced this pull request Jan 9, 2019
This is just a case I missed in #6169.
msullivan added a commit that referenced this pull request Jan 9, 2019
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.

2 participants