-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Fix issue for pandera allowing generic Series to work #492
Conversation
index: Axes | None = ..., | ||
dtype=..., | ||
name: Hashable | None = ..., | ||
copy: bool = ..., | ||
fastpath: bool = ..., | ||
) -> Series[IntervalT]: ... | ||
) -> Series[Interval[int]]: ... | ||
@overload |
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.
might be nice to add a TODO referencing the mypy issue
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.
might be nice to add a TODO referencing the mypy issue
I didn't research whether there exists a mypy issue, or how to create a small sample to replicate.
I could add a comment indicating that we prefer the Series[IntervalT]
notation, but that it doesn't seem to work and reference the original pandas-stubs issue. Let me know if I should do that.
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.
Would something like the following work?
T = TypeVar("T", float, int, Timestamp, Timedelta)
data: IntervalIndex[Interval[T]],
....
) -> Series[Interval[T]]: ...
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.
I can't see how this would work, because we have:
class IntervalIndex(IntervalMixin, ExtensionIndex, Generic[IntervalT]):
Since IntervalIndex
is generic, and Interval
is generic, you can't make IntervalIndex
depend on the "inner" generic 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.
Okay, sorry for the trouble.
Thanks @Dr-Irv ! |
* split Series[IntervalT] into separate __new__ * add test for generic series * Update reference to GH issue
test_series.py:test_pandera_generic()
Fix here is to expand the
Series[IntervalT].__new__()
into each individual part. Seems like a doubleTypeVar
causes issues formypy
. Had to do a similar fix forInterval.__contains__()
Either @twoertwein or @bashtage can approve or merge (both not required)