Skip to content

core.groupby.generic.DataFrameGroupBy missing keyword-only arguments engine and engine_kwargs #810

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

Closed
Avasam opened this issue Nov 3, 2023 · 1 comment · Fixed by #848
Labels
Apply Apply, Aggregate, Transform Awaiting Response Waiting for response Groupby

Comments

@Avasam
Copy link

Avasam commented Nov 3, 2023

Describe the bug
core.groupby.generic.DataFrameGroupBy missing keyword-only arguments

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
  2. Indicate which type checker you are using (mypy or pyright).
  3. Show the error message received from that type checker while checking your example.

Current:

DataFrameGroupBy().aggregate("size", "some", "args", engine=0, engine_kwargs="not valid", other_kwarg="")
# no error despite `engine` as `engine_kwargs` not being valid types for those kw-only args

Expected:
mypy

error: No overload variant of "aggregate" of "DataFrameGroupBy" matches argument types "str", "str", "str", "int", "int", "str"  [call-overload]
note: Possible overload variants:
note:     def aggregate(self, arg: Literal['size']) -> Series[Any]
note:     def aggregate(self, arg: Union[Union[Callable[..., Any], str, ufunc], list[Union[Callable[..., Any], str, ufunc]], Mapping[Any, Union[Union[Callable[..., Any], str, ufunc], list[Union[Callable[..., 
Any], str, ufunc]]]]] = ..., *args: Any, engine: Optional[str] = ..., engine_kwargs: Optional[dict[str, bool]] = ..., **kwargs: Any) -> DataFrame

pyright

error: Argument of type "Literal[0]" cannot be assigned to parameter "engine" of type "str | None" in function "aggregate"
    Type "Literal[0]" cannot be assigned to type "str | None"
      "Literal[0]" is incompatible with "str"
      Type cannot be assigned to type "None" (reportGeneralTypeIssues)
error: Argument of type "Literal[0]" cannot be assigned to parameter "engine_kwargs" of type "dict[str, bool] | None" in function "aggregate"
    Type "Literal[0]" cannot be assigned to type "dict[str, bool] | None"
      "Literal[0]" is incompatible with "dict[str, bool]"
      Type cannot be assigned to type "None" (reportGeneralTypeIssues)

Please complete the following information:

  • OS: Windows
  • OS Version 10.0.19045 Build 19045
  • python version: 3.9.13
  • version of type checker:
  • version of installed pandas-stubs: 2.1.1.230928

Additional context
Noticed while drilling down seaborn types to complete some method signatures in typeshed

@Avasam Avasam changed the title core.groupby.generic.DataFrameGroupBy missing keyword-only arguments core.groupby.generic.DataFrameGroupBy missing keyword-only arguments engine and engine_kwargs Nov 3, 2023
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 6, 2023

I'm not sure that the code above is correct in terms of how pandas documents DataFrameGroupBy.aggregate(), because of the first 3 arguments, which would need to be a list to do what I think you want.

Having said that, the engine and engine_kwargs arguments are missing from the stubs.

For us to address this, we would need a more complete example.

@Dr-Irv Dr-Irv added Apply Apply, Aggregate, Transform Groupby Awaiting Response Waiting for response labels Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform Awaiting Response Waiting for response Groupby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants