[New-bugs-announce] [issue44922] isinstance breaks on imported dataclasses
Oleg Baskakov
report at bugs.python.org
Sun Aug 15 18:19:35 EDT 2021
New submission from Oleg Baskakov <baskakov at google.com>:
Hey I was trying to import dataclasses from another file and somehow isinstance doesn't work anymore:
main.py:
```
import codegen
from dataclasses import dataclass
@dataclass
class AtomX:
my_symbol: str
quantity: str = ""
codegen.inheritance_map(AtomX("qwerty"))
```
codegen.py:
```
from main import AtomX
def inheritance_map(candidate):
assert isinstance(candidate, AtomX)
```
PS the same code with `assert candidate.__class__.__name__ == "AtomX"` works fine
----
Python 3.9.6 (v3.9.6:db3ff76da1, Jun 28 2021, 11:49:53)
[Clang 6.0 (clang-600.0.57)] on darwin
I'm running inside of PyCharm
----------
messages: 399628
nosy: baskakov
priority: normal
severity: normal
status: open
title: isinstance breaks on imported dataclasses
type: behavior
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44922>
_______________________________________
More information about the New-bugs-announce
mailing list