mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
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))
15 lines
378 B
Python
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
|