Files
pytorch/torch/utils/_typing_utils.py
PyTorch MergeBot 09ae69a364 Revert "Fix type annotation of Linear.bias (#142326)"
This reverts commit 81e370fc6b90f9cb98c88f3173e738aba0dc650a.

Reverted https://github.com/pytorch/pytorch/pull/142326 on behalf of https://github.com/malfet due to This introduced a graph break and regressed inductor tests, see 73622fc5fa/1 ([comment](https://github.com/pytorch/pytorch/pull/142326#issuecomment-2614196349))
2025-01-26 03:41:00 +00:00

15 lines
378 B
Python

"""Miscellaneous utilities to aid with typing."""
from typing import Optional, TypeVar
# Helper to turn Optional[T] into T when we know None either isn't
# possible or should trigger an exception.
T = TypeVar("T")
def not_none(obj: Optional[T]) -> T:
if obj is None:
raise TypeError("Invariant encountered: value was None when it should not be")
return obj