[BE]: Update Typeguard to TypeIs for better type inference (#133814)

Uses TypeIs instead of TypeGuard for better inference. See https://peps.python.org/pep-0742/

Pull Request resolved: https://github.com/pytorch/pytorch/pull/133814
Approved by: https://github.com/ezyang
This commit is contained in:
Aaron Gokaslan
2024-08-18 19:10:14 +00:00
committed by PyTorch MergeBot
parent 0d4cedaa47
commit cf60fe53a8
9 changed files with 24 additions and 24 deletions

View File

@ -4,7 +4,7 @@ import contextlib
import warnings
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Set, Union, Protocol, Tuple, Sequence, overload, Deque
from typing_extensions import TypeGuard
from typing_extensions import TypeIs
from collections import deque
import torch
@ -354,7 +354,7 @@ class TensorWithFlatten(Protocol):
def is_traceable_wrapper_subclass(t: object) -> TypeGuard[TensorWithFlatten]:
def is_traceable_wrapper_subclass(t: object) -> TypeIs[TensorWithFlatten]:
"""
Returns whether or not a tensor subclass that implements __torch_dispatch__
is 'traceable' with torch.compile.