Skip to content

TYP: misc typing in _libs #44349

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
Dec 14, 2021
Merged

TYP: misc typing in _libs #44349

merged 3 commits into from
Dec 14, 2021

Conversation

twoertwein
Copy link
Member

Reduced the list of partially typed functions in _libs a bit.

@twoertwein twoertwein added the Typing type annotations, mypy/pyright type checking label Nov 8, 2021
def ceil(self: _S, freq) -> _S: ...
def round(self: _S, freq: str) -> _S: ...
def floor(self: _S, freq: str) -> _S: ...
def ceil(self: _S, freq: str) -> _S: ...
Copy link
Member

Choose a reason for hiding this comment

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

could also be BaseOffset?

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 added most annotations based on the documentation (when available): it mentions only strings. freq ends up in to_offset so it should support BaseOffset.

def strftime(self, fmt: str) -> str: ...
def to_timestamp(
self,
freq: str | BaseOffset | None = ...,
how: str = ...,
tz: Timezone | None = ...,
) -> Timestamp: ...
def asfreq(self, freq, how=...) -> Period: ...
def asfreq(self, freq: str, how: str = ...) -> Period: ...
Copy link
Member Author

Choose a reason for hiding this comment

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

freq can also be a BaseOffset but the documentation requires a str.

If the documentation is out of date, BaseOffset should be added. It might be that the type was intentionally restricted to make future refactoring/simplifications possible?

I'll only comment on these cases for now.

@jreback jreback added this to the 1.4 milestone Nov 16, 2021
@jreback
Copy link
Contributor

jreback commented Nov 16, 2021

can you rebase

@jreback jreback merged commit 482d66f into pandas-dev:master Dec 14, 2021
@jreback
Copy link
Contributor

jreback commented Dec 14, 2021

thanks @twoertwein

@twoertwein twoertwein deleted the misc_libs branch March 9, 2022 02:56
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