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

Method visit_Import

mypy/fastparse.py:1408–1421  ·  view source on GitHub ↗
(self, n: ast3.Import)

Source from the content-addressed store, hash-verified

1406
1407 # Import(alias* names)
1408 def visit_Import(self, n: ast3.Import) -> Import:
1409 names: list[tuple[str, str | None]] = []
1410 for alias in n.names:
1411 name = self.translate_module_id(alias.name)
1412 asname = alias.asname
1413 if asname is None and name != alias.name:
1414 # if the module name has been translated (and it's not already
1415 # an explicit import-as), make it an implicit import-as the
1416 # original name
1417 asname = alias.name
1418 names.append((name, asname))
1419 i = Import(names)
1420 self.imports.append(i)
1421 return self.set_line(i, n)
1422
1423 # ImportFrom(identifier? module, alias* names, int? level)
1424 def visit_ImportFrom(self, n: ast3.ImportFrom) -> ImportBase:

Callers

nothing calls this directly

Calls 4

translate_module_idMethod · 0.95
set_lineMethod · 0.95
ImportClass · 0.90
appendMethod · 0.80

Tested by

no test coverage detected