Skip to content
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

register_dataframe_accessor causes "Untyped class decorator obscures type of class; ignoring decorator" #906

Open
davetapley opened this issue Apr 13, 2024 · 2 comments

Comments

@davetapley
Copy link
Contributor

Describe the bug
Example from the docs causes:

Untyped class decorator obscures type of class; ignoring decoratorPylance[reportUntypedClassDecorator](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportUntypedClassDecorator)

in VSCode.

To Reproduce

In VSCode:

@pd.api.extensions.register_dataframe_accessor("geo")
class GeoAccessor:
    ...

Please complete the following information:

  • OS: Ubuntu
  • OS Version 20.04
  • python version 3.11
  • version of type checker pyright v1.1.354
  • version of installed pandas-stubs v2.2.1.240316

Additional context

This fixes it, PR welcome?

from typing import Callable, TypeVar

T = TypeVar('T')  # return type

def register_dataframe_accessor(name: str) -> Callable[[T], T]: ...

See also:

@twoertwein
Copy link
Member

twoertwein commented Apr 13, 2024

This fixes it, PR welcome?

Yes - probably should use a more specific TypeVar, maybe DataFrameT = TypeVar("DataFrameT", bound=DataFrame).

@twoertwein
Copy link
Member

I opened pandas-dev/pandas#58339 for pandas. Feel free to open a similar PR here

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

No branches or pull requests

2 participants