Skip to content

Commit

Permalink
Remove typing as tp imports (#2147)
Browse files Browse the repository at this point in the history
  • Loading branch information
zundertj committed Dec 23, 2021
1 parent 216ca46 commit 8c88270
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions py-polars/polars/_html.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
"""
Module for formatting output data in HTML.
"""
import typing as tp
from textwrap import dedent
from types import TracebackType
from typing import Dict, Iterable, Optional, Type
from typing import Dict, Iterable, List, Optional, Type

from polars.datatypes import Object, dtype_to_ffiname


class Tag:
def __init__(
self,
elements: tp.List[str],
elements: List[str],
tag: str,
attributes: Optional[Dict[str, str]] = None,
):
Expand Down Expand Up @@ -42,7 +41,7 @@ def __exit__(
class HTMLFormatter:
def __init__(self, df: "DataFrame", max_cols: int = 75, max_rows: int = 40): # type: ignore # noqa
self.df = df
self.elements: tp.List[str] = []
self.elements: List[str] = []
self.max_cols = max_cols
self.max_rows = max_rows
self.row_idx: Iterable[int]
Expand Down Expand Up @@ -102,7 +101,7 @@ def write_body(self) -> None:
def write(self, inner: str) -> None:
self.elements.append(inner)

def render(self) -> tp.List[str]:
def render(self) -> List[str]:
with Tag(self.elements, "table", {"border": "1", "class": "dataframe"}):
self.write_header()
self.write_body()
Expand Down Expand Up @@ -139,7 +138,7 @@ def write_style(self) -> None:
template = dedent("\n".join((template_first, template_mid, template_last)))
self.write(template)

def render(self) -> tp.List[str]:
def render(self) -> List[str]:
"""
Return the lines needed to render a HTML table.
"""
Expand Down
6 changes: 3 additions & 3 deletions py-polars/tests/test_df.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# flake8: noqa: W191,E101
import sys
import typing as tp
from builtins import range
from datetime import datetime
from io import BytesIO
from typing import Any, Iterator
from unittest.mock import patch

import numpy as np
Expand Down Expand Up @@ -1432,7 +1432,7 @@ def test_transpose() -> None:
)
assert expected.frame_equal(out)

def name_generator() -> tp.Iterator[str]:
def name_generator() -> Iterator[str]:
base_name = "my_column_"
count = 0
while True:
Expand Down Expand Up @@ -1664,7 +1664,7 @@ def test_pivot_list() -> None:


@pytest.mark.parametrize("as_series,inner_dtype", [(True, pl.Series), (False, list)])
def test_to_dict(as_series: bool, inner_dtype: tp.Any) -> None:
def test_to_dict(as_series: bool, inner_dtype: Any) -> None:
df = pl.DataFrame(
{
"A": [1, 2, 3, 4, 5],
Expand Down

0 comments on commit 8c88270

Please sign in to comment.