Skip to content

TYP: io #36120

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 1 commit into from
Sep 4, 2020
Merged

TYP: io #36120

Show file tree
Hide file tree
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: 7 additions & 5 deletions pandas/io/excel/_util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List

from pandas.compat._optional import import_optional_dependency

from pandas.core.dtypes.common import is_integer, is_list_like
Expand Down Expand Up @@ -56,7 +58,7 @@ def get_writer(engine_name):
raise ValueError(f"No Excel writer '{engine_name}'") from err


def _excel2num(x):
def _excel2num(x: str) -> int:
"""
Convert Excel column name like 'AB' to 0-based column index.

Expand Down Expand Up @@ -88,7 +90,7 @@ def _excel2num(x):
return index - 1


def _range2cols(areas):
def _range2cols(areas: str) -> List[int]:
"""
Convert comma separated list of column names and ranges to indices.

Expand All @@ -109,12 +111,12 @@ def _range2cols(areas):
>>> _range2cols('A,C,Z:AB')
[0, 2, 25, 26, 27]
"""
cols = []
cols: List[int] = []

for rng in areas.split(","):
if ":" in rng:
rng = rng.split(":")
cols.extend(range(_excel2num(rng[0]), _excel2num(rng[1]) + 1))
rngs = rng.split(":")
cols.extend(range(_excel2num(rngs[0]), _excel2num(rngs[1]) + 1))
else:
cols.append(_excel2num(rng))

Expand Down
9 changes: 6 additions & 3 deletions pandas/io/formats/css.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import re
from typing import Optional
import warnings


Expand Down Expand Up @@ -93,6 +94,7 @@ def __call__(self, declarations_str, inherited=None):
props[prop] = val

# 2. resolve relative font size
font_size: Optional[float]
if props.get("font-size"):
if "font-size" in inherited:
em_pt = inherited["font-size"]
Expand Down Expand Up @@ -173,10 +175,11 @@ def _error():
warnings.warn(f"Unhandled size: {repr(in_val)}", CSSWarning)
return self.size_to_pt("1!!default", conversions=conversions)

try:
val, unit = re.match(r"^(\S*?)([a-zA-Z%!].*)", in_val).groups()
except AttributeError:
match = re.match(r"^(\S*?)([a-zA-Z%!].*)", in_val)
if match is None:
return _error()

val, unit = match.groups()
if val == "":
# hack for 'large' etc.
val = 1
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,6 @@ check_untyped_defs=False
[mypy-pandas.io.formats.console]
check_untyped_defs=False

[mypy-pandas.io.formats.css]
check_untyped_defs=False

[mypy-pandas.io.formats.csvs]
check_untyped_defs=False

Expand Down