Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: Series initialiser also takes positional arguments #1207

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

Conversation

cmp0xff
Copy link
Contributor

@cmp0xff cmp0xff commented May 2, 2025

Describe the bug

All arguments in pandas.Series.__init__ are positional, but in the stubs some arguments are key-word only.

To Reproduce

Provide a minimal runnable pandas example that is not properly checked by the stubs.

import pandas as pd

pd.Series([], pd.DatetimeIndex([]), "float", "col")

Indicate which type checker you are using (mypy or pyright).

mypy

Show the error message received from that type checker while checking your example.

error: No overload variant of "Series" matches argument types "list[Never]", "DatetimeIndex", "str", "str"  [call-overload]
note: Possible overload variants:
note:     def [S1: str | bytes | date | time | bool | <11 more items>] Series(data: ndarray[Any, dtype[floating[_64Bit]]], index: ExtensionArray | ndarray[Any, Any] | Index[Any] | Series[Any] | list[Any] | dict[Any, Any] | range | tuple[Any, ...] | None = ..., *, dtype: ExtensionDtype | str | dtype[generic] | type[str] | type[complex] | type[bool] | type[object] = ..., name: Hashable = ..., copy: 
bool = ...) -> Series[float]
note:     def [S1: str | bytes | date | time | bool | <11 more items>] Series(data: Sequence[Never], index: ExtensionArray | ndarray[Any, Any] | Index[Any] | Series[Any] | list[Any] | dict[Any, Any] | range | tuple[Any, ...] | None = ..., *, dtype: ExtensionDtype | str | dtype[generic] | type[str] | type[complex] | type[bool] | type[object] = ..., name: Hashable = ..., copy: bool = ...) -> Series[Any]
note:     def [S1: str | bytes | date | time | bool | <11 more items>] Series(data: Sequence[list[str]], index: ExtensionArray | ndarray[Any, Any] | Index[Any] | Series[Any] | list[Any] | dict[Any, Any] | range | tuple[Any, ...] | None = ..., *, dtype: ExtensionDtype | str | dtype[generic] | type[str] | type[complex] | type[bool] | type[object] = ..., name: Hashable = ..., copy: bool = ...) -> Series[list[str]]
note:     def [S1: str | bytes | date | time | bool | <11 more items>] Series(data: Sequence[str], index: ExtensionArray | ndarray[Any, Any] | Index[Any] | Series[Any] | list[Any] | dict[Any, Any] | range | tuple[Any, ...] | None = ..., *, dtype: ExtensionDtype | str | dtype[generic] | type[str] | type[complex] | type[bool] | type[object] = ..., name: Hashable = ..., copy: bool = ...) -> Series[str]

Please complete the following information:

OS

Windows

OS Version

10

python version

13.2

version of type checker

1.15.0

version of installed pandas-stubs

2.2.3.250308

  • Tests added: Please use assert_type() to assert the type of any return value

@cmp0xff cmp0xff marked this pull request as draft May 2, 2025 14:56
@cmp0xff
Copy link
Contributor Author

cmp0xff commented May 2, 2025

Whoa, I'll need to think about this PR. Didn't expect so many errors.

cmp0xff added a commit to cmp0xff/pandas-stubs that referenced this pull request May 2, 2025
cmp0xff added a commit to cmp0xff/pandas-stubs that referenced this pull request May 2, 2025
@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/positional_arguments_for_series_initialiser branch from 19cf72c to 4124947 Compare May 2, 2025 19:09
cmp0xff added a commit to cmp0xff/pandas-stubs that referenced this pull request May 2, 2025
@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/positional_arguments_for_series_initialiser branch from 4124947 to 5cac358 Compare May 2, 2025 19:10
@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/positional_arguments_for_series_initialiser branch from 5cac358 to 4128829 Compare May 2, 2025 19:12
@cmp0xff cmp0xff marked this pull request as ready for review May 2, 2025 19:26
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.

thanks @cmp0xff

@Dr-Irv Dr-Irv merged commit cbb6723 into pandas-dev:main May 2, 2025
13 checks passed
@cmp0xff cmp0xff deleted the hotfix/cmp0xff/positional_arguments_for_series_initialiser branch May 2, 2025 19:43
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.

2 participants