You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
base_configuration.is_valid_hint should allow TypeVar as a hint
Best would be to check whether the spec class is a generic with the same typevar and not allow unbound typevars.
E.g. this is fine:
class Incremental(BaseConfiguration, Generic[T]):
initial_value: Optional[T]
This is not
class Incremental(BaseConfiguration):
initial_value: Optional[T]
get_resolvable_fields when called on a concrete subclass or a generic alias, such as Incremental[str] or class SomeClass(Incremental[str])
Should match the typevar of the fields with the typevars on the generic base and return the concrete type for each field. There may be multiple generic types in the class.
When get_resolvable_fields is called on the generic baseclass, if typevars can't be mapped to concrete types, either:
Raise an exception -> force user to specify concrete type (may be breaking change)
Allow it but replace unmatched typevar hints with Any
Start with 2. but with deprecation warnings and change to 1. in later release
Testing
All existing tests should pass unchanged
Test generic with 1 and multiple typevars
Test generic baseclass as a config
Test subclass of a concrete type
The text was updated successfully, but these errors were encountered:
Currently we don't support
TypeVar
s in config fields, so generic types need to be definedAny
We should allow typevar hints on fields which are part of generic classes.
This would allow incremental config to be typed and validated correctly:
Implementation notes:
base_configuration.is_valid_hint
should allowTypeVar
as a hintBest would be to check whether the spec class is a generic with the same typevar and not allow unbound typevars.
E.g. this is fine:
This is not
get_resolvable_fields
when called on a concrete subclass or a generic alias, such asIncremental[str]
orclass SomeClass(Incremental[str])
Should match the typevar of the fields with the typevars on the generic base and return the concrete type for each field. There may be multiple generic types in the class.
When
get_resolvable_fields
is called on the generic baseclass, if typevars can't be mapped to concrete types, either:Any
Testing
The text was updated successfully, but these errors were encountered: