This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Can not add a metclass that inherits both ABCMeta & ABC to a Union
Type: Stage:
Components: Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ajoino, andrei.avk, erezinman
Priority: normal Keywords:

Created on 2021-03-22 13:53 by erezinman, last changed 2022-04-11 14:59 by admin.

Messages (4)
msg389317 - (view) Author: Erez Zinman (erezinman) Date: 2021-03-22 13:53
Related to Issue #43594.

When running the following code

```
from abc import ABCMeta, ABC
from typing import Union

class MetaclassMixin(ABC):
    pass 

class Meta(MetaclassMixin, ABCMeta):
    pass

print(Union[str, Meta])
```

An exception is raised

 >>> TypeError: descriptor '__subclasses__' of 'type' object needs an argument


Tested on v3.6.9
msg389320 - (view) Author: Erez Zinman (erezinman) Date: 2021-03-22 14:14
This is actually a lot worse and unrelated to the aforementioned issue.

The code 

```
from typing import Union
from abc import ABC


Union[str, ABC]
```

raises the exception

 >>> TypeError: descriptor '__subclasses__' of 'type' object needs an argument
msg389412 - (view) Author: Jacob Nilsson (ajoino) Date: 2021-03-23 22:00
Hi, I tried both code snippets, and they work for me with the output:

    typing.Union[str, abc.ABC]

For your second code snippet.

Tested on 3.7.6 (IPython though) on a Windows machine, can test it on Linux tomorrow.
msg396701 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-06-29 04:53
Works for me, too - no error (MacOS, 3.9.1)
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87761
2021-06-29 04:53:58andrei.avksetnosy: + andrei.avk
messages: + msg396701
2021-03-23 22:00:53ajoinosetnosy: + ajoino
messages: + msg389412
2021-03-22 14:14:35erezinmansetmessages: + msg389320
2021-03-22 13:53:50erezinmancreate