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

Method visit_block

mypy/checker.py:3256–3277  ·  view source on GitHub ↗
(self, b: Block)

Source from the content-addressed store, hash-verified

3254 #
3255
3256 def visit_block(self, b: Block) -> None:
3257 if b.is_unreachable:
3258 # This block was marked as being unreachable during semantic analysis.
3259 # It turns out any blocks marked in this way are *intentionally* marked
3260 # as unreachable -- so we don't display an error.
3261 self.binder.unreachable()
3262 return
3263 marked_unreachable = False
3264 for s in b.body:
3265 if self.binder.is_unreachable():
3266 if self.scope.top_level_function() is None and not marked_unreachable:
3267 self.mark_unreachable(b.body, after=s)
3268 marked_unreachable = True
3269 if not self.should_report_unreachable_issues():
3270 break
3271 if not self.is_noop_for_reachability(s):
3272 self.msg.unreachable_statement(s)
3273 break
3274 else:
3275 self.accept(s)
3276 # Clear expression cache after each statement to avoid unlimited growth.
3277 self.expr_checker.expr_cache.clear()
3278
3279 def should_report_unreachable_issues(self) -> bool:
3280 return (

Callers

nothing calls this directly

Calls 9

mark_unreachableMethod · 0.95
acceptMethod · 0.95
unreachableMethod · 0.80
is_unreachableMethod · 0.80
top_level_functionMethod · 0.80
unreachable_statementMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected