Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/series/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ def test_pandera_generic() -> None:

class MySeries(pd.Series, Generic[T]):
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
return object.__new__(cls)
return super().__new__(cls) # type: ignore[return-value] # pyright: ignore[reportReturnType]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't want # type: ignore in the test files, except in the following cases:

  1. the type checkers disagree - one is OK, but the other flags it, so we have to ignore for one of the checkers
  2. When we are doing TYPE_CHECKING_INVALID_USAGE

I think the following will make this work:

        def __new__(cls, *args: Any, **kwargs: Any) -> MySeries[T]:
            return cast(MySeries[T], super().__new__(cls))

In this case, you have to do the cast because of how __new() works.

@cmp0xff or @loicdiridollou can you try this and get it to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this comment. @loicdiridollou has created #1489.

My understanding used to be that ignores are not allowed in tests, and these new ignores are not in tests themselves.


def func() -> MySeries[float]:
return MySeries[float]([1, 2, 3])
Expand Down