From 65ae527026aa04784332c3ff27e64a2e53400bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Anast=C3=A1cio?= Date: Tue, 12 Mar 2024 11:03:31 -0300 Subject: [PATCH] Decouple imports reported by mypy linter --- pyiceberg/avro/file.py | 3 ++- pyiceberg/catalog/__init__.py | 2 +- pyiceberg/catalog/dynamodb.py | 4 +--- pyiceberg/catalog/rest.py | 4 +--- pyiceberg/cli/output.py | 3 ++- pyiceberg/io/pyarrow.py | 2 +- pyiceberg/table/__init__.py | 3 +-- pyproject.toml | 1 + tests/avro/test_file.py | 2 +- tests/avro/test_resolver.py | 3 ++- tests/io/test_pyarrow.py | 2 +- 11 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pyiceberg/avro/file.py b/pyiceberg/avro/file.py index 2f21e165b4..d0da7651b7 100644 --- a/pyiceberg/avro/file.py +++ b/pyiceberg/avro/file.py @@ -35,7 +35,8 @@ TypeVar, ) -from pyiceberg.avro.codecs import KNOWN_CODECS, Codec +from pyiceberg.avro.codecs import KNOWN_CODECS +from pyiceberg.avro.codecs.codec import Codec from pyiceberg.avro.decoder import BinaryDecoder, new_decoder from pyiceberg.avro.encoder import BinaryEncoder from pyiceberg.avro.reader import Reader diff --git a/pyiceberg/catalog/__init__.py b/pyiceberg/catalog/__init__.py index db83658f1f..4f7b5a3292 100644 --- a/pyiceberg/catalog/__init__.py +++ b/pyiceberg/catalog/__init__.py @@ -46,8 +46,8 @@ CommitTableRequest, CommitTableResponse, Table, - TableMetadata, ) +from pyiceberg.table.metadata import TableMetadata from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder from pyiceberg.typedef import ( EMPTY_DICT, diff --git a/pyiceberg/catalog/dynamodb.py b/pyiceberg/catalog/dynamodb.py index b7b0f3ddb1..266dd6353d 100644 --- a/pyiceberg/catalog/dynamodb.py +++ b/pyiceberg/catalog/dynamodb.py @@ -34,8 +34,6 @@ PREVIOUS_METADATA_LOCATION, TABLE_TYPE, Catalog, - Identifier, - Properties, PropertiesUpdateSummary, ) from pyiceberg.exceptions import ( @@ -56,7 +54,7 @@ from pyiceberg.table import CommitTableRequest, CommitTableResponse, Table from pyiceberg.table.metadata import new_table_metadata from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder -from pyiceberg.typedef import EMPTY_DICT +from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties if TYPE_CHECKING: import pyarrow as pa diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py index a5f33f02dd..f67fe2c1fd 100644 --- a/pyiceberg/catalog/rest.py +++ b/pyiceberg/catalog/rest.py @@ -38,8 +38,6 @@ URI, WAREHOUSE_LOCATION, Catalog, - Identifier, - Properties, PropertiesUpdateSummary, ) from pyiceberg.exceptions import ( @@ -68,7 +66,7 @@ ) from pyiceberg.table.metadata import TableMetadata from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder, assign_fresh_sort_order_ids -from pyiceberg.typedef import EMPTY_DICT, UTF8, IcebergBaseModel +from pyiceberg.typedef import EMPTY_DICT, UTF8, IcebergBaseModel, Identifier, Properties from pyiceberg.types import transform_dict_value_to_str if TYPE_CHECKING: diff --git a/pyiceberg/cli/output.py b/pyiceberg/cli/output.py index 18cdab1556..67081fbd8d 100644 --- a/pyiceberg/cli/output.py +++ b/pyiceberg/cli/output.py @@ -31,7 +31,8 @@ from pyiceberg.partitioning import PartitionSpec from pyiceberg.schema import Schema -from pyiceberg.table import Table, TableMetadata +from pyiceberg.table import Table +from pyiceberg.table.metadata import TableMetadata from pyiceberg.table.refs import SnapshotRefType from pyiceberg.typedef import IcebergBaseModel, Identifier, Properties diff --git a/pyiceberg/io/pyarrow.py b/pyiceberg/io/pyarrow.py index 7192513a2d..f1e4d302ec 100644 --- a/pyiceberg/io/pyarrow.py +++ b/pyiceberg/io/pyarrow.py @@ -69,8 +69,8 @@ ) from sortedcontainers import SortedList -from pyiceberg.avro.resolver import ResolveError from pyiceberg.conversions import to_bytes +from pyiceberg.exceptions import ResolveError from pyiceberg.expressions import ( AlwaysTrue, BooleanExpression, diff --git a/pyiceberg/table/__init__.py b/pyiceberg/table/__init__.py index b244dfb16d..c5dd2e8e70 100644 --- a/pyiceberg/table/__init__.py +++ b/pyiceberg/table/__init__.py @@ -71,7 +71,6 @@ from pyiceberg.partitioning import ( INITIAL_PARTITION_SPEC_ID, PARTITION_FIELD_ID_START, - IdentityTransform, PartitionField, PartitionSpec, _PartitionNameGenerator, @@ -108,7 +107,7 @@ update_snapshot_summaries, ) from pyiceberg.table.sorting import SortOrder -from pyiceberg.transforms import TimeTransform, Transform, VoidTransform +from pyiceberg.transforms import IdentityTransform, TimeTransform, Transform, VoidTransform from pyiceberg.typedef import ( EMPTY_DICT, IcebergBaseModel, diff --git a/pyproject.toml b/pyproject.toml index dcb65f7c5d..4095f325da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -149,6 +149,7 @@ warn_unreachable = true warn_unused_ignores = true disallow_any_generics = true disallow_untyped_defs = true +implicit_reexport = false [[tool.mypy.overrides]] module = "pyarrow.*" diff --git a/tests/avro/test_file.py b/tests/avro/test_file.py index 74458fd923..8a3aaf72cb 100644 --- a/tests/avro/test_file.py +++ b/tests/avro/test_file.py @@ -26,7 +26,7 @@ from fastavro import reader, writer import pyiceberg.avro.file as avro -from pyiceberg.avro.codecs import DeflateCodec +from pyiceberg.avro.codecs.deflate import DeflateCodec from pyiceberg.avro.file import META_SCHEMA, AvroFileHeader from pyiceberg.io.pyarrow import PyArrowFileIO from pyiceberg.manifest import ( diff --git a/tests/avro/test_resolver.py b/tests/avro/test_resolver.py index c08ca235fb..07d41491fa 100644 --- a/tests/avro/test_resolver.py +++ b/tests/avro/test_resolver.py @@ -32,7 +32,7 @@ StringReader, StructReader, ) -from pyiceberg.avro.resolver import ResolveError, resolve_reader, resolve_writer +from pyiceberg.avro.resolver import resolve_reader, resolve_writer from pyiceberg.avro.writer import ( BinaryWriter, DefaultWriter, @@ -44,6 +44,7 @@ StringWriter, StructWriter, ) +from pyiceberg.exceptions import ResolveError from pyiceberg.io.pyarrow import PyArrowFileIO from pyiceberg.manifest import MANIFEST_ENTRY_SCHEMAS from pyiceberg.schema import Schema diff --git a/tests/io/test_pyarrow.py b/tests/io/test_pyarrow.py index 2acffdfdf9..c2d8f7bd12 100644 --- a/tests/io/test_pyarrow.py +++ b/tests/io/test_pyarrow.py @@ -28,8 +28,8 @@ import pytest from pyarrow.fs import FileType, LocalFileSystem -from pyiceberg.avro.resolver import ResolveError from pyiceberg.catalog.noop import NoopCatalog +from pyiceberg.exceptions import ResolveError from pyiceberg.expressions import ( AlwaysFalse, AlwaysTrue,