Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not add a metclass that inherits both ABCMeta & ABC to a Union #87761

Closed
erezinman mannequin opened this issue Mar 22, 2021 · 5 comments
Closed

Can not add a metclass that inherits both ABCMeta & ABC to a Union #87761

erezinman mannequin opened this issue Mar 22, 2021 · 5 comments

Comments

@erezinman
Copy link
Mannequin

erezinman mannequin commented Mar 22, 2021

BPO 43595
Nosy @erezinman, @akulakov, @ajoino

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-03-22.13:53:50.445>
labels = []
title = 'Can not add a metclass that inherits both ABCMeta & ABC to a Union'
updated_at = <Date 2021-06-29.04:53:58.304>
user = 'https://github.com/erezinman'

bugs.python.org fields:

activity = <Date 2021-06-29.04:53:58.304>
actor = 'andrei.avk'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2021-03-22.13:53:50.445>
creator = 'erezinman'
dependencies = []
files = []
hgrepos = []
issue_num = 43595
keywords = []
message_count = 4.0
messages = ['389317', '389320', '389412', '396701']
nosy_count = 3.0
nosy_names = ['erezinman', 'andrei.avk', 'ajoino']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue43595'
versions = ['Python 3.6']

@erezinman
Copy link
Mannequin Author

erezinman mannequin commented Mar 22, 2021

Related to Issue bpo-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

@erezinman
Copy link
Mannequin Author

erezinman mannequin commented Mar 22, 2021

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

@ajoino
Copy link
Mannequin

ajoino mannequin commented Mar 23, 2021

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.

@akulakov
Copy link
Contributor

Works for me, too - no error (MacOS, 3.9.1)

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@AlexWaygood
Copy link
Member

I can reproduce the first snippet on 3.6.1, but cannot reproduce either snippet on 3.9+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants