Skip to content

Conversation

@loicdiridollou
Copy link
Member

@loicdiridollou loicdiridollou requested review from Dr-Irv and cmp0xff and removed request for Dr-Irv December 10, 2025 21:55
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

I'm fine with this. Would like @cmp0xff to take a look as well.

Copy link
Contributor

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

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

I think we still miss a few tests.

I also plan to simplify the tests structure for arithmetic operations, removing the arithmetic subfolder and move everything one level above. Hopefully this will confuse people less in the future.

def pivot_table(
data: DataFrame,
values: _PivotTableValuesTypes[
values: _PivotTableValuesTypes[ # ty: ignore[non-subscriptable]
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bit surprising that we now need to ty: ignore's here. Would be great if you could report it to ty.

Copy link
Contributor

@cmp0xff cmp0xff Dec 14, 2025

Choose a reason for hiding this comment

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

Proposing an alternative fix in #1547. This is related to astral-sh/ty#1846.

def __gt__(self, other: Self | S1) -> np_1darray_bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
@overload
def __add__(self: Index[Never], other: _str) -> Never: ...
def __add__(self: Index[Never], other: _str) -> Index[_str]: ...
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add tests in tests/indexes/arithmetic/test_add.py

sr = df[0]

check(assert_type(sr + "c1", "pd.Series[str]"), pd.Series, str)
check(assert_type("c1" + sr, "pd.Series[str]"), pd.Series, str)
Copy link
Contributor

Choose a reason for hiding this comment

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

  • series/arithmetic/str/test_add.py is meant to test for known Series[str]. For Series[Any] at type checking, the plan is to use series/arithmetic/test_add.py. Please move this part there.
    • We also have a left_str = pd.DataFrame({"a": ["1", "2", "3_"]})["a"] defined in that file.
  • Please also make the undunder methods add and radd work

Comment on lines +4 to +6
from typing import (
TypeAlias,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from typing import (
TypeAlias,
)
from typing import TypeAlias

Comment on lines 5 to 7
from typing_extensions import (
Never,
assert_type,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from typing_extensions import (
Never,
assert_type,
)
from typing_extensions import assert_type

if TYPE_CHECKING_INVALID_USAGE:
assert_type(left_i + s, Never)
assert_type(s + left_i, Never)
# relaxing typing, won't work at runtime though
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# relaxing typing, won't work at runtime though
# GH1541 relaxing typing, won't work at runtime though

Comment on lines +102 to +104
_PivotTableColumnsTypes[ # ty: ignore[non-subscriptable]
Hashable # ty: ignore[invalid-type-arguments]
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Proposing an alternative fix in #1547. This is related to astral-sh/ty#1846.

Comment on lines +123 to +129
values: _PivotTableValuesTypes[ # ty: ignore[non-subscriptable]
Hashable # ty: ignore[invalid-type-arguments]
] = None,
index: (
_PivotTableIndexTypes[Hashable] # ty: ignore[invalid-type-arguments]
_PivotTableIndexTypes[ # ty: ignore[non-subscriptable]
Hashable # ty: ignore[invalid-type-arguments]
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Proposing an alternative fix in #1547. This is related to astral-sh/ty#1846.

Comment on lines +70 to +76
values: _PivotTableValuesTypes[ # ty: ignore[non-subscriptable]
Hashable # ty: ignore[invalid-type-arguments]
] = None,
index: _PivotTableIndexTypes[Hashable] = None, # ty: ignore[invalid-type-arguments]
columns: _PivotTableColumnsTypes[
index: _PivotTableIndexTypes[ # ty: ignore[non-subscriptable]
Hashable # ty: ignore[invalid-type-arguments]
] = None,
columns: _PivotTableColumnsTypes[ # ty: ignore[non-subscriptable]
Copy link
Contributor

Choose a reason for hiding this comment

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

Proposing an alternative fix in #1547. This is related to astral-sh/ty#1846.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Series[Any] should accept __add__ with strings

3 participants