Skip to content

Commit

Permalink
Fix more linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
satrana42 committed Oct 10, 2024
1 parent f0e6435 commit fdb4d0f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
20 changes: 15 additions & 5 deletions fennel/client_tests/test_date_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,17 @@ class DebitFeatures:
min: Decimal[2] = F(DebitDataset.min, default=0.0)
max: Decimal[2] = F(DebitDataset.max, default=0.0)
earliest_transaction_ts: datetime = F(
DebitDataset.earliest_transaction_ts, default=default_ts)
DebitDataset.earliest_transaction_ts, default=default_ts
)
latest_transaction_ts: datetime = F(
DebitDataset.latest_transaction_ts, default=default_ts)
DebitDataset.latest_transaction_ts, default=default_ts
)
earliest_transaction_date: date = F(
DebitDataset.earliest_transaction_date, default=default_date)
DebitDataset.earliest_transaction_date, default=default_date
)
latest_transaction_date: date = F(
DebitDataset.latest_transaction_date, default=default_date)
DebitDataset.latest_transaction_date, default=default_date
)
stddev: float = F(DebitDataset.stddev, default=0.0)
median: float = F(DebitDataset.median, default=0.0)

Expand Down Expand Up @@ -178,7 +182,13 @@ def test_date_type(client):
],
"is_debit": [True, False, True, True, False],
"transaction_ts": [now, now_l1d, now_l1d, now, now],
"transaction_date": [now_date, now_l1d_date, now_l1d_date, now_date, now_date],
"transaction_date": [
now_date,
now_l1d_date,
now_l1d_date,
now_date,
now_date,
],
"timestamp": [now, now_l1d, now_l1d, now_l1d, now],
}
)
Expand Down
10 changes: 8 additions & 2 deletions fennel/datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,10 @@ def visitAggregate(self, obj) -> DSSchema:
elif isinstance(agg, Min):
dtype = input_schema.get_type(agg.of)
primtive_dtype = get_primitive_dtype_with_optional(dtype)
allowed_types = primitive_numeric_types + [datetime.date, datetime.datetime]
allowed_types = primitive_numeric_types + [
datetime.date,
datetime.datetime,
]
if primtive_dtype not in allowed_types:
raise TypeError(
f"invalid min: type of field `{agg.of}` is not int, float, date or datetime"
Expand All @@ -2789,7 +2792,10 @@ def visitAggregate(self, obj) -> DSSchema:
elif isinstance(agg, Max):
dtype = input_schema.get_type(agg.of)
primtive_dtype = get_primitive_dtype_with_optional(dtype)
allowed_types = primitive_numeric_types + [datetime.date, datetime.datetime]
allowed_types = primitive_numeric_types + [
datetime.date,
datetime.datetime,
]
if primtive_dtype not in allowed_types:
raise TypeError(
f"invalid max: type of field `{agg.of}` is not int, float, date or datetime"
Expand Down
3 changes: 2 additions & 1 deletion fennel/datasets/test_schema_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ def pipeline(cls, a: Dataset):
)

assert (
str(e.value) == """invalid max: type of field `b` is not int, float, date or datetime"""
str(e.value)
== """invalid max: type of field `b` is not int, float, date or datetime"""
)


Expand Down

0 comments on commit fdb4d0f

Please sign in to comment.