## Summary Resolves #15695, rework of #15704. This change modifies the Mdtests framework so that: * Paths must now be specified in a separate preceding line: `````markdown `a.py`: ```py x = 1 ``` ````` If the path of a file conflicts with its `lang`, an error will be thrown. * Configs are no longer accepted. The pattern still take them into account, however, to avoid "Unterminated code block" errors. * Unnamed files are now assigned unique, `lang`-respecting paths automatically. Additionally, all legacy usages have been updated. ## Test Plan Unit tests and Markdown tests. --------- Co-authored-by: Carl Meyer <carl@astral.sh>
1.1 KiB
1.1 KiB
Known constants
typing.TYPE_CHECKING
This constant is True when in type-checking mode, False otherwise. The symbol is defined to be
False at runtime. In typeshed, it is annotated as bool. This test makes sure that we infer
Literal[True] for it anyways.
Basic
from typing import TYPE_CHECKING
import typing
reveal_type(TYPE_CHECKING) # revealed: Literal[True]
reveal_type(typing.TYPE_CHECKING) # revealed: Literal[True]
Aliased
Make sure that we still infer the correct type if the constant has been given a different name:
from typing import TYPE_CHECKING as TC
reveal_type(TC) # revealed: Literal[True]
Must originate from typing
Make sure we only use our special handling for typing.TYPE_CHECKING and not for other constants
with the same name:
constants.py:
TYPE_CHECKING: bool = False
from constants import TYPE_CHECKING
reveal_type(TYPE_CHECKING) # revealed: bool
typing_extensions re-export
This should behave in the same way as typing.TYPE_CHECKING:
from typing_extensions import TYPE_CHECKING
reveal_type(TYPE_CHECKING) # revealed: Literal[True]