From 311a9344ac4815afaa14172cc3fa9950df058351 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 24 Jun 2024 15:24:19 +0100 Subject: [PATCH] lint --- Cargo.lock | 2 +- polars_xdt/functions.py | 12 ++++++------ polars_xdt/ranges.py | 3 ++- src/expressions.rs | 2 -- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ce9f52..f211f38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1149,7 +1149,7 @@ dependencies = [ [[package]] name = "polars_xdt" -version = "0.14.14" +version = "0.15.0" dependencies = [ "chrono", "chrono-tz 0.9.0", diff --git a/polars_xdt/functions.py b/polars_xdt/functions.py index f24cf58..ecf0a31 100644 --- a/polars_xdt/functions.py +++ b/polars_xdt/functions.py @@ -1,9 +1,6 @@ from __future__ import annotations -import re import sys -import warnings -from datetime import date, timedelta from pathlib import Path from typing import TYPE_CHECKING, Literal, Sequence @@ -17,6 +14,8 @@ from typing_extensions import TypeAlias if TYPE_CHECKING: + from datetime import date + from polars.type_aliases import IntoExpr RollStrategy: TypeAlias = Literal["raise", "forward", "backward"] @@ -50,7 +49,6 @@ def get_weekmask(weekend: Sequence[str]) -> list[bool]: return weekmask - def is_workday( expr: IntoExpr, *, @@ -104,7 +102,10 @@ def is_workday( expr = parse_into_expr(expr) weekend_int = [mapping[x] for x in weekend] if holidays is not None: - return ~(expr.dt.date().is_in(holidays) | expr.dt.weekday().is_in(weekend_int)) + return ~( + expr.dt.date().is_in(holidays) + | expr.dt.weekday().is_in(weekend_int) + ) return ~expr.dt.weekday().is_in(weekend_int) @@ -675,4 +676,3 @@ def arg_previous_greater(expr: IntoExpr) -> pl.Expr: is_elementwise=False, args=[expr], ) - diff --git a/polars_xdt/ranges.py b/polars_xdt/ranges.py index 4d9332e..c284fa4 100644 --- a/polars_xdt/ranges.py +++ b/polars_xdt/ranges.py @@ -41,7 +41,7 @@ def date_range( @overload def date_range( - start: date| IntoExprColumn, + start: date | IntoExprColumn, end: date | IntoExprColumn, interval: str | timedelta = "1d", *, @@ -119,6 +119,7 @@ def date_range( # noqa: PLR0913 │ 2023-01-09 │ │ 2023-01-10 │ └────────────┘ + """ if weekend == ("Sat", "Sun"): weekend_int = [6, 7] diff --git a/src/expressions.rs b/src/expressions.rs index 82faa10..e9e8b8e 100644 --- a/src/expressions.rs +++ b/src/expressions.rs @@ -54,7 +54,6 @@ pub fn from_local_datetime_output( Ok(Field::new(&field.name, dtype)) } - #[polars_expr(output_type=Int32)] fn month_delta(inputs: &[Series]) -> PolarsResult { let start_dates = &inputs[0]; @@ -62,7 +61,6 @@ fn month_delta(inputs: &[Series]) -> PolarsResult { impl_month_delta(start_dates, end_dates) } - #[polars_expr(output_type_func=to_local_datetime_output)] fn to_local_datetime(inputs: &[Series]) -> PolarsResult { let s1 = &inputs[0];