Skip to content

Commit

Permalink
Merge branch 'main' of github.com:loicdiridollou/pandas-stubs into gh…
Browse files Browse the repository at this point in the history
…1089_tests_migration
  • Loading branch information
loicdiridollou committed Jan 15, 2025
2 parents 3c6f490 + 0e22870 commit 65aa064
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 17 deletions.
38 changes: 22 additions & 16 deletions .github/workflows/comment_commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,10 @@ jobs:
if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/pyright_strict", "/mypy_nightly"]'), github.event.comment.body)

steps:
- uses: actions/checkout@v4

- name: Install project dependencies
uses: ./.github/setup
with:
os: ubuntu-latest
python-version: "3.11"

- name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}
# run the tests based on the value of the comment
id: tests-step
run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }}

- name: Get head sha and store value
- name: Get head sha, branch name and store value
# get the sha of the last commit to attach the results of the tests
if: always()
id: get-sha
id: get-branch-info
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -48,6 +35,25 @@ jobs:
pull_number: ${{ github.event.issue.number }}
})
core.setOutput('sha', pr.data.head.sha)
core.setOutput('branch', pr.data.head.ref)
- name: Checkout code on the correct branch
uses: actions/checkout@v4
with:
# context is not aware which branch to checkout so it would otherwise
# default to main
ref: ${{ steps.get-branch-info.outputs.branch }}

- name: Install project dependencies
uses: ./.github/setup
with:
os: ubuntu-latest
python-version: "3.12"

- name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}
# run the tests based on the value of the comment
id: tests-step
run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }}

- name: Report results of the tests and publish
# publish the results to a check run no matter the pass or fail
Expand All @@ -58,7 +64,7 @@ jobs:
script: |
github.rest.checks.create({
name: '${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}',
head_sha: '${{ steps.get-sha.outputs.sha }}',
head_sha: '${{ steps.get-branch-info.outputs.sha }}',
status: 'completed',
conclusion: '${{ steps.tests-step.outcome }}',
output: {
Expand Down
42 changes: 41 additions & 1 deletion pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
copy: bool = ...,
) -> IntervalSeries[_OrderableT]: ...
@overload
def __new__(
def __new__( # type: ignore[overload-overlap]
cls,
data: Scalar | _ListLike | dict[HashableT1, Any] | None,
index: Axes | None = ...,
Expand All @@ -353,6 +353,46 @@ class Series(IndexOpsMixin[S1], NDFrame):
copy: bool = ...,
) -> Self: ...
@overload
def __new__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
cls,
data: Sequence[bool],
index: Axes | None = ...,
*,
dtype: Dtype = ...,
name: Hashable = ...,
copy: bool = ...,
) -> Series[bool]: ...
@overload
def __new__( # type: ignore[overload-overlap]
cls,
data: Sequence[int],
index: Axes | None = ...,
*,
dtype: Dtype = ...,
name: Hashable = ...,
copy: bool = ...,
) -> Series[int]: ...
@overload
def __new__(
cls,
data: Sequence[float],
index: Axes | None = ...,
*,
dtype: Dtype = ...,
name: Hashable = ...,
copy: bool = ...,
) -> Series[float]: ...
@overload
def __new__( # type: ignore[overload-cannot-match] # pyright: ignore[reportOverlappingOverload]
cls,
data: Sequence[int | float],
index: Axes | None = ...,
*,
dtype: Dtype = ...,
name: Hashable = ...,
copy: bool = ...,
) -> Series[float]: ...
@overload
def __new__(
cls,
data: S1 | _ListLike[S1] | dict[HashableT1, S1] | dict_keys[S1, Any],
Expand Down
13 changes: 13 additions & 0 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3588,3 +3588,16 @@ def test_series_dict() -> None:
pd.Series,
str,
)


def test_series_int_float() -> None:
# pyright infers mixtures of int and float in a list as list[int | float]
check(assert_type(pd.Series([1, 2, 3]), "pd.Series[int]"), pd.Series, np.integer)
check(
assert_type(pd.Series([1.0, 2.0, 3.0]), "pd.Series[float]"),
pd.Series,
np.float64,
)
check(
assert_type(pd.Series([1, 2.0, 3]), "pd.Series[float]"), pd.Series, np.float64
)

0 comments on commit 65aa064

Please sign in to comment.