Skip to content

TYP: timedeltas.pyi #40766

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 3 commits into from
Apr 14, 2021
Merged

TYP: timedeltas.pyi #40766

merged 3 commits into from
Apr 14, 2021

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry

@simonjayhawkins mypy is unhappy about Timedelta.__new__ potentially returning NaT. Thoughts on how to handle this? (it'll come up again in Timestamp and Period)

pandas/_libs/tslibs/timedeltas.pyi:51: error: "__new__" must return a class instance (got "Union[Timedelta, NaTType]")  [misc]

@jbrockmendel jbrockmendel added the Typing type annotations, mypy/pyright type checking label Apr 4, 2021
@jbrockmendel
Copy link
Member Author

@simonjayhawkins im pretty sure this is non-actionable based on what I read in python/mypy#1020, but would like your say-so before mothballing this

@simonjayhawkins
Copy link
Member

yes. looks tricky. I would add ignores for now since imo the benefit of the added types outweighs the extra ignores.

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

I guess we need some lint checks on the stubs.

from datetime import timedelta
from time import struct_time
from typing import (
AnyStr,
Copy link
Member

Choose a reason for hiding this comment

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

unused

from typing import (
AnyStr,
ClassVar,
Optional,
Copy link
Member

Choose a reason for hiding this comment

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

unused

AnyStr,
ClassVar,
Optional,
SupportsAbs,
Copy link
Member

Choose a reason for hiding this comment

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

unused

Tuple,
Type,
TypeVar,
Union,
Copy link
Member

Choose a reason for hiding this comment

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

unused

@@ -0,0 +1,106 @@
from datetime import timedelta
from time import struct_time
Copy link
Member

Choose a reason for hiding this comment

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

unused

import numpy as np

from pandas._libs.tslibs import (
NaT,
Copy link
Member

Choose a reason for hiding this comment

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

unused

@simonjayhawkins simonjayhawkins added this to the 1.3 milestone Apr 11, 2021
@jbrockmendel jbrockmendel marked this pull request as ready for review April 11, 2021 19:50
@jbrockmendel
Copy link
Member Author

updated per comments

@jreback jreback merged commit 84d9c5e into pandas-dev:master Apr 14, 2021
@jbrockmendel jbrockmendel deleted the typ-timedeltas branch April 14, 2021 14:27
yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request Apr 21, 2021
yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request May 6, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
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.

3 participants