Skip to content

Conversation

@jbrockmendel
Copy link
Member

splitting this off of branches that do non-CLN stuff

@pep8speaks
Copy link

pep8speaks commented Nov 15, 2019

Hello @jbrockmendel! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-11-17 15:40:56 UTC

def _aggregate_named(self, func, *args, **kwargs):
result = OrderedDict()
def _aggregate_named(self, func, *args, **kwargs) -> OrderedDict:
result = OrderedDict() # type: OrderedDict
Copy link
Contributor

Choose a reason for hiding this comment

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

can just be a dict now

@jreback jreback added Clean Groupby Typing type annotations, mypy/pyright type checking labels Nov 16, 2019
@jreback jreback added this to the 1.0 milestone Nov 16, 2019

def _aggregate_named(self, func, *args, **kwargs):
result = OrderedDict()
def _aggregate_named(self, func, *args, **kwargs) -> dict:
Copy link
Member

Choose a reason for hiding this comment

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

Can you use typing.Dict instead of the built-in? Would also be great if you can identify key / value types if not too much incremental effort

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do. In cases where we can do Dict[foo, bar] i get why that's better. In cases where we can't say anything meaningful, is it just for consistency or is there some other upside?

def _aggregate_named(self, func, *args, **kwargs):
result = OrderedDict()
def _aggregate_named(self, func, *args, **kwargs) -> Dict:
result = {} # type: Dict
Copy link
Contributor

Choose a reason for hiding this comment

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

can use the new style of typing now, e.g. result: Dict = {}, though odd that mypy can't infer that. better to be even specific, Dict[str, ]

Copy link
Member

Choose a reason for hiding this comment

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

Just FYI mypy will always complain for an empty container creation as it can't infer the subtypes

return result

def _transform_fast(self, func, func_nm) -> Series:
def _transform_fast(self, func: Callable, func_nm: str) -> Series:
Copy link
Member

Choose a reason for hiding this comment

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

If the arguments and/or return type of Callable can be provided it is very helpful; not sure how much incremental effort that is

def _aggregate_named(self, func, *args, **kwargs):
result = OrderedDict()
def _aggregate_named(self, func, *args, **kwargs) -> Dict:
result = {} # type: Dict
Copy link
Member

Choose a reason for hiding this comment

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

Just FYI mypy will always complain for an empty container creation as it can't infer the subtypes

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.

Note that there are a few conflicts between this and #29124

result.insert(0, name, lev)

def _wrap_aggregated_output(self, output, names=None):
def _wrap_aggregated_output(self, output: dict, names=None):
Copy link
Member

Choose a reason for hiding this comment

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

dict -> typing.Dict and ideally with subtypes if possible (here and below)

@jbrockmendel
Copy link
Member Author

Closing in favor of #29124

@jbrockmendel jbrockmendel deleted the cln-gb branch November 18, 2019 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Clean Groupby Typing type annotations, mypy/pyright type checking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants