Skip to content

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