module documentation

Utilities related to determining the reachability of code (in semantic analysis).

Class MarkImportsMypyOnlyVisitor Visitor that sets is_mypy_only (which affects priority).
Class MarkImportsUnreachableVisitor 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_pattern_value Undocumented
Function infer_reachability_of_if_statement Undocumented
Function infer_reachability_of_match_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
Type Variable Targ Undocumented
def assert_will_always_fail(s: AssertStmt, options: Options) -> bool: (source)

Undocumented

def consider_sys_platform(expr: Expression, platform: str) -> int: (source)

Consider whether expr is a comparison involving sys.platform. Return ALWAYS_TRUE, ALWAYS_FALSE, or TRUTH_VALUE_UNKNOWN.

def consider_sys_version_info(expr: Expression, pyversion: tuple[int, ...]) -> int: (source)

Consider whether expr is a comparison involving sys.version_info. Return ALWAYS_TRUE, ALWAYS_FALSE, or TRUTH_VALUE_UNKNOWN.

def contains_int_or_tuple_of_ints(expr: Expression) -> (None|int)|tuple[int, ...]: (source)

Undocumented

def contains_sys_version_info(expr: Expression) -> (None|int)|tuple[int|None, int|None]: (source)

Undocumented

def fixed_comparison(left: Targ, op: str, right: Targ) -> int: (source)

Undocumented

def infer_condition_value(expr: Expression, options: Options) -> int: (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.

def infer_pattern_value(pattern: Pattern) -> int: (source)

Undocumented

def infer_reachability_of_if_statement(s: IfStmt, options: Options): (source)

Undocumented

def infer_reachability_of_match_statement(s: MatchStmt, options: Options): (source)

Undocumented

def is_sys_attr(expr: Expression, name: str) -> bool: (source)

Undocumented

def mark_block_mypy_only(block: Block): (source)

Undocumented

def mark_block_unreachable(block: Block): (source)

Undocumented

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

Undocumented

Value
TypeVar('Targ', int, str, Tuple[int, ...])