Skip to content
Discussion options

You must be logged in to vote

According to the Python typing spec, a type variable is valid only when used in the context of a "def", "class" or type alias declaration. It must be associated with one of those scopes and has no meaning if used otherwise. That's why you're seeing the error here.

I'm not sure what your intent is here. Do you mean for the Parameter class to be generic and parameterized by the type variable?

@dataclass
class Parameter(Generic[ValidatorRetType]):
    name: str
    validate: Callable[[str, str], ValidatorRetType]
    value: ValidatorRetType = field(init=False)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@erictraut
Comment options

Answer selected by erictraut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants