From eea8f8383d7b1862ab3d085ea98bd430dd00800a Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:09:15 +0000 Subject: [PATCH] mypy in pre-commit --- .pre-commit-config.yaml | 7 ++++++- narwhals/spec/__init__.py | 3 +++ tpch/q1.py | 2 +- tpch/q4.py | 2 +- tpch/q5.py | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index be4682e75..4c7ca1436 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,4 +8,9 @@ repos: args: [--fix] # Run the formatter. - id: ruff-format - \ No newline at end of file +- repo: https://github.com/pre-commit/mirrors-mypy + rev: 'v1.8.0' + hooks: + - id: mypy + additional_dependencies: ['polars==0.20.10', 'pytest==8.0.1'] + exclude: utils diff --git a/narwhals/spec/__init__.py b/narwhals/spec/__init__.py index 89502e37a..972753c8c 100644 --- a/narwhals/spec/__init__.py +++ b/narwhals/spec/__init__.py @@ -18,6 +18,9 @@ def alias(self, name: str) -> Self: def cast(self, dtype: DType) -> Self: ... + def __eq__(self, other: object) -> Expr: # type: ignore[override] + ... + def __and__(self, other: Any) -> Expr: ... diff --git a/tpch/q1.py b/tpch/q1.py index 34dd15249..82ff14d41 100644 --- a/tpch/q1.py +++ b/tpch/q1.py @@ -8,7 +8,7 @@ polars.Config.set_tbl_cols(10) -def q1(df_raw: Any) -> None: +def q1(df_raw: Any) -> Any: var_1 = datetime(1998, 9, 2) df, pl = to_polars_api(df_raw, version="0.20") result = ( diff --git a/tpch/q4.py b/tpch/q4.py index a79aa3c44..dc0d66847 100644 --- a/tpch/q4.py +++ b/tpch/q4.py @@ -13,7 +13,7 @@ def q4( lineitem_ds_raw: Any, orders_ds_raw: Any, -): +) -> Any: var_1 = datetime(1993, 7, 1) var_2 = datetime(1993, 10, 1) diff --git a/tpch/q5.py b/tpch/q5.py index b0859b4e6..aa36ec87a 100644 --- a/tpch/q5.py +++ b/tpch/q5.py @@ -15,7 +15,7 @@ def q5( lineitem_ds_raw: Any, orders_ds_raw: Any, supplier_ds_raw: Any, -): +) -> Any: var_1 = "ASIA" var_2 = datetime(1994, 1, 1) var_3 = datetime(1995, 1, 1)