Skip to content

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

Closed

Description

@refi64

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.

Activity

  1. gvanrossum commented on Oct 24, 2016

    @gvanrossum
    Member

    Hm, interesting. @Michael0x2a might have some insights.

  2. refi64 commented on Oct 24, 2016

    @refi64
    ContributorAuthor

    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 $ 
    
  3. refi64 commented on Oct 24, 2016

    @refi64
    ContributorAuthor

    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.

  4. gvanrossum commented on Oct 25, 2016

    @gvanrossum
    Member
  5. refi64 commented on Oct 25, 2016

    @refi64
    ContributorAuthor

    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...

  6. gvanrossum commented on Oct 25, 2016

    @gvanrossum
    Member
  7. added this to the milestone on Oct 27, 2016
  8. gvanrossum commented on Mar 24, 2017

    @gvanrossum
    Member

    Is this still reproducible?

  9. refi64 commented on Mar 27, 2017

    @refi64
    ContributorAuthor
  10. added a commit that references this issue on Mar 27, 2017
    161a2ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions