-
-
Notifications
You must be signed in to change notification settings - Fork 156
GH1541 Revert Series[Any].__add__(str) #1542
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
base: main
Are you sure you want to change the base?
Changes from all commits
a56a50c
4aa6173
3bbe2c1
9e74866
e63fe8c
17670b7
4db2db1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,11 +67,13 @@ _Values: TypeAlias = SequenceNotStr[Any] | _ExtendedAnyArrayLike | |
| @overload | ||
| def pivot_table( | ||
| data: DataFrame, | ||
| values: _PivotTableValuesTypes[ | ||
| 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] | ||
|
Comment on lines
+70
to
+76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| Hashable # ty: ignore[invalid-type-arguments] | ||
| ] = None, | ||
| aggfunc: ( | ||
|
|
@@ -91,13 +93,15 @@ def pivot_table( | |
| @overload | ||
| def pivot_table( | ||
| data: DataFrame, | ||
| values: _PivotTableValuesTypes[ | ||
| values: _PivotTableValuesTypes[ # ty: ignore[non-subscriptable] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit surprising that we now need to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| Hashable # ty: ignore[invalid-type-arguments] | ||
| ] = None, | ||
| *, | ||
| index: Grouper, | ||
| columns: ( | ||
| _PivotTableColumnsTypes[Hashable] # ty: ignore[invalid-type-arguments] | ||
| _PivotTableColumnsTypes[ # ty: ignore[non-subscriptable] | ||
| Hashable # ty: ignore[invalid-type-arguments] | ||
| ] | ||
|
Comment on lines
+102
to
+104
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| | np_ndarray | ||
| | Index[Any] | ||
| ) = None, | ||
|
|
@@ -116,11 +120,13 @@ def pivot_table( | |
| @overload | ||
| def pivot_table( | ||
| data: DataFrame, | ||
| values: _PivotTableValuesTypes[ | ||
| 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] | ||
| ] | ||
|
Comment on lines
+123
to
+129
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| | np_ndarray | ||
| | Index[Any] | ||
| ) = None, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |||||||||||
| import numpy as np | ||||||||||||
| import pandas as pd | ||||||||||||
| from typing_extensions import ( | ||||||||||||
| Never, | ||||||||||||
| assert_type, | ||||||||||||
| ) | ||||||||||||
|
Comment on lines
5
to
7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
|
|
@@ -107,5 +106,6 @@ def test_add_i_py_str() -> None: | |||||||||||
| s = "abc" | ||||||||||||
|
|
||||||||||||
| 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 | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| assert_type(left_i + s, "pd.Index[str]") | ||||||||||||
| assert_type(s + left_i, "pd.Index[str]") | ||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,3 +145,12 @@ def test_add_pd_series() -> None: | |
| if TYPE_CHECKING_INVALID_USAGE: | ||
| left.radd(i) # type: ignore[arg-type] # pyright: ignore[reportArgumentType, reportCallIssue] | ||
| check(assert_type(left.radd(r0), "pd.Series[str]"), pd.Series, str) | ||
|
|
||
|
|
||
| def test_series_add_str() -> None: | ||
| """Test Series.__add__ with Series[Any].""" | ||
| df = pd.DataFrame({0: ["a", "b"]}) | ||
| 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,9 @@ | ||||||||||
| from __future__ import annotations | ||||||||||
|
|
||||||||||
| import datetime as dt | ||||||||||
| from typing import TypeAlias | ||||||||||
| from typing import ( | ||||||||||
| TypeAlias, | ||||||||||
| ) | ||||||||||
|
Comment on lines
+4
to
+6
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| from dateutil.relativedelta import ( | ||||||||||
| FR, | ||||||||||
|
|
||||||||||
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.
Please add tests in
tests/indexes/arithmetic/test_add.py