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

Method semantic_analysis_pass1

mypy/build.py:3305–3338  ·  view source on GitHub ↗

Perform pass 1 of semantic analysis, which happens immediately after parsing. This pass can't assume that any other modules have been processed yet.

(self)

Source from the content-addressed store, hash-verified

3303 )
3304
3305 def semantic_analysis_pass1(self) -> None:
3306 """Perform pass 1 of semantic analysis, which happens immediately after parsing.
3307
3308 This pass can't assume that any other modules have been processed yet.
3309 """
3310 options = self.options
3311 assert self.tree is not None
3312
3313 t0 = time_ref()
3314
3315 # Do the first pass of semantic analysis: analyze the reachability
3316 # of blocks and import statements. We must do this before
3317 # processing imports, since this may mark some import statements as
3318 # unreachable.
3319 #
3320 # TODO: This should not be considered as a semantic analysis
3321 # pass -- it's an independent pass.
3322 if not options.native_parser or not self.manager.fscache.exists(
3323 self.xpath, real_only=True
3324 ):
3325 analyzer = SemanticAnalyzerPreAnalysis()
3326 with self.wrap_context():
3327 analyzer.visit_file(self.tree, self.xpath, self.id, options)
3328 # TODO: Do this while constructing the AST?
3329 self.tree.names = SymbolTable()
3330 if not self.tree.is_stub:
3331 if not self.options.allow_redefinition:
3332 # Perform some low-key variable renaming when assignments can't
3333 # widen inferred types
3334 self.tree.accept(LimitedVariableRenameVisitor())
3335 if options.allow_redefinition_old:
3336 # Perform more renaming across the AST to allow variable redefinitions
3337 self.tree.accept(VariableRenameVisitor())
3338 self.time_spent_us += time_spent_us(t0)
3339
3340 def add_dependency(self, dep: str) -> None:
3341 if dep not in self.dependencies_set:

Callers 2

parse_fileMethod · 0.95
parse_parallelMethod · 0.80

Calls 9

wrap_contextMethod · 0.95
visit_fileMethod · 0.95
SymbolTableClass · 0.90
time_spent_usFunction · 0.90
existsMethod · 0.80
acceptMethod · 0.45

Tested by

no test coverage detected