mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
remove allow-untyped-defs from torch/_classes.py (#157231)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157231 Approved by: https://github.com/jingsh
This commit is contained in:
committed by
PyTorch MergeBot
parent
be56a8d7ac
commit
9d8cf24b3b
@ -1,15 +1,15 @@
|
||||
# mypy: allow-untyped-defs
|
||||
import types
|
||||
from typing import Any
|
||||
|
||||
import torch._C
|
||||
|
||||
|
||||
class _ClassNamespace(types.ModuleType):
|
||||
def __init__(self, name):
|
||||
def __init__(self, name: str) -> None:
|
||||
super().__init__("torch.classes" + name)
|
||||
self.name = name
|
||||
|
||||
def __getattr__(self, attr):
|
||||
def __getattr__(self, attr: str) -> Any:
|
||||
proxy = torch._C._get_custom_class_python_wrapper(self.name, attr)
|
||||
if proxy is None:
|
||||
raise RuntimeError(f"Class {self.name}.{attr} not registered!")
|
||||
@ -22,16 +22,16 @@ class _Classes(types.ModuleType):
|
||||
def __init__(self) -> None:
|
||||
super().__init__("torch.classes")
|
||||
|
||||
def __getattr__(self, name):
|
||||
def __getattr__(self, name: str) -> _ClassNamespace:
|
||||
namespace = _ClassNamespace(name)
|
||||
setattr(self, name, namespace)
|
||||
return namespace
|
||||
|
||||
@property
|
||||
def loaded_libraries(self):
|
||||
def loaded_libraries(self) -> Any:
|
||||
return torch.ops.loaded_libraries
|
||||
|
||||
def load_library(self, path):
|
||||
def load_library(self, path: str) -> None:
|
||||
"""
|
||||
Loads a shared library from the given path into the current process.
|
||||
|
||||
|
Reference in New Issue
Block a user