Skip to content

Commit

Permalink
chore: address lints
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Feb 4, 2024
1 parent 817cfaa commit 1ce8af0
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ibis/backends/clickhouse/tests/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_array_index(con, arr, gen_idx):
)
def test_array_concat(con, arrays):
expr = L([]).cast("!array<int8>")
expected = sum(arrays, [])
expected = sum(arrays, []) # noqa: RUF017
for arr in arrays:
expr += L(arr, type="!array<int8>")

Expand Down
8 changes: 4 additions & 4 deletions ibis/backends/pandas/execution/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def execute_timestamp_truncate(op, data, **kwargs):
def execute_interval_from_integer_series(op, data, **kwargs):
unit = op.unit.short
resolution = op.unit.plural
cls = OFFSET_CLASS.get(unit, None)
cls = OFFSET_CLASS.get(unit)

# fast path for timedelta conversion
if cls is None:
Expand All @@ -142,7 +142,7 @@ def execute_interval_from_integer_series(op, data, **kwargs):
def execute_interval_from_integer_integer_types(op, data, **kwargs):
unit = op.unit.short
resolution = op.unit.plural
cls = OFFSET_CLASS.get(unit, None)
cls = OFFSET_CLASS.get(unit)

Check warning on line 145 in ibis/backends/pandas/execution/temporal.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/pandas/execution/temporal.py#L145

Added line #L145 was not covered by tests

if cls is None:
return pd.Timedelta(data, unit=unit)
Expand All @@ -154,7 +154,7 @@ def execute_cast_integer_to_interval_series(op, data, type, **kwargs):
to = op.to
unit = to.unit.short
resolution = to.unit.plural
cls = OFFSET_CLASS.get(unit, None)
cls = OFFSET_CLASS.get(unit)

if cls is None:
return data.astype(f"timedelta64[{unit}]")
Expand All @@ -166,7 +166,7 @@ def execute_cast_integer_to_interval_integer_types(op, data, type, **kwargs):
to = op.to
unit = to.unit.short
resolution = to.unit.plural
cls = OFFSET_CLASS.get(unit, None)
cls = OFFSET_CLASS.get(unit)

if cls is None:
return pd.Timedelta(data, unit=unit)
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/postgres/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def to_ibis(cls, typ: sat.TypeEngine, nullable: bool = True) -> dt.DataType:
return dt.Map(dt.string, dt.string, nullable=nullable)
elif isinstance(typ, psql.INTERVAL):
field = typ.fields.upper()
if (unit := _postgres_interval_fields.get(field, None)) is None:
if (unit := _postgres_interval_fields.get(field)) is None:
raise ValueError(f"Unknown PostgreSQL interval field {field!r}")
elif unit in {"Y", "M"}:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/risingwave/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def to_ibis(cls, typ: sat.TypeEngine, nullable: bool = True) -> dt.DataType:
return dt.Map(dt.string, dt.string, nullable=nullable)
elif isinstance(typ, psql.INTERVAL):
field = typ.fields.upper()
if (unit := _postgres_interval_fields.get(field, None)) is None:
if (unit := _postgres_interval_fields.get(field)) is None:
raise ValueError(f"Unknown Risingwave interval field {field!r}")
elif unit in {"Y", "M"}:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/tests/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def test_literal_map_getitem_broadcast(backend, alltypes, df):
expr = lookup_table[alltypes.string_col]

result = expr.name("tmp").execute()
expected = df.string_col.apply(lambda x: value.get(x, None)).rename("tmp")
expected = df.string_col.apply(value.get).rename("tmp")

backend.assert_series_equal(result, expected)

Expand Down
2 changes: 1 addition & 1 deletion ibis/common/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ def match(self, values, context):
if result is NoMatch:
return NoMatch
else:
return sum(result, [])
return [el for lst in result for el in lst]


def _maybe_unwrap_capture(obj):
Expand Down
26 changes: 13 additions & 13 deletions ibis/common/tests/test_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ def test_generic_instance_of_with_covariant_typevar():
assert p.match(My(1, 2, "3"), context={}) == My(1, 2, "3")
assert p.describe() == "a My[int, Any]"

assert match(My[int, AnyType], v := My(1, 2, "3")) == v
assert match(My[int, int], v := My(1, 2, "3")) == v
assert match(My[int, AnyType], v := My(1, 2, "3")) == v # noqa: RUF018
assert match(My[int, int], v := My(1, 2, "3")) == v # noqa: RUF018
assert match(My[int, float], My(1, 2, "3")) is NoMatch
assert match(My[int, float], v := My(1, 2.0, "3")) == v
assert match(My[int, float], v := My(1, 2.0, "3")) == v # noqa: RUF018


def test_generic_instance_of_disallow_nested_coercion():
Expand Down Expand Up @@ -777,12 +777,12 @@ def test_matching():
assert Capture("pi", InstanceOf(float)) == "pi" @ InstanceOf(float)
assert Capture("pi", InstanceOf(float)) == "pi" @ InstanceOf(float)

assert match(Capture("pi", InstanceOf(float)), 3.14, ctx := {}) == 3.14
assert match(Capture("pi", InstanceOf(float)), 3.14, ctx := {}) == 3.14 # noqa: RUF018
assert ctx == {"pi": 3.14}
assert match("pi" @ InstanceOf(float), 3.14, ctx := {}) == 3.14
assert match("pi" @ InstanceOf(float), 3.14, ctx := {}) == 3.14 # noqa: RUF018
assert ctx == {"pi": 3.14}

assert match("pi" @ InstanceOf(float), 3.14, ctx := {}) == 3.14
assert match("pi" @ InstanceOf(float), 3.14, ctx := {}) == 3.14 # noqa: RUF018
assert ctx == {"pi": 3.14}

assert match(InstanceOf(int) | InstanceOf(float), 3) == 3
Expand Down Expand Up @@ -894,13 +894,13 @@ def test_matching_sequence_pattern_keeps_original_type():
def test_matching_sequence_with_captures():
v = list(range(1, 9))
assert match([1, 2, 3, 4, Some(...)], v) == v
assert match([1, 2, 3, 4, "rest" @ Some(...)], v, ctx := {}) == v
assert match([1, 2, 3, 4, "rest" @ Some(...)], v, ctx := {}) == v # noqa: RUF018
assert ctx == {"rest": [5, 6, 7, 8]}

v = list(range(5))
assert match([0, 1, x @ Some(...), 4], v, ctx := {}) == v
assert match([0, 1, x @ Some(...), 4], v, ctx := {}) == v # noqa: RUF018
assert ctx == {"x": [2, 3]}
assert match([0, 1, "var" @ Some(...), 4], v, ctx := {}) == v
assert match([0, 1, "var" @ Some(...), 4], v, ctx := {}) == v # noqa: RUF018
assert ctx == {"var": [2, 3]}

p = [
Expand All @@ -911,7 +911,7 @@ def test_matching_sequence_with_captures():
6,
]
v = [0, 1, 2, 3, 4.0, 5.0, 6]
assert match(p, v, ctx := {}) == v
assert match(p, v, ctx := {}) == v # noqa: RUF018
assert ctx == {"ints": [2, 3], "last_float": 5.0}


Expand All @@ -927,7 +927,7 @@ def test_matching_sequence_remaining():
assert match([1, 2, 3, Some(InstanceOf(int) & Between(0, 10))], five) == five
assert match([1, 2, 3, Some(InstanceOf(int) & Between(0, 4))], five) is NoMatch
assert match([1, 2, 3, Some(int, at_least=2)], four) is NoMatch
assert match([1, 2, 3, "res" @ Some(int, at_least=2)], five, ctx := {}) == five
assert match([1, 2, 3, "res" @ Some(int, at_least=2)], five, ctx := {}) == five # noqa: RUF018
assert ctx == {"res": [4, 5]}


Expand All @@ -944,12 +944,12 @@ def test_matching_sequence_complicated():
"a": [2, 3],
"b": [5, 6, 7],
}
assert match(pat, range(1, 10), ctx := {}) == list(range(1, 10))
assert match(pat, range(1, 10), ctx := {}) == list(range(1, 10)) # noqa: RUF018
assert ctx == expected

pat = [1, 2, Capture("remaining", Some(...))]
expected = {"remaining": [3, 4, 5, 6, 7, 8, 9]}
assert match(pat, range(1, 10), ctx := {}) == list(range(1, 10))
assert match(pat, range(1, 10), ctx := {}) == list(range(1, 10)) # noqa: RUF018
assert ctx == expected

v = [0, [1, 2, "3"], [1, 2, "4"], 3]
Expand Down
2 changes: 1 addition & 1 deletion ibis/common/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def evaluate_annotations(
else:
localns = dict(Self=f"{module_name}.{class_name}")
return {
k: eval(v, globalns, localns) if isinstance(v, str) else v # noqa: PGH001
k: eval(v, globalns, localns) if isinstance(v, str) else v
for k, v in annots.items()
}

Expand Down

0 comments on commit 1ce8af0

Please sign in to comment.