Browse Source

Use a TypeVar for flatten_user to workaround Pyright bug

pull/8272/head
Stocker 3 years ago
committed by GitHub
parent
commit
3ee18e4c5d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      discord/member.py

6
discord/member.py

@ -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('_'):

Loading…
Cancel
Save