Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
torch / utils / _typing_utils.py
Size: Mime:
"""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