You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running mypy in a simple file which uses type annotations from alembic1.7.0 gives a crash. Works fine with `1.6.5 .
Traceback
Traceback (most recent call last):
File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "E:\projects\temp\.env39-alembic-mypy\Scripts\mypy.exe\__main__.py", line 7, in <module>
File "e:\projects\temp\.env39-alembic-mypy\lib\site-packages\mypy\__main__.py", line 11, in console_entry
main(None, sys.stdout, sys.stderr)
File "mypy\main.py", line 87, in main
File "mypy\main.py", line 165, in run_build
File "mypy\build.py", line 179, in build
File "mypy\build.py", line 254, in _build
File "mypy\build.py", line 2697, in dispatch
File "mypy\build.py", line 3021, in process_graph
File "mypy\build.py", line 3138, in process_stale_scc
File "mypy\build.py", line 2288, in write_cache
File "mypy\build.py", line 1475, in write_cache
File "mypy\nodes.py", line 313, in serialize
File "mypy\nodes.py", line 3149, in serialize
File "mypy\nodes.py", line 3083, in serialize
AssertionError: Definition of alembic.runtime.migration.EnvironmentContext is unexpectedly incomplete
It seems a circular import issue. If I comment some of the import that are guarded by TYPE_CHECKING the crash disappears. This is of course not feasible, since it defeats the purpose of TYPE_CHECKING
Well the fix in alembic was a workaround for this issue of mypy.
The issue seems a circular import or something related to the import resolution, since the error was triggered by an import of a class from a module that re-exported it instead of the module defining it.
It may be worth looking into it from the mypy side, but I have no idea of how common this may be, so maybe it's not worth the effort, especially if there is a reliable way of fixing the issue
Activity
elpablete commentedon Sep 3, 2021
Having the same issue on my code, I really don't understand where and why, can someone shed some light?
elpablete commentedon Sep 3, 2021
mentioned in alembics repo: sqlalchemy/alembic#897
CaselIT commentedon Sep 6, 2021
I've tried to debug this a bit on alembic side: sqlalchemy/alembic#897 (comment)
It seems a circular import issue. If I comment some of the import that are guarded by
TYPE_CHECKINGthe crash disappears. This is of course not feasible, since it defeats the purpose ofTYPE_CHECKINGMorikko commentedon Oct 19, 2021
It looks like this could be closed as sqlalchemy/alembic#897 is closed and I confirm that with an upgrade to
alembic==1.7.4the crash disappeared.CaselIT commentedon Oct 19, 2021
Well the fix in alembic was a workaround for this issue of mypy.
The issue seems a circular import or something related to the import resolution, since the error was triggered by an import of a class from a module that re-exported it instead of the module defining it.
It may be worth looking into it from the mypy side, but I have no idea of how common this may be, so maybe it's not worth the effort, especially if there is a reliable way of fixing the issue
Fix crash involving explicit reexport, import cycle, wildcard (#11632)
Fix crash involving explicit reexport, import cycle, wildcard (#11632)
Fix crash involving explicit reexport, import cycle, wildcard (python…