remove collection from typing collections (#13943)
Fixes #13923
Summary of the issue:
Performing type checks for collections fail
The following code raises an error when FlagValueEnum is defined as
FlagValueEnum(enum.EnumMeta, _DisplayStringEnumMixin, FeatureFlagEnumProtocol): pass
In the NVDA python console
>>>import collections.abc
>>>isinstance(12, collections.abc.Sized)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Users\sean\AppData\Local\Programs\Python\Python37-32\lib\abc.py", line 139, in __instancecheck__
return _abc_instancecheck(cls, instance)
File "C:\Users\sean\AppData\Local\Programs\Python\Python37-32\lib\abc.py", line 143, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
File "C:\Users\sean\AppData\Local\Programs\Python\Python37-32\lib\abc.py", line 143, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
File "C:\Users\sean\AppData\Local\Programs\Python\Python37-32\lib\abc.py", line 143, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
[Previous line repeated 1 more time]
TypeError: descriptor '__subclasses__' of 'type' object needs an argument
Description of user facing changes
API is fixed for performing type checks in collections.
Description of development approach
Removing typing.Collection or enum.EnumMeta from the MRO both resolve the python console / API bug.
As a result, I assume the bug is some sort of class conflict between typing.Collection and enum.EnumMeta .
We could resolve this by creating a metaclass.
However, I believe the already included EnumMeta class should cover what we wanted in type hinting typing.Collection.
The EnumMeta metaclass is responsible for providing the __contains__(), __dir__(), __iter__() and other methods that allow one to do things with an Enum class that fail on a typical class, such as list(Color) or some_enum_var in Color. EnumMeta is responsible for ensuring that various other methods on the final Enum class are correct (such as __new__(), __getnewargs__(), __str__() and __repr__()).
https://docs.python.org/3/library/enum.html#enum-classes.