Skip to content
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

Cannot find component ProtocolIntersection\u200b #4

Closed
evhub opened this issue Apr 23, 2023 · 4 comments · Fixed by #5
Closed

Cannot find component ProtocolIntersection\u200b #4

evhub opened this issue Apr 23, 2023 · 4 comments · Fixed by #5

Comments

@evhub
Copy link

evhub commented Apr 23, 2023

If one module imports ProtocolIntersection, and then another module attempts to import it from that module, mypy seems unable to lookup ProtocolIntersection in the imported module's namespace (maybe due to the presence of a zero-width space at the end?):

Traceback (most recent call last):
  File "C:\Users\evanj\GitHub\coconut\coconut\command\mypy.py", line 69, in mypy_run
    stdout, stderr, exit_code = run(args)
  File "mypy\api.py", line 72, in run
  File "mypy\api.py", line 59, in _run
  File "mypy\api.py", line 73, in <lambda>
  File "mypy\main.py", line 95, in main
  File "mypy\main.py", line 174, in run_build
  File "mypy\build.py", line 194, in build
  File "mypy\build.py", line 277, in _build
  File "mypy\build.py", line 2930, in dispatch
  File "mypy\build.py", line 3321, in process_graph
  File "mypy\build.py", line 3402, in process_fresh_modules
  File "mypy\build.py", line 2121, in fix_cross_refs
  File "mypy\fixup.py", line 53, in fixup_module
  File "mypy\fixup.py", line 136, in visit_symbol_table
  File "mypy\fixup.py", line 73, in visit_type_info
  File "mypy\fixup.py", line 138, in visit_symbol_table
  File "mypy\nodes.py", line 774, in accept
  File "mypy\fixup.py", line 146, in visit_func_def
  File "mypy\types.py", line 1869, in accept
  File "mypy\fixup.py", line 244, in visit_callable_type
  File "mypy\types.py", line 2803, in accept
  File "mypy\fixup.py", line 338, in visit_type_type
  File "mypy\types.py", line 1357, in accept
  File "mypy\fixup.py", line 209, in visit_instance
  File "mypy\fixup.py", line 344, in lookup_fully_qualified_typeinfo
  File "mypy\lookup.py", line 49, in lookup_fully_qualified
AssertionError: Cannot find component 'ProtocolIntersection\u200b' for 'typing_protocol_intersection.types.ProtocolIntersection\u200b'

Also note that reproduction here is a bit tricky, since it seems to depend on the current status of .mypy_cache, though it always shows up for me after running mypy enough times. I'm on Python 3.9 and mypy 1.2.0. mypy.ini is just:

[mypy]
plugins = typing_protocol_intersection.mypy_plugin
@evhub
Copy link
Author

evhub commented Apr 23, 2023

Hmmm... I'm sometimes seeing this error now even when everything is contained in a single file without importing ProtocolIntersection from elsewhere, so I'm a bit stumped as to what's causing it. It continues to be very dependent on .mypy_cache—it seems like it generally works on the first try before any .mypy_cache has been generated, then fails at some point later when it loads that .mypy_cache.

@evhub evhub changed the title Cannot import ProtocolIntersection Cannot find component 'ProtocolIntersection\u200b' Apr 23, 2023
@evhub evhub changed the title Cannot find component 'ProtocolIntersection\u200b' Cannot find component ProtocolIntersection\u200b Apr 23, 2023
@evhub
Copy link
Author

evhub commented Apr 23, 2023

This gist seems sufficient to reproduce the error for me after it has been run a couple of times to generate a .mypy_cache, though I don't really know which components of it are necessary for the error to occur.

@klausweiss
Copy link
Owner

Hey. Thanks for reporting! Just wanted to mention that life's hectic, so I might take a few days to look at this issue in depth. Should you have any ideas before I investigate, shoot.

@klausweiss klausweiss added the help wanted Extra attention is needed label May 26, 2023
@klausweiss
Copy link
Owner

I have no solution so far. Frankly I didn't have time to dive deep, I only scratched a surface. If mypyc/mypyc#973 gets fixed, we can return to the old implementation that didn't add artificial suffixes to the class names. I'm happy to consider any alternative approaches to the implementation anyone might have.

@klausweiss klausweiss removed the help wanted Extra attention is needed label Aug 28, 2023
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 a pull request may close this issue.

2 participants