Skip to content

CLN: follow-ups #29600

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 6 commits into from
Nov 14, 2019
Merged

CLN: follow-ups #29600

merged 6 commits into from
Nov 14, 2019

Conversation

jbrockmendel
Copy link
Member

includes requested followups for reshape.merge cc @simonjayhawkins

_right = _validate_operand(right)
self.left = self.orig_left = _validate_operand(_left) # type: "DataFrame"
self.right = self.orig_right = _validate_operand(_right) # type: "DataFrame"
_left: "DataFrame" = _validate_operand(left)
Copy link
Member

Choose a reason for hiding this comment

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

since _validate_operand is typed (with a return type), the variable annotation is redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

we dont want it just for the reader?

Copy link
Member

Choose a reason for hiding this comment

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

i don't think so. doing this sort of thing could loosen type checking, say if for instance _validate_operand returned a subclass of DataFrame this would pass mypy and the variable would no longer have the type of the subclass

import pandas as pd


class MyDataFrame(pd.DataFrame):
    pass


def some_function() -> MyDataFrame:
    return MyDataFrame()


loose: pd.DataFrame = some_function()
reveal_type(loose)
tight = some_function()
reveal_type(tight)
$ mypy test.py
test.py:13: note: Revealed type is 'pandas.core.frame.DataFrame'
test.py:15: note: Revealed type is 'test.MyDataFrame'

Copy link
Member Author

Choose a reason for hiding this comment

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

got it, thanks. will update

@jreback jreback added the Clean label Nov 13, 2019
@jreback jreback added this to the 1.0 milestone Nov 13, 2019
@jreback jreback merged commit c5766c1 into pandas-dev:master Nov 14, 2019
@jreback
Copy link
Contributor

jreback commented Nov 14, 2019

thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the cln-follow branch November 14, 2019 16:05
Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants