-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Annotated[Any, ...] #12757
Comments
@orenbenkiki |
@Viicos - Thanks, I'll look into it. The point still stands; it seems that |
Other than that I find your implementation pretty neat, I don't recall seeing this anywhere. Maybe you could even get rid of the SeriesOfBool = Annotated[pandas.Series, "bool"]
def is_series_of_bool(series: pandas.Series) -> TypeGuard[SeriesOfBool]:
return series.dtype == "bool" Needs to be tested ;) |
I'm not sure what NewType of Any is meant to do. If you want an opaque new type, you should make a NewType of object. Annotated[T, ...] is usually exactly the same as T; I don't think it works how you think it works. From PEP 593:
|
Feature
Id like to be able to write:
Pitch
I would dearly love to track the data type of the many series values floating around my code. The above seems like a reasonable approach., which seems to work fine if I define
ArrayOfBool = NewType("ArrayOfBool", Annotated[numpy.ndarray, "bool"])
.However because
pandas
has no type annotations, thenpandas.Series
is essentiallyAny
and trying the above gives the errorArgument 2 to NewType(...) must be subclassable (got "Any")
.It seems like
Annotated[Any, ...]
shouldn't be the same asAny
- in particular, not all values belong to the annotated type - so this error is over conservative?The text was updated successfully, but these errors were encountered: