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
When using the new Python-compatible syntax, the issue is that we do not detect invalid circular imports statically. This is a potential new feature -- updated labels accordingly.
Yeah, circular imports are pretty common in larger programs (even mypy has several). Some circular imports cause the program to always fail, and mypy could detect some of these. I'll edit the title to be less confusing.
@JukkaL in my driver PR I remove all the circular imports I think. They are only needed for typechecking (i.e. in string-quoted types), not actually running mypy.
The workaround I use is if False: import mypy.foo. Any fix that mypy forms should take this into account.
Activity
JukkaL commentedon Jun 27, 2013
When using the new Python-compatible syntax, the issue is that we do not detect invalid circular imports statically. This is a potential new feature -- updated labels accordingly.
[-]Circular imports cause invalid python to be generated[/-][+]Circular imports are not rejected[/+]o11c commentedon Jul 14, 2015
Circular imports are valid somtimes, but mypy is buggy, I hit this in #721
JukkaL commentedon Jul 26, 2015
Yeah, circular imports are pretty common in larger programs (even mypy has several). Some circular imports cause the program to always fail, and mypy could detect some of these. I'll edit the title to be less confusing.
[-]Circular imports are not rejected[/-][+]Bad circular imports are not rejected[/+]o11c commentedon Jul 26, 2015
@JukkaL in my
driverPR I remove all the circular imports I think. They are only needed for typechecking (i.e. in string-quoted types), not actually running mypy.The workaround I use is
if False: import mypy.foo. Any fix that mypy forms should take this into account.JukkaL commentedon Jul 26, 2015
@o11c I saw that and it's a pretty neat trick. Alternatively, we could define a constant such as
MYPYthat is alwaysFalseand do something like this:The if statement trick also supports
from ... import, unlike a real circular import:It may be worth it to describe this in mypy documentation.
Also, mypy could complain if a type imported as above is used without literal escapes.
dosisod commentedon May 4, 2020
Instead of a
MYPYconstant, we can use TYPE_CHECKING:mahmoudajawad commentedon Dec 25, 2020
JelleZijlstra commentedon Dec 28, 2020
hauntsaninja commentedon Dec 28, 2020
mahmoudajawad commentedon Dec 28, 2020
mahmoudajawad commentedon Dec 29, 2020
JelleZijlstra commentedon Dec 29, 2020