Skip to content

add dataframe property #110

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

Merged
merged 1 commit into from
Mar 28, 2023
Merged

Conversation

MarcoGorelli
Copy link
Contributor

closes #108

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Marco. One question: isn't it better to type "returns unknown object" with -> Any rather than -> object?

@MarcoGorelli
Copy link
Contributor Author

-> object would ensure that no properties of the object are being used - e.g.

from typing import *

class Animal:
    def foo(self) -> object:
        ...
        
class Cat(Animal):
    def foo(self) -> int:
        return 3

reveal_type(Cat().foo())

type checks fine, and would error on Animal().foo().sort_values(), whereas a return type of Any would turn off the type checker and Animal().foo().sort_values() would pass (though that's probably not what we want, because there would be no guarantees about what methods are in the return value from .dataframe)

@rgommers
Copy link
Member

Ah fair enough. I haven't seen -> object used before, but the rationale seems solid here. And for users who know what type they want/expect, they can type-narrow themselves.

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems straightforward enough and the one minor concern on typing was answered - in it goes. Thanks @MarcoGorelli

@rgommers rgommers merged commit d10a096 into data-apis:main Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Method to get underlying object
2 participants