Skip to content

Bug with type: ignore comment on import and incremental #2308

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
refi64 opened this issue Oct 24, 2016 · 8 comments
Closed

Bug with type: ignore comment on import and incremental #2308

refi64 opened this issue Oct 24, 2016 · 8 comments
Labels

Comments

@refi64
Copy link
Contributor

refi64 commented Oct 24, 2016

Still trying to get a test case. However, for now, I'll post the interesting parts:

  • In errors.py, I have code like this:
import colorama  # type: ignore

For some reason, the cache for this file at some point didn't add colorama to the suppressed section, so the import started being an error.

@gvanrossum
Copy link
Member

Hm, interesting. @Michael0x2a might have some insights.

@refi64
Copy link
Contributor Author

refi64 commented Oct 24, 2016

Create the following files:

  • x.py:

    A = 0
    from y import B
  • y.py:

    import xyz  # type: ignore
    B = 0
    from x import A

Now, watch the following commands:

ryan@DevPC-LX ~/blaze-mypy/bug master $ mypy -i x.py  # Works.
ryan@DevPC-LX ~/blaze-mypy/bug master $ touch x.py    # Update the mtime of x.py.
ryan@DevPC-LX ~/blaze-mypy/bug master $ mypy -i x.py  # Works.
ryan@DevPC-LX ~/blaze-mypy/bug master $ touch x.py    # Update the mtime of x.py again.
ryan@DevPC-LX ~/blaze-mypy/bug master $ mypy -i x.py  # Fails!
x.py:2: note: In module imported here:
y.py:1: error: Cannot find module named 'xyz'
y.py:1: note: (Perhaps setting MYPYPATH or using the "--silent-imports" flag would help)
ryan@DevPC-LX ~/blaze-mypy/bug master $ 

@refi64
Copy link
Contributor Author

refi64 commented Oct 24, 2016

Workaround to avoid having to clear the entire cache: rm .mypy_cache/*/y.*.json, replacing y with the module that had the type: ignore comment.

@gvanrossum
Copy link
Member

gvanrossum commented Oct 25, 2016 via email

@refi64
Copy link
Contributor Author

refi64 commented Oct 25, 2016

Well, I actually just realized that a much, much better workaround is to just do touch y.py... I don't know why I didn't think of that before...

@gvanrossum
Copy link
Member

gvanrossum commented Oct 25, 2016 via email

@gvanrossum gvanrossum added this to the 0.5 milestone Oct 27, 2016
@gvanrossum gvanrossum added the bug mypy got something wrong label Oct 27, 2016
@gvanrossum
Copy link
Member

Is this still reproducible?

@refi64
Copy link
Contributor Author

refi64 commented Mar 27, 2017

@gvanrossum Yup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants