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

A generic 'frame' type #1806

Open
brentonmallen1 opened this issue Jul 16, 2024 · 0 comments
Open

A generic 'frame' type #1806

brentonmallen1 opened this issue Jul 16, 2024 · 0 comments
Labels
topic: feature Discussions about new features for Python's type annotations

Comments

@brentonmallen1
Copy link

I'm not sure how all this works, so if my idea doesn't make sense or isn't feasible, no worries.

My thought is to have a generic type that could encompass objects like the pandas or polars dataframe without having to import those libraries. Maybe it's a collection? The motivation is that these libraries can be large and so their use could be made optional, but in order to type a function that could take one as an argument, the library or a stubs dependency would have to be added. There is the pandas-stubs, which is what make this DOA, but one doesn't exist for polars (which might make it out of scope here). Not sure if there are other libaries/objects that would benefit from something like this. Anyway, just had the thought and I think mostly answered it to myself as I typed but maybe someone else has more thoughts/suggestions.

example:

# something object could either be a string (json) or a dataframe
def process_records(records: Union[str, typing.frame]) -> Union[dict, typing.frame]:
    ...
@brentonmallen1 brentonmallen1 added the topic: feature Discussions about new features for Python's type annotations label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: feature Discussions about new features for Python's type annotations
Projects
None yet
Development

No branches or pull requests

1 participant