diff --git a/.github/workflows/comment_commands.yml b/.github/workflows/comment_commands.yml index c85cdca8..328a27c6 100644 --- a/.github/workflows/comment_commands.yml +++ b/.github/workflows/comment_commands.yml @@ -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 }} @@ -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 @@ -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: { diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index acf5a78c..770ad776 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -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 = ..., @@ -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], diff --git a/tests/test_series.py b/tests/test_series.py index 86b277df..ddbb5e73 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -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 + )