Skip to content

Commit

Permalink
Updated pre-commit tools. Fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinugu committed Dec 5, 2024
1 parent 1a7609c commit ec8d6ae
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml
types: [ yaml ]
Expand All @@ -14,7 +14,7 @@ repos:
hooks:
- id: poetry-check
- repo: https://github.com/google/yapf
rev: v0.40.2
rev: v0.43.0
hooks:
- id: yapf
name: "yapf"
Expand Down
4 changes: 2 additions & 2 deletions src/omnipy/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ def _parse_root_object(cls, root_obj: dict[str, ModelT]) -> Any: # noqa

def to_data(self) -> dict[str, Any]:
return {
key: self._check_value(val) for key,
val in GenericModel.dict(self, by_alias=True).get(DATA_KEY).items()
key: self._check_value(val)
for key, val in GenericModel.dict(self, by_alias=True).get(DATA_KEY).items()
}

def from_data(self,
Expand Down
8 changes: 4 additions & 4 deletions src/omnipy/data/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def _parse_none_in_mapping(plain_outer_type, outer_type_args, inner_val_type, va
for _ in chain(inner_key_union_types, inner_val_union_types)):
return plain_outer_type({
_parse_none_in_types(inner_key_union_types) if key is None else key:
_parse_none_in_types(inner_val_union_types) if val is None else val for key,
val in value.items()
_parse_none_in_types(inner_val_union_types) if val is None else val
for key, val in value.items()
})
return value

Expand All @@ -120,8 +120,8 @@ def _parse_none_in_typevar(inner_val_type):

def _parse_none_in_fixed_tuple(plain_outer_type, tuple_of_union_variant_types, value):
return plain_outer_type(
_parse_none_in_types(tuple_of_union_variant_types[i]) if val is None else val for i,
val in enumerate(value))
_parse_none_in_types(tuple_of_union_variant_types[i]) if val is None else val
for i, val in enumerate(value))


def _parse_none_in_union(flattened_union_variant_types, value):
Expand Down
5 changes: 3 additions & 2 deletions src/omnipy/data/mixins/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def available_data(self) -> IsDataset[type[ModelT]]:
self_with_data = cast(HasData, self)
copy = cast(HasData, self.__class__())
copy.data = {
key: val for key,
val in self_with_data.data.items() if not isinstance(val, (PendingData, FailedData))
key: val
for key, val in self_with_data.data.items()
if not isinstance(val, (PendingData, FailedData))
}
return cast(IsDataset[type[ModelT]], copy)

Expand Down
4 changes: 2 additions & 2 deletions src/omnipy/util/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def __init_subclass__(cls, **kwargs):
@classmethod
def _get_mixin_init_kwarg_params(cls) -> dict[str, inspect.Parameter]:
return {
key: param for param_dict in cls._init_params_per_mixin_cls.values() for key,
param in param_dict.items()
key: param for param_dict in cls._init_params_per_mixin_cls.values()
for key, param in param_dict.items()
}

@property
Expand Down
35 changes: 16 additions & 19 deletions src/omnipy/util/tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ def _html_row_with_attrs(celltag, unsafe, cell_values, colwidths, colaligns):
}
if unsafe:
values_with_attrs = [
"<{0}{1}>{2}</{0}>".format(celltag, alignment.get(a, ""), c) for c,
a in zip(cell_values, colaligns)
"<{0}{1}>{2}</{0}>".format(celltag, alignment.get(a, ""), c)
for c, a in zip(cell_values, colaligns)
]
else:
values_with_attrs = [
"<{0}{1}>{2}</{0}>".format(celltag, alignment.get(a, ""), htmlescape(c)) for c,
a in zip(cell_values, colaligns)
"<{0}{1}>{2}</{0}>".format(celltag, alignment.get(a, ""), htmlescape(c))
for c, a in zip(cell_values, colaligns)
]
rowhtml = "<tr>{}</tr>".format("".join(values_with_attrs).rstrip())
if celltag == "th": # it's a header row, create a new table header
Expand All @@ -191,8 +191,8 @@ def _moin_row_with_attrs(celltag, cell_values, colwidths, colaligns, header=""):
"decimal": '<style="text-align: right;">',
}
values_with_attrs = [
"{}{} {} ".format(celltag, alignment.get(a, ""), header + c + header) for c,
a in zip(cell_values, colaligns)
"{}{} {} ".format(celltag, alignment.get(a, ""), header + c + header)
for c, a in zip(cell_values, colaligns)
]
return "".join(values_with_attrs) + "||"

Expand Down Expand Up @@ -1162,8 +1162,9 @@ def _align_column(
# wcswidth and _visible_width don't count invisible characters;
# padfn doesn't need to apply another correction
padded_strings = [
"\n".join([padfn(w, s) for s, w in zip((ms.splitlines() or ms), mw)]) for ms,
mw in zip(strings, visible_widths)
"\n".join([padfn(w, s)
for s, w in zip((ms.splitlines() or ms), mw)])
for ms, mw in zip(strings, visible_widths)
]
else: # single-line cell values
if not enable_widechars and not has_invisible:
Expand Down Expand Up @@ -2163,11 +2164,9 @@ def tabulate(
missing_vals = list(missingval)
if len(missing_vals) < len(cols):
missing_vals.extend((len(cols) - len(missing_vals)) * [_DEFAULT_MISSINGVAL])
cols = [[_format(v, ct, fl_fmt, int_fmt, miss_v, has_invisible) for v in c] for c,
ct,
fl_fmt,
int_fmt,
miss_v in zip(cols, coltypes, float_formats, int_formats, missing_vals)]
cols = [[_format(v, ct, fl_fmt, int_fmt, miss_v,
has_invisible) for v in c] for c, ct, fl_fmt, int_fmt, miss_v in zip(
cols, coltypes, float_formats, int_formats, missing_vals)]

# align columns
# first set global alignment
Expand All @@ -2189,9 +2188,8 @@ def tabulate(
aligns[idx] = align
minwidths = ([width_fn(h) + min_padding for h in headers] if headers else [0] * len(cols))
cols = [
_align_column(c, a, minw, has_invisible, enable_widechars, is_multiline) for c,
a,
minw in zip(cols, aligns, minwidths)
_align_column(c, a, minw, has_invisible, enable_widechars, is_multiline)
for c, a, minw in zip(cols, aligns, minwidths)
]

aligns_headers = None
Expand Down Expand Up @@ -2220,9 +2218,8 @@ def tabulate(
aligns_headers[hidx] = align
minwidths = [max(minw, max(width_fn(cl) for cl in c)) for minw, c in zip(minwidths, t_cols)]
headers = [
_align_header(h, a, minw, width_fn(h), is_multiline, width_fn) for h,
a,
minw in zip(headers, aligns_headers, minwidths)
_align_header(h, a, minw, width_fn(h), is_multiline, width_fn)
for h, a, minw in zip(headers, aligns_headers, minwidths)
]
rows = list(zip(*cols))
else:
Expand Down

0 comments on commit ec8d6ae

Please sign in to comment.