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

Function generate_guarded

mypy/stubutil.py:138–157  ·  view source on GitHub ↗

Ignore or report errors during stub generation. Optionally report success.

(
    mod: str, target: str, ignore_errors: bool = True, verbose: bool = False
)

Source from the content-addressed store, hash-verified

136
137@contextmanager
138def generate_guarded(
139 mod: str, target: str, ignore_errors: bool = True, verbose: bool = False
140) -> Iterator[None]:
141 """Ignore or report errors during stub generation.
142
143 Optionally report success.
144 """
145 if verbose:
146 print(f"Processing {mod}")
147 try:
148 yield
149 except Exception as e:
150 if not ignore_errors:
151 raise e
152 else:
153 # --ignore-errors was passed
154 print("Stub generation failed for", mod, file=sys.stderr)
155 else:
156 if verbose:
157 print(f"Created {target}")
158
159
160def report_missing(mod: str, message: str | None = "", traceback: str = "") -> None:

Callers 1

generate_stubsFunction · 0.90

Calls 1

printFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…