From 9423fe3879a58d2395e9cad6216c1c95dffc9a5f Mon Sep 17 00:00:00 2001 From: "Kyle D. Kavanagh" Date: Tue, 9 Jul 2024 20:19:22 +0000 Subject: [PATCH] Optional import fixes --- .pre-commit-config.yaml | 1 + pyproject.toml | 1 + src/textual_fastdatatable/__init__.py | 2 -- src/textual_fastdatatable/backend.py | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d00c315..d066aff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,6 +17,7 @@ repos: - pytest - pyarrow-stubs - pandas-stubs + - polars exclude: "tests/snapshot_tests/" args: - "--disallow-untyped-calls" diff --git a/pyproject.toml b/pyproject.toml index 8e5a509..32738bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ pandas-stubs = { version="^2.1.1", python=">=3.9,<3.13" } pytest = "^7.3.1" pytest-asyncio = ">=0.21,<0.24" pytest-textual-snapshot = ">=0.4.0" +polars = ">=0.20.0" [tool.ruff] diff --git a/src/textual_fastdatatable/__init__.py b/src/textual_fastdatatable/__init__.py index 7fab6a2..44dfe00 100644 --- a/src/textual_fastdatatable/__init__.py +++ b/src/textual_fastdatatable/__init__.py @@ -1,6 +1,5 @@ from textual_fastdatatable.backend import ( ArrowBackend, - PolarsBackend, DataTableBackend, create_backend, ) @@ -9,7 +8,6 @@ __all__ = [ "DataTable", "ArrowBackend", - "PolarsBackend", "DataTableBackend", "create_backend", ] diff --git a/src/textual_fastdatatable/backend.py b/src/textual_fastdatatable/backend.py index 48fd124..ebfe23e 100644 --- a/src/textual_fastdatatable/backend.py +++ b/src/textual_fastdatatable/backend.py @@ -53,7 +53,7 @@ def create_backend( return ArrowBackend(data, max_rows=max_rows) if isinstance(data, pa.RecordBatch): return ArrowBackend.from_batches(data, max_rows=max_rows) - if isinstance(data, pl.DataFrame) and _HAS_POLARS: + if _HAS_POLARS and isinstance(data, pl.DataFrame): return PolarsBackend.from_dataframe(data, max_rows=max_rows) if isinstance(data, Path) or isinstance(data, str):