mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
This reverts commit81e370fc6b. 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, see73622fc5fa/1([comment](https://github.com/pytorch/pytorch/pull/142326#issuecomment-2614196349))
14 lines
378 B
Python
14 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
|