Skip to content

Commit

Permalink
Incorporate ruff-mediated code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
rich-iannone committed Nov 26, 2024
1 parent 0e94fc2 commit ddd9575
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
14 changes: 5 additions & 9 deletions great_tables/_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Literal, TypedDict, TypeVar, cast

import babel
import faicons
from babel.dates import format_date, format_datetime, format_time
from typing_extensions import TypeAlias

import faicons

from ._gt_data import FormatFn, FormatFns, FormatInfo, GTData
from ._helpers import px
from ._locale import _get_currencies_data, _get_default_locales_data, _get_locales_data
Expand All @@ -24,16 +23,15 @@
DataFrameLike,
PlExpr,
SelectExpr,
_get_column_dtype,
is_na,
is_series,
to_list,
_get_column_dtype,
)
from ._text import _md_html, escape_pattern_str_latex
from ._utils import _str_detect, _str_replace
from ._utils_nanoplots import _generate_nanoplot


if TYPE_CHECKING:
from ._types import GTSelf

Expand Down Expand Up @@ -3766,9 +3764,10 @@ def to_html(self, val: Any):
return span

def to_latex(self, val: Any):
from ._gt_data import FormatterSkipElement
from warnings import warn

from ._gt_data import FormatterSkipElement

Check warning on line 3769 in great_tables/_formats.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_formats.py#L3769

Added line #L3769 was not covered by tests

warn("fmt_image() is not currently implemented in LaTeX output.")

return FormatterSkipElement()
Expand Down Expand Up @@ -4033,7 +4032,6 @@ class FmtIcon:
SPAN_TEMPLATE: ClassVar = '<span style="white-space:nowrap;">{}</span>'

def to_html(self, val: Any):

if is_na(self.dispatch_on, val):
return val

Check warning on line 4036 in great_tables/_formats.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_formats.py#L4036

Added line #L4036 was not covered by tests

Expand All @@ -4057,9 +4055,7 @@ def to_html(self, val: Any):
out: list[str] = []

for icon in icon_list:

if isinstance(self.fill_color, dict):

if icon in self.fill_color:
fill_color = self.fill_color[icon]
else:
Expand Down Expand Up @@ -4087,9 +4083,9 @@ def to_html(self, val: Any):
return span

def to_latex(self, val: Any):
from warnings import warn

Check warning on line 4086 in great_tables/_formats.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_formats.py#L4086

Added line #L4086 was not covered by tests

from ._gt_data import FormatterSkipElement

Check warning on line 4088 in great_tables/_formats.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_formats.py#L4088

Added line #L4088 was not covered by tests
from warnings import warn

warn("fmt_icon() is not currently implemented in LaTeX output.")

Check warning on line 4090 in great_tables/_formats.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_formats.py#L4090

Added line #L4090 was not covered by tests

Expand Down
5 changes: 0 additions & 5 deletions tests/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,6 @@ def test_fmt_image_path_http(url: str):


def test_fmt_icon_one_per_cell():

df = pd.DataFrame({"x": ["hippo", "burger", "pizza-slice"]})

gt = GT(df).fmt_icon(columns="x")
Expand All @@ -1505,7 +1504,6 @@ def test_fmt_icon_one_per_cell():


def test_fmt_icon_two_per_cell():

df = pd.DataFrame({"x": ["hippo,burger", "pizza-slice,fish"]})

gt = GT(df).fmt_icon(columns="x")
Expand All @@ -1522,7 +1520,6 @@ def test_fmt_icon_two_per_cell():


def test_fmt_icon_single_color():

df = pd.DataFrame({"x": ["hippo"]})

gt = GT(df).fmt_icon(columns="x", fill_color="red")
Expand All @@ -1531,7 +1528,6 @@ def test_fmt_icon_single_color():


def test_fmt_icon_two_colors():

df = pd.DataFrame({"x": ["dog,hippo"]})

gt = GT(df).fmt_icon(columns="x", fill_color={"dog": "red", "hippo": "blue"})
Expand All @@ -1541,7 +1537,6 @@ def test_fmt_icon_two_colors():


def test_fmt_icon_multiple_attrs():

df = pd.DataFrame({"x": ["hippo"]})

gt = GT(df).fmt_icon(
Expand Down

0 comments on commit ddd9575

Please sign in to comment.