Use a TypeVar for flatten_user to workaround Pyright bug

This commit is contained in:
Stocker 2022-07-25 21:18:52 -04:00 committed by GitHub
parent fb8d5c15d0
commit 3ee18e4c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,7 @@ import datetime
import inspect
import itertools
from operator import attrgetter
from typing import Any, Awaitable, Callable, Collection, Dict, List, Optional, TYPE_CHECKING, Tuple, Union, Type
from typing import Any, Awaitable, Callable, Collection, Dict, List, Optional, TYPE_CHECKING, Tuple, TypeVar, Union
import discord.abc
@ -48,6 +48,8 @@ __all__ = (
'Member',
)
T = TypeVar('T', bound=type)
if TYPE_CHECKING:
from typing_extensions import Self
@ -205,7 +207,7 @@ class _ClientStatus:
return self
def flatten_user(cls: Any) -> Type[Member]:
def flatten_user(cls: T) -> T:
for attr, value in itertools.chain(BaseUser.__dict__.items(), User.__dict__.items()):
# ignore private/special methods
if attr.startswith('_'):