basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

understand that imports within `TYPE_CHECKING` shouldn't be used in runtime positions

Open KotlinIsland opened this issue 1 year ago • 1 comments

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    import sys

sys  # expect error: sys is imported as type only
  • related #166 It's kinda a half measure of fixing it

BTW, ruff does handle this

KotlinIsland avatar Jan 16 '24 04:01 KotlinIsland

I wonder if there is any use case where you want to type checker to think something is imported because at runtime it actually is imported.

It should be a config options then.

KotlinIsland avatar Jun 15 '24 08:06 KotlinIsland