Skip to content
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

pandas: Incorrect return type for pandas.Timestamp.normalize() #779

Closed
DannyNemer opened this issue Dec 27, 2020 · 4 comments
Closed

pandas: Incorrect return type for pandas.Timestamp.normalize() #779

DannyNemer opened this issue Dec 27, 2020 · 4 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version typestub Issue relating to our bundled type stubs

Comments

@DannyNemer
Copy link

DannyNemer commented Dec 27, 2020

Environment

  • Language Server: v2020.12.2
  • OS: macOS v10.15.6
  • Python: v3.7.9
  • Pandas: v1.1.5 (latest)

Expected behavior

Recognize that pandas.Timestamp.normalize() returns an instance of pandas.Timestamp:

Actual behavior

Pylance incorrectly says pandas.Timestamp.normalize() returns None:

Code Snippet

Should not return errors:

import pandas as pd

pd.Timestamp.today().normalize().tz_localize(None)

Please let me know how I can improve this bug report because many more will follow (all for typeshed issues). Is this the best repo for such bug reports? (I am following the precedent of Pandas type issues in the release notes.)

@judej
Copy link
Contributor

judej commented Dec 29, 2020

Thanks for the report @DannyNemer, looks like the type stub needs an update.

@judej judej added the typestub Issue relating to our bundled type stubs label Dec 29, 2020
@github-actions github-actions bot removed the triage label Dec 29, 2020
@gramster
Copy link
Member

gramster commented Mar 5, 2021

It doesn't seem like Timestamp is the issue here, as it says in the stub:

from __future__ import annotations

...
class Timestamp:
    ...
    @classmethod
    def today(cls, tz: Optional[Any] = ...) -> Timestamp: ...
    def normalize(self, *args, **kwargs) -> Timestamp: ...
    def tz_localize(self, tz: Any = ...) -> Timestamp: ...

@erictraut, can you see something I may be missing?

@gramster
Copy link
Member

I also see "argument missing for parameter tz" on the line

pd.Timestamp.today()

which makes me wonder if @classmethod is being handled in the stubs.

@gramster gramster added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label May 4, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.5.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202150-5-may-2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version typestub Issue relating to our bundled type stubs
Projects
None yet
Development

No branches or pull requests

4 participants