MCPcopy Index your code
hub / github.com/python/mypy / analyze_cond_branch

Method analyze_cond_branch

mypy/checkexpr.py:6055–6072  ·  view source on GitHub ↗
(
        self,
        map: dict[Expression, Type],
        node: Expression,
        context: Type | None,
        allow_none_return: bool = False,
        suppress_unreachable_errors: bool = True,
    )

Source from the content-addressed store, hash-verified

6053 return res
6054
6055 def analyze_cond_branch(
6056 self,
6057 map: dict[Expression, Type],
6058 node: Expression,
6059 context: Type | None,
6060 allow_none_return: bool = False,
6061 suppress_unreachable_errors: bool = True,
6062 ) -> Type:
6063 with self.chk.binder.frame_context(can_skip=True, fall_through=0):
6064 if mypy.checker.is_unreachable_map(map):
6065 # We still need to type check node, in case we want to
6066 # process it for isinstance checks later. Since the branch was
6067 # determined to be unreachable, any errors should be suppressed.
6068 with self.msg.filter_errors(filter_errors=suppress_unreachable_errors):
6069 self.accept(node, type_context=context, allow_none_return=allow_none_return)
6070 return UninhabitedType()
6071 self.chk.push_type_map(map)
6072 return self.accept(node, type_context=context, allow_none_return=allow_none_return)
6073
6074 def _combined_context(self, ty: Type | None) -> Type | None:
6075 ctx_items = []

Callers 3

check_boolean_opMethod · 0.95
visit_assert_stmtMethod · 0.80

Calls 5

acceptMethod · 0.95
UninhabitedTypeClass · 0.90
frame_contextMethod · 0.80
filter_errorsMethod · 0.80
push_type_mapMethod · 0.80

Tested by

no test coverage detected