Skip to content

TYP: Typing annotations pandas/util/ #30411

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 2 commits into from
Dec 24, 2019
Merged

Conversation

ShaharNaveh
Copy link
Member

@ShaharNaveh ShaharNaveh commented Dec 22, 2019

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@ShaharNaveh ShaharNaveh changed the title TYP: Typing annotations TYP: Typing annotations pandas/util/ Dec 22, 2019
@alimcmaster1 alimcmaster1 added the Typing type annotations, mypy/pyright type checking label Dec 23, 2019
@@ -37,7 +37,7 @@ def test_foo():
from pandas.core.computation.expressions import _NUMEXPR_INSTALLED, _USE_NUMEXPR


def safe_import(mod_name, min_version=None):
def safe_import(mod_name: str, min_version: Optional[str] = None):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def safe_import(mod_name: str, min_version: Optional[str] = None):
def safe_import(mod_name: str, min_version: Optional[str] = None) -> Union[types.ModuleType, bool]:

Actually not 100% sure on this one but would be nice if return type could be annotated as well

Copy link
Member Author

@ShaharNaveh ShaharNaveh Dec 23, 2019

Choose a reason for hiding this comment

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

Code style question, what is preferred here?

from types import ModuleType

or

import types

Copy link
Member Author

Choose a reason for hiding this comment

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

NVM, mypy complains about it anyway.


compat_args: OrderedDict
A ordered dictionary of keys and their associated default values.
compat_args : OrderedDict
Copy link
Member

Choose a reason for hiding this comment

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

Is this still an OrderedDict? IIRC we removed all occurrences of those from code base recently

Copy link
Member Author

Choose a reason for hiding this comment

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

Remove it from the doc?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm was going to say just label as dict but it looks like there is a detailed note about ordered requirements. Still should just be a dict but have to clean up the associated note; can do in a follow up if you'd like

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at the detailed note, it's just to be compatible some buggy versions of numpy, and by looking at the git-blame of it, it way 4 years ago.

It's probably fixed by now, but I really cant know for sure, because there's no mention of a
specific/range of problematic numpy's versions.

Do you feel comfortable with removing the detailed note about the OrderedDict?

@ShaharNaveh ShaharNaveh force-pushed the TYP-util branch 2 times, most recently from 592ed71 to ef5b45d Compare December 23, 2019 09:07
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Minor comment otherwise @simonjayhawkins

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

lgtm

@WillAyd WillAyd added this to the 1.0 milestone Dec 24, 2019
@@ -195,7 +195,9 @@ def skip_if_no(package: str, min_version: Optional[str] = None) -> Callable:
)


def skip_if_np_lt(ver_str, reason=None, *args, **kwds):
def skip_if_np_lt(
Copy link
Contributor

Choose a reason for hiding this comment

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

these could actually be a pytest.mark.skipif type (not sure what that actually is though)

Copy link
Contributor

Choose a reason for hiding this comment

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

but can address that later if so desired

@jreback jreback merged commit 658840d into pandas-dev:master Dec 24, 2019
@jreback
Copy link
Contributor

jreback commented Dec 24, 2019

thanks @MomIsBestFriend

@ShaharNaveh ShaharNaveh deleted the TYP-util branch December 24, 2019 16:42
AlexKirko pushed a commit to AlexKirko/pandas that referenced this pull request Dec 29, 2019
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.

4 participants