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

Extend type hints from outside #13

Open
mflova opened this issue May 13, 2024 · 0 comments
Open

Extend type hints from outside #13

mflova opened this issue May 13, 2024 · 0 comments

Comments

@mflova
Copy link
Owner

mflova commented May 13, 2024

When type hinting new pandas accessors, these will not be properly type hinted. Consider the possibility of adding hardcoded lines and imports. Lines to be added to the class. Something like:

{extra_imports}

class MyDataFrame(pd.DataFrame):

    {line_given_by_the_user}

    @overload  # type: ignore
    def __getitem__(self, key: Literal['HA40+']) -> pd.Series["Quantity"]:
        ...

Where line_given_by_the_user can be: pint: PintAccessor and {extra_imports} being PintAccessor corresponding import

How this information is given is still to be decided

EDIT: Another alternative would be to scan all accessors within a pandas dataframe and include them in the class scope of the dataframe (including associated import)

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

1 participant