pandas-stubs icon indicating copy to clipboard operation
pandas-stubs copied to clipboard

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

Open davetapley opened this issue 2 months ago • 2 comments

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:

  • https://github.com/pandas-dev/pandas/issues/58244

davetapley avatar Apr 13 '24 01:04 davetapley