KotlinIsland / basedmypy

Based Python static type checker with baseline, sane default settings and based typing features
Other
124 stars 4 forks source link

`BASEDMYPY_TYPE_CHECKING` variable #524

Closed DetachHead closed 4 days ago

DetachHead commented 9 months ago

it would be nice to have a variable like TYPE_CHECKING that's only true in basedmypy, so we can conditionally support based features while still supporting regular type checkers:

from basedtyping import BASEDMYPY_TYPE_CHECKING

if IS_BASEDMYPY:
    foo: Foo & Bar
else:
    foo: object

related: #37

KotlinIsland commented 9 months ago

Something like this?

BASEDMYPY: Literal[False] = False

If BASEDMYPY:
    A = B & C
else:
    A = object
> mypy --always-true BASEDMYPY
DetachHead commented 9 months ago

Yeah but it should be enabled by default

KotlinIsland commented 6 months ago

There is MYPY, can we close this issue?

DetachHead commented 6 months ago

nah, because not only does it not work at all, it also won't allow for conditionally defining stuff depending on whether you're using basedmypy or mypy, like in my example

KotlinIsland commented 3 weeks ago

What about we introduce BASEDMYPY, equivalent to MYPY?