File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -483,13 +483,16 @@ def from_type(cls, t: type):
483483 if issubclass (t , discord .abc .Role ):
484484 return cls .ROLE
485485 # Here's the issue. Typechecking for a **Union** somewhat differs per version (from 3.6.8+)
486- if (
487- hasattr (typing , "_GenericAlias" )
488- and isinstance (t , typing ._UnionGenericAlias ) # noqa
489- or not hasattr (typing , "_GenericAlias" )
490- and isinstance (t , typing ._Union ) # noqa
491- ):
492- return cls .MENTIONABLE
486+
487+ if hasattr (typing , "_GenericAlias" ): # 3.7 onwards
488+ if isinstance (t , typing ._UnionGenericAlias ): # noqa
489+ return cls .MENTIONABLE # 3.9+
490+ elif t .__origin__ is typing .Union : # 3.7-3.8
491+ return cls .MENTIONABLE
492+ else : # py 3.6
493+ if isinstance (t , typing ._Union ): # noqa
494+ return cls .MENTIONABLE
495+
493496 if issubclass (t , float ):
494497 return cls .FLOAT
495498
You can’t perform that action at this time.
0 commit comments