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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions pandas/io/formats/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module for formatting output data in Latex.
"""
from abc import ABC, abstractmethod
from typing import Iterator, List, Optional, Tuple, Type, Union
from typing import Iterator, List, Optional, Sequence, Tuple, Type, Union

import numpy as np

Expand Down Expand Up @@ -74,9 +74,7 @@ def __init__(
self.multirow = multirow
self.clinebuf: List[List[int]] = []
self.strcols = self._get_strcols()
self.strrows: List[List[str]] = list(
zip(*self.strcols) # type: ignore[arg-type]
)
self.strrows = list(zip(*self.strcols))

def get_strrow(self, row_num: int) -> str:
"""Get string representation of the row."""
Expand Down Expand Up @@ -179,7 +177,7 @@ def _empty_info_line(self):
f"Index: {self.frame.index}"
)

def _preprocess_row(self, row: List[str]) -> List[str]:
def _preprocess_row(self, row: Sequence[str]) -> List[str]:
"""Preprocess elements of the row."""
if self.fmt.escape:
crow = _escape_symbols(row)
Expand Down Expand Up @@ -781,7 +779,7 @@ def _get_index_format(self) -> str:
return "l" * self.frame.index.nlevels if self.fmt.index else ""


def _escape_symbols(row: List[str]) -> List[str]:
def _escape_symbols(row: Sequence[str]) -> List[str]:
"""Carry out string replacements for special symbols.
Parameters
Expand Down Expand Up @@ -813,7 +811,7 @@ def _escape_symbols(row: List[str]) -> List[str]:
]


def _convert_to_bold(crow: List[str], ilevels: int) -> List[str]:
def _convert_to_bold(crow: Sequence[str], ilevels: int) -> List[str]:
"""Convert elements in ``crow`` to bold."""
return [
f"\\textbf{{{x}}}" if j < ilevels and x.strip() not in ["", "{}"] else x
Expand Down