Skip to content
Discussion options

You must be logged in to vote

Lol and I found the solution on my own again.

from typing import TYPE_CHECKING, TypeAliasType, TypeAlias

if TYPE_CHECKING:
    from bear.bear_doubly_forward_a import A
else:
    A: TypeAlias = TypeAliasType("A", "bear.bear_doubly_forward_a.A")

class B:
    def __init__(self, inner: list[A | None]):
        self.inner = inner

Learned this trick from #562 (comment)

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Glinte
Comment options

You must be logged in to vote
5 replies
@Glinte
Comment options

@leycec
Comment options

@Glinte
Comment options

@leycec
Comment options

@Glinte
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants