Skip to content

Fix failure to identify an unresolvable classvar in PEP-649 annotations.#121

Merged
DavidCEllis merged 3 commits into
mainfrom
fix-unresolvable-classvar
Jul 9, 2026
Merged

Fix failure to identify an unresolvable classvar in PEP-649 annotations.#121
DavidCEllis merged 3 commits into
mainfrom
fix-unresolvable-classvar

Conversation

@DavidCEllis

Copy link
Copy Markdown
Owner

Fixes an issue where an annotation that could not resolve as a ForwardRef would not be correctly identified as a ClassVar.

This could be an issue if typing aliases were ever removed for instance. This example would previously fail to detect CV as a ClassVar as the AttributeError causes the annotation to become an opaque forward reference.

Using reannotate this now correctly extracts and evaluates the ClassVar.

import typing as t
from ducktools.classbuilder.prefab import prefab

@prefab
class Example:
    CV: t.ClassVar[t.RemovedAlias] = ['a']

@DavidCEllis DavidCEllis merged commit 6949fc2 into main Jul 9, 2026
6 checks passed
@DavidCEllis DavidCEllis deleted the fix-unresolvable-classvar branch July 9, 2026 11:39
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 this pull request may close these issues.

1 participant