Mypy: Add "dummy import" to avoid cyclic import

Created on 31 May 2016  路  2Comments  路  Source: python/mypy

If I simply want to import some classes to make proper type annotations, why should I deal with cyclic import issue? Cuz, the code involved is kind of "useless" i.e. deletion would not change anything.

So, I proposal that we can have a special mechanism, like from a import A as A.

Do you see the point? import A as A, which is totally meaningless. Anyone who has a brain would not do it and the interpreter will know this import is just for type annotations.

The change is fairly trivial.

Most helpful comment

You can do this by using 'if False: import...'

All 2 comments

You can do this by using 'if False: import...'

That is even simpler. I am pretty sure that many people do not know it.

Was this page helpful?
0 / 5 - 0 ratings