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

Method declare_global

mypyc/codegen/emitmodule.py:1494–1508  ·  view source on GitHub ↗
(
        self, type_spaced: str, name: str, *, initializer: str | None = None
    )

Source from the content-addressed store, hash-verified

1492 return result
1493
1494 def declare_global(
1495 self, type_spaced: str, name: str, *, initializer: str | None = None
1496 ) -> None:
1497 if "[" not in type_spaced:
1498 base = f"{type_spaced}{name}"
1499 else:
1500 a, b = type_spaced.split("[", 1)
1501 base = f"{a}{name}[{b}"
1502
1503 if not initializer:
1504 defn = None
1505 else:
1506 defn = [f"{base} = {initializer};"]
1507 if name not in self.context.declarations:
1508 self.context.declarations[name] = HeaderDeclaration(f"{base};", defn=defn)
1509
1510 def declare_internal_globals(self, module_name: str, emitter: Emitter) -> None:
1511 static_name = emitter.static_name("globals", module_name)

Callers 3

declare_moduleMethod · 0.95

Calls 2

HeaderDeclarationClass · 0.90
splitMethod · 0.80

Tested by

no test coverage detected