Skip to content

Conversation

@twoertwein
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.



def is_number(obj) -> TypeGuard[Number | np.number]:
def is_number(obj: object) -> TypeGuard[Number | np.number]:
Copy link
Member

Choose a reason for hiding this comment

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

Curious, is there any difference between object and Any?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think typeshed recommends to use object, when literally any object is accepted (typically for __eq__ and similar methods) and to use Any when it is too difficult to write a type annotation/when the code is too dynamic.

@mroeschke mroeschke added the Typing type annotations, mypy/pyright type checking label Dec 28, 2023
@mroeschke mroeschke added this to the 3.0 milestone Dec 29, 2023
@mroeschke mroeschke merged commit 37975eb into pandas-dev:main Dec 29, 2023
@mroeschke
Copy link
Member

Thanks @twoertwein

cbpygit pushed a commit to cbpygit/pandas that referenced this pull request Jan 2, 2024
@twoertwein twoertwein deleted the types branch January 17, 2024 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Typing type annotations, mypy/pyright type checking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants