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

attr.resolve_types caches badly with inheritence #842

Closed
A5rocks opened this issue Sep 19, 2021 · 1 comment · Fixed by #843
Closed

attr.resolve_types caches badly with inheritence #842

A5rocks opened this issue Sep 19, 2021 · 1 comment · Fixed by #843

Comments

@A5rocks
Copy link

A5rocks commented Sep 19, 2021

Reproduction case:

from __future__ import annotations

import attr

@attr.define()
class A:
  n: int

@attr.define()
class B(A):
  pass

attr.resolve_types(A)
attr.resolve_types(B)

print(attr.fields(B))

I believe this is because B is somehow inheriting A's __attrs_types_resolved__, even though it gets set later -- which means that it never had its types resolved, but it thinks it has.

This came up when I was using cattrs (I raised an issue there about a trouble I had debugging too :^), which means I do not control the resolution order of types without applying a attr.resolve_types decorator to every class (which might not work -- I'm not sure all my class declarations are in order either...)

@euresti
Copy link
Contributor

euresti commented Sep 19, 2021

Oh. This is a good one. Thanks for the report. I'll get a fix in soon.

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

Successfully merging a pull request may close this issue.

2 participants