diff --git a/pyproject.toml b/pyproject.toml index 4249045..cd7bbc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,6 +73,19 @@ markers = [ data_file = "/tmp/wherewolf/.coverage" timid = true +[tool.ty.rules] +# pyspark is an optional extra, so ty sees two different worlds. Without the extra +# installed, `from pyspark.sql import ...` is an unresolved-import; with it, that +# import resolves but `SparkSession.builder` does not (pyspark declares it as a +# classproperty ty cannot follow), producing unresolved-attribute instead. The two +# configurations therefore need opposite `ty: ignore` comments, and whichever set is +# not needed is reported as an unused directive. CI's lint leg installs +# `--extra spark`; a plain `uv sync` does not. Silencing unused-directive reports is +# what lets both suppressions coexist. Do not remove the `ty: ignore` comments in +# src/wherewolf/execution/spark_engine.py or tests/conftest.py because they look +# unused locally — they are load-bearing in the other configuration. +unused-ignore-comment = "ignore" + [dependency-groups] dev = [ "hatch>=1.17.0", diff --git a/src/wherewolf/execution/spark_engine.py b/src/wherewolf/execution/spark_engine.py index 8d01a47..e4dcbad 100644 --- a/src/wherewolf/execution/spark_engine.py +++ b/src/wherewolf/execution/spark_engine.py @@ -32,7 +32,7 @@ def _get_session(self) -> Any: spark_session = import_module("pyspark.sql").SparkSession root_session = ( # pyspark exposes `builder` dynamically, which ty cannot resolve. - spark_session.builder.appName("Wherewolf") + spark_session.builder.appName("Wherewolf") # ty: ignore[unresolved-attribute] .master("local[1]") .config("spark.driver.memory", "512m") .config("spark.ui.enabled", "false") diff --git a/tests/conftest.py b/tests/conftest.py index fcb0107..c048dd9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -29,7 +29,7 @@ def spark_session() -> Iterator[Any]: ) session = ( - SparkSession.builder.appName("wherewolf-tests") + SparkSession.builder.appName("wherewolf-tests") # ty: ignore[unresolved-attribute] .master("local[1]") .config("spark.driver.memory", "512m") .config("spark.ui.enabled", "false")