[issue45326] Unexpected TypeError with type alias+issubclass+ABC

2022-02-27 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
nosy: +kj
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45326] Unexpected TypeError with type alias+issubclass+ABC

2022-02-27 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

This error was added in https://bugs.python.org/issue33018 . See some 
discussion on that issue.

Note that first arg needs to be a type (i.e. instance of `type`) to avoid this 
error:

[ins] In [41]: class C(ABC):0

[ins] In [42]: issubclass(dict, C)
Out[42]: False

[ins] In [43]: issubclass('', C)  # TypeError: issubclass() arg 1 must be a 
class

[ins] In [44]: issubclass(typing.Dict, C)   # same error as above

--
nosy: +andrei.avk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45326] Unexpected TypeError with type alias+issubclass+ABC

2022-02-23 Thread burrito


Change by burrito :


--
nosy: +burrito

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45326] Unexpected TypeError with type alias+issubclass+ABC

2021-09-29 Thread Dong-hee Na


Change by Dong-hee Na :


--
versions: +Python 3.10, Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45326] Unexpected TypeError with type alias+issubclass+ABC

2021-09-29 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45326] Unexpected TypeError with type alias+issubclass+ABC

2021-09-29 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45326] Unexpected TypeError with type alias+issubclass+ABC

2021-09-29 Thread Dmitry Marakasov


New submission from Dmitry Marakasov :

Here's a curious problem. issubclass() check of a type against an ABC-derived 
class raises TypeError claiming that type is not a class, however 
inspect.isclass() says it's a class, and issubclass() check against a simple 
class works fine:

```
from abc import ABC

class C1:
pass

issubclass(dict[str, str], C1)  # False

class C2(ABC):
pass

issubclass(dict[str, str], C2)  # TypeError: issubclass() arg 1 must be a class
```

I've ran into this problem while using `inspect` module to look for subclasses 
of a specific ABC in a module which may also contain type aliases, and after 
converting a type alias from `Dict[str, str]` to modern `dict[str, str]` I've 
got an unexpected crash in this code:

if inspect.isclass(member) and issubclass(member, superclass):

Not sure which is the culprit, ABC or how dict[]-style type aliases are 
implemented.

--
components: Library (Lib)
messages: 402914
nosy: AMDmi3
priority: normal
severity: normal
status: open
title: Unexpected TypeError with type alias+issubclass+ABC
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com