diff --git a/daft/datasources.py b/daft/datasources.py index cd79972dbe..2d396f96e2 100644 --- a/daft/datasources.py +++ b/daft/datasources.py @@ -3,8 +3,10 @@ import sys from dataclasses import dataclass from enum import Enum +from typing import TYPE_CHECKING -from daft.io import IOConfig +if TYPE_CHECKING: + from daft.io import IOConfig if sys.version_info < (3, 8): from typing_extensions import Protocol diff --git a/daft/io/parquet.py b/daft/io/parquet.py index e9137bedf5..06e9b51c83 100644 --- a/daft/io/parquet.py +++ b/daft/io/parquet.py @@ -1,6 +1,6 @@ # isort: dont-add-import: from __future__ import annotations -from typing import Dict, List, Optional, Union +from typing import TYPE_CHECKING, Dict, List, Optional, Union import fsspec @@ -8,16 +8,18 @@ from daft.dataframe import DataFrame from daft.datasources import ParquetSourceInfo from daft.datatype import DataType -from daft.io import IOConfig from daft.io.common import _get_tabular_files_scan +if TYPE_CHECKING: + from daft.io import IOConfig + @PublicAPI def read_parquet( path: Union[str, List[str]], schema_hints: Optional[Dict[str, DataType]] = None, fs: Optional[fsspec.AbstractFileSystem] = None, - io_config: Optional[IOConfig] = None, + io_config: Optional["IOConfig"] = None, use_native_downloader: bool = False, ) -> DataFrame: """Creates a DataFrame from Parquet file(s) diff --git a/daft/table/schema_inference.py b/daft/table/schema_inference.py index 0957b16121..196192371c 100644 --- a/daft/table/schema_inference.py +++ b/daft/table/schema_inference.py @@ -9,7 +9,6 @@ from daft.datatype import DataType from daft.filesystem import _resolve_paths_and_filesystem -from daft.io import IOConfig from daft.logical.schema import Schema from daft.runners.partitioning import TableParseCSVOptions from daft.table import Table @@ -18,6 +17,8 @@ if TYPE_CHECKING: import fsspec + from daft.io import IOConfig + def from_csv( file: FileInput, diff --git a/daft/table/table_io.py b/daft/table/table_io.py index 2eae36872d..896c09db44 100644 --- a/daft/table/table_io.py +++ b/daft/table/table_io.py @@ -3,7 +3,7 @@ import contextlib import pathlib from collections.abc import Generator -from typing import IO, Union +from typing import IO, TYPE_CHECKING, Union from uuid import uuid4 import fsspec @@ -16,11 +16,13 @@ from daft.expressions import ExpressionsProjection from daft.filesystem import _resolve_paths_and_filesystem -from daft.io import IOConfig from daft.logical.schema import Schema from daft.runners.partitioning import TableParseCSVOptions, TableReadOptions from daft.table import Table +if TYPE_CHECKING: + from daft.io import IOConfig + FileInput = Union[pathlib.Path, str, IO[bytes]]