indie-status-page/venv/lib/python3.11/site-packages/mypy/checker_state.py
IndieStatusBot 902133edd3 feat: indie status page MVP -- FastAPI + SQLite
- 8 DB models (services, incidents, monitors, subscribers, etc.)
- Full CRUD API for services, incidents, monitors
- Public status page with live data
- Incident detail page with timeline
- API key authentication
- Uptime monitoring scheduler
- 13 tests passing
- TECHNICAL_DESIGN.md with full spec
2026-04-25 05:00:00 +00:00

30 lines
858 B
Python

from __future__ import annotations
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Final
from mypy.checker_shared import TypeCheckerSharedApi
# This is global mutable state. Don't add anything here unless there's a very
# good reason.
class TypeCheckerState:
# Wrap this in a class since it's faster that using a module-level attribute.
def __init__(self, type_checker: TypeCheckerSharedApi | None) -> None:
# Value varies by file being processed
self.type_checker = type_checker
@contextmanager
def set(self, value: TypeCheckerSharedApi) -> Iterator[None]:
saved = self.type_checker
self.type_checker = value
try:
yield
finally:
self.type_checker = saved
checker_state: Final = TypeCheckerState(type_checker=None)