module documentation
(source)

Utilities related to determining the reachability of code (in semantic analysis).
Class ​Mark​Imports​Mypy​Only​Visitor Visitor that sets is_mypy_only (which affects priority).
Class ​Mark​Imports​Unreachable​Visitor Visitor that flags all imports nested within a node as unreachable.
Function assert​_will​_always​_fail Undocumented
Function consider​_sys​_platform Consider whether expr is a comparison involving sys.platform.
Function consider​_sys​_version​_info Consider whether expr is a comparison involving sys.version_info.
Function contains​_int​_or​_tuple​_of​_ints Undocumented
Function contains​_sys​_version​_info Undocumented
Function fixed​_comparison Undocumented
Function infer​_condition​_value Infer whether the given condition is always true/false.
Function infer​_reachability​_of​_if​_statement Undocumented
Function is​_sys​_attr Undocumented
Function mark​_block​_mypy​_only Undocumented
Function mark​_block​_unreachable Undocumented
Constant ALWAYS​_FALSE Undocumented
Constant ALWAYS​_TRUE Undocumented
Constant inverted​_truth​_mapping Undocumented
Constant MYPY​_FALSE Undocumented
Constant MYPY​_TRUE Undocumented
Constant reverse​_op Undocumented
Constant TRUTH​_VALUE​_UNKNOWN Undocumented
Variable ​Targ Undocumented
def assert_will_always_fail(s, options): (source)

Undocumented

Parameters
s:AssertStmtUndocumented
options:OptionsUndocumented
Returns
boolUndocumented
def consider_sys_platform(expr, platform): (source)

Consider whether expr is a comparison involving sys.platform.

Return ALWAYS_TRUE, ALWAYS_FALSE, or TRUTH_VALUE_UNKNOWN.

Parameters
expr:ExpressionUndocumented
platform:strUndocumented
Returns
intUndocumented
def consider_sys_version_info(expr, pyversion): (source)

Consider whether expr is a comparison involving sys.version_info.

Return ALWAYS_TRUE, ALWAYS_FALSE, or TRUTH_VALUE_UNKNOWN.

Parameters
expr:ExpressionUndocumented
pyversion:Tuple[int, ...]Undocumented
Returns
intUndocumented
def contains_int_or_tuple_of_ints(expr): (source)

Undocumented

Parameters
expr:ExpressionUndocumented
Returns
Union[None, int, Tuple[int], Tuple[int, ...]]Undocumented
def contains_sys_version_info(expr): (source)

Undocumented

Parameters
expr:ExpressionUndocumented
Returns
Union[None, int, Tuple[Optional[int], Optional[int]]]Undocumented
def fixed_comparison(left, op, right): (source)

Undocumented

Parameters
left:TargUndocumented
op:strUndocumented
right:TargUndocumented
Returns
intUndocumented
def infer_condition_value(expr, options): (source)

Infer whether the given condition is always true/false.

Return ALWAYS_TRUE if always true, ALWAYS_FALSE if always false, MYPY_TRUE if true under mypy and false at runtime, MYPY_FALSE if false under mypy and true at runtime, else TRUTH_VALUE_UNKNOWN.

Parameters
expr:ExpressionUndocumented
options:OptionsUndocumented
Returns
intUndocumented
def infer_reachability_of_if_statement(s, options): (source)

Undocumented

Parameters
s:IfStmtUndocumented
options:OptionsUndocumented
def is_sys_attr(expr, name): (source)

Undocumented

Parameters
expr:ExpressionUndocumented
name:strUndocumented
Returns
boolUndocumented
def mark_block_mypy_only(block): (source)

Undocumented

Parameters
block:BlockUndocumented
def mark_block_unreachable(block): (source)

Undocumented

Parameters
block:BlockUndocumented
ALWAYS_FALSE: int = (source)

Undocumented

Value
3
ALWAYS_TRUE: int = (source)

Undocumented

Value
1
MYPY_FALSE: int = (source)

Undocumented

Value
4
MYPY_TRUE: int = (source)

Undocumented

Value
2
reverse_op: dict[str, str] = (source)

Undocumented

Value
{'==': '==', '!=': '!=', '<': '>', '>': '<', '<=': '>=', '>=': '<='}
TRUTH_VALUE_UNKNOWN: int = (source)

Undocumented

Value
5
Targ = (source)

Undocumented