diff --git a/httpx/__init__.py b/httpx/__init__.py index e9addde071..1b61fc4f1a 100644 --- a/httpx/__init__.py +++ b/httpx/__init__.py @@ -102,4 +102,9 @@ def main() -> None: # type: ignore __locals = locals() for __name in __all__: if not __name.startswith("__"): - setattr(__locals[__name], "__module__", "httpx") # noqa + try: + setattr(__locals[__name], "__module__", "httpx") # noqa + except AttributeError: # pragma: no cover + # typing.Union instances are immutable in Python 3.14+, + # so don't fail if writing to "__module__" fails + continue # pragma: no cover