Skip to content

TYP: fix mypy ignored error in pandas/io/formats/latex.py #37738

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
Nov 10, 2020

Conversation

ivanovmg
Copy link
Member

Handle mypy ignored error in pandas/io/formats/latex.py.

@ivanovmg ivanovmg changed the title TYP: fix mypy ignored error TYP: fix mypy ignored error in pandas/io/formats/latex.py Nov 10, 2020
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @ivanovmg generally lgtm.

Comment on lines 76 to 77
self.strcols: Sequence[Sequence[str]] = self._get_strcols()
self.strrows: Sequence[Sequence[str]] = list(zip(*self.strcols))
Copy link
Member

Choose a reason for hiding this comment

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

The variable type annotations can be removed. My preference is not to add variable types annotations unless absolutely necessary.

the variable types for self.strcols and self.strrows can (should) be inferred from the rhs expression.

self.strcols: Revealed type is 'builtins.list[builtins.list[builtins.str]]'
self.strrows: Revealed type is 'builtins.list[builtins.tuple*[Any]]'

I'm not sure why mypy can't infer more precise for self.strrows

mypy is green, but if wanted to be more precise for self.strrows could use List[Tuple[str, ...]]

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for the suggestions!
Updated accordingly.

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Nov 10, 2020
@simonjayhawkins simonjayhawkins added this to the 1.2 milestone Nov 10, 2020
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @ivanovmg ping on green.

@ivanovmg
Copy link
Member Author

@simonjayhawkins looks like green (internal Windows py38_np18 error)

@simonjayhawkins simonjayhawkins merged commit 0ddf563 into pandas-dev:master Nov 10, 2020
@simonjayhawkins
Copy link
Member

Thanks @ivanovmg

@ivanovmg ivanovmg deleted the mypy/latex branch November 10, 2020 15:22
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.

2 participants