Skip to content

Commit

Permalink
Merge branch 'master' into v2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDotCom committed Apr 9, 2022
2 parents 6052537 + b82092c commit ab95493
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__author__ = "Pycord Development"
__license__ = "MIT"
__copyright__ = "Copyright 2015-2021 Rapptz & Copyright 2021-present Pycord Development"
__version__ = "2.0.0b6"
__version__ = "2.0.0b7"

__path__ = __import__("pkgutil").extend_path(__path__, __name__)

Expand Down Expand Up @@ -75,6 +75,6 @@ class VersionInfo(NamedTuple):
serial: int


version_info: VersionInfo = VersionInfo(major=2, minor=0, micro=0, releaselevel="beta", serial=6)
version_info: VersionInfo = VersionInfo(major=2, minor=0, micro=0, releaselevel="beta", serial=7)

logging.getLogger(__name__).addHandler(logging.NullHandler())
12 changes: 7 additions & 5 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,13 @@ def from_datatype(cls, datatype):
else:
raise TypeError("Invalid usage of typing.Union")

py_3_10_union_type = hasattr(types, "UnionType") and isinstance(datatype, types.UnionType)

if py_3_10_union_type or getattr(datatype, "__origin__", None) is Union:
# Python 3.10+ "|" operator or typing.Union has been used. The __args__ attribute is a tuple of the types.
# Type checking fails for this case, so ignore it.
return cls.from_datatype(datatype.__args__) # type: ignore

if datatype.__name__ in ["Member", "User"]:
return cls.user
if datatype.__name__ in [
Expand All @@ -669,11 +676,6 @@ def from_datatype(cls, datatype):
if datatype.__name__ == "Mentionable":
return cls.mentionable

if isinstance(datatype, types.UnionType) or getattr(datatype, "__origin__", None) is Union:
# Python 3.10+ "|" operator or typing.Union has been used. The __args__ attribute is a tuple of the types.
# Type checking fails for this case, so ignore it.
return cls.from_datatype(datatype.__args__) # type: ignore

if issubclass(datatype, str):
return cls.string
if issubclass(datatype, bool):
Expand Down

0 comments on commit ab95493

Please sign in to comment.