basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

`BASEDMYPY_TYPE_CHECKING` variable

Open DetachHead opened this issue 2 years ago • 4 comments

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

DetachHead avatar Oct 01 '23 00:10 DetachHead

Something like this?

BASEDMYPY: Literal[False] = False

If BASEDMYPY:
    A = B & C
else:
    A = object
> mypy --always-true BASEDMYPY

KotlinIsland avatar Oct 01 '23 01:10 KotlinIsland

Yeah but it should be enabled by default

DetachHead avatar Oct 01 '23 04:10 DetachHead

There is MYPY, can we close this issue?

KotlinIsland avatar Jan 19 '24 01:01 KotlinIsland

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

DetachHead avatar Jan 19 '24 01:01 DetachHead

What about we introduce BASEDMYPY, equivalent to MYPY?

KotlinIsland avatar Jun 21 '24 00:06 KotlinIsland