Skip to content

Commit ab95493

Browse files
committed
Merge branch 'master' into v2.x
2 parents 6052537 + b82092c commit ab95493

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

discord/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
__author__ = "Pycord Development"
1414
__license__ = "MIT"
1515
__copyright__ = "Copyright 2015-2021 Rapptz & Copyright 2021-present Pycord Development"
16-
__version__ = "2.0.0b6"
16+
__version__ = "2.0.0b7"
1717

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

@@ -75,6 +75,6 @@ class VersionInfo(NamedTuple):
7575
serial: int
7676

7777

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

8080
logging.getLogger(__name__).addHandler(logging.NullHandler())

discord/enums.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,13 @@ def from_datatype(cls, datatype):
650650
else:
651651
raise TypeError("Invalid usage of typing.Union")
652652

653+
py_3_10_union_type = hasattr(types, "UnionType") and isinstance(datatype, types.UnionType)
654+
655+
if py_3_10_union_type or getattr(datatype, "__origin__", None) is Union:
656+
# Python 3.10+ "|" operator or typing.Union has been used. The __args__ attribute is a tuple of the types.
657+
# Type checking fails for this case, so ignore it.
658+
return cls.from_datatype(datatype.__args__) # type: ignore
659+
653660
if datatype.__name__ in ["Member", "User"]:
654661
return cls.user
655662
if datatype.__name__ in [
@@ -669,11 +676,6 @@ def from_datatype(cls, datatype):
669676
if datatype.__name__ == "Mentionable":
670677
return cls.mentionable
671678

672-
if isinstance(datatype, types.UnionType) or getattr(datatype, "__origin__", None) is Union:
673-
# Python 3.10+ "|" operator or typing.Union has been used. The __args__ attribute is a tuple of the types.
674-
# Type checking fails for this case, so ignore it.
675-
return cls.from_datatype(datatype.__args__) # type: ignore
676-
677679
if issubclass(datatype, str):
678680
return cls.string
679681
if issubclass(datatype, bool):

0 commit comments

Comments
 (0)