def monkeypatch(extra_classes: Iterable[type] | None = None, include_builtins: bool = True) -> None:
    """Monkey patch django as necessary to work properly with mypy."""
    # Add the __class_getitem__ dunder.
    suited_for_this_version = filter(
        lambda spec: spec.version is None or VERSION[:2] <= spec.version,
        _get_need_generic(),
    )
    for el in suited_for_this_version:
        el.cls.__class_getitem__ = classmethod(lambda cls, *args, **kwargs: cls)
    if extra_classes:
        for cls in extra_classes:
            cls.__class_getitem__ = classmethod(lambda cls, *args, **kwargs: cls)  # type: ignore[attr-defined]

    # Add `reveal_type` and `reveal_locals` helpers if needed:
    if include_builtins:
        builtins.reveal_type = lambda _: None
        builtins.reveal_locals = lambda: None
Monkey patch django as necessary to work properly with mypy.
ext/django_stubs_ext/patch.py