-
Notifications
You must be signed in to change notification settings - Fork 49
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
style[next]: improve typing in next.type_translation #1493
Conversation
else: | ||
type_ = xtyping.infer_type(value, annotate_callable_kwargs=True) | ||
symbol_type = from_type_hint(type_) | ||
|
||
if isinstance(symbol_type, (ts.DataType, ts.CallableType, ts.OffsetType, ts.DimensionType)): | ||
if isinstance( | ||
symbol_type, (ts.DataType, ts.CallableType, ts.OffsetType, ts.DimensionType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CallableType is not a TypeSpec. this looks like a bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CallableType is a mixin and all subtypes of it are a TypeSpec. Maybe we should rename it to something like CallableTypeMixin
. If you want it to be 100% correct maybe isinstance(symbol_type, ts.CallableType) and isinstance(symbol_type, ts.TypeSpec)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed by isinstance(symbol_type, ts.CallableType) and isinstance(symbol_type, ts.TypeSpec)
@@ -66,7 +67,7 @@ def from_type_hint( | |||
localns: Optional[dict[str, Any]] = None, | |||
) -> ts.TypeSpec: | |||
recursive_make_symbol = functools.partial(from_type_hint, globalns=globalns, localns=localns) | |||
extra_args = () | |||
extra_args: list = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: What is the type in the list? type
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's filled from typing.get_args
which returns Any
, could add additional checks, but thought better than before.
No description provided.