From 1adbb87627bfdfe80622d78c57b6214957520be0 Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Tue, 28 Jan 2025 16:45:58 +0100 Subject: [PATCH] Move from `types_extensions` to `types` (#1586) `Annotated` has been part of `typing` since 3.9 --- pyiceberg/partitioning.py | 12 +----------- pyiceberg/table/metadata.py | 10 +--------- pyiceberg/table/refs.py | 3 +-- pyiceberg/table/sorting.py | 10 +--------- pyiceberg/table/update/__init__.py | 3 +-- tests/test_transforms.py | 3 +-- 6 files changed, 6 insertions(+), 35 deletions(-) diff --git a/pyiceberg/partitioning.py b/pyiceberg/partitioning.py index 01606a3414..2bed2ce899 100644 --- a/pyiceberg/partitioning.py +++ b/pyiceberg/partitioning.py @@ -21,16 +21,7 @@ from dataclasses import dataclass from datetime import date, datetime, time from functools import cached_property, singledispatch -from typing import ( - Any, - Dict, - Generic, - List, - Optional, - Tuple, - TypeVar, - Union, -) +from typing import Annotated, Any, Dict, Generic, List, Optional, Tuple, TypeVar, Union from urllib.parse import quote_plus from pydantic import ( @@ -40,7 +31,6 @@ WithJsonSchema, model_validator, ) -from typing_extensions import Annotated from pyiceberg.schema import Schema from pyiceberg.transforms import ( diff --git a/pyiceberg/table/metadata.py b/pyiceberg/table/metadata.py index 29067838e5..01a299db11 100644 --- a/pyiceberg/table/metadata.py +++ b/pyiceberg/table/metadata.py @@ -19,18 +19,10 @@ import datetime import uuid from copy import copy -from typing import ( - Any, - Dict, - List, - Literal, - Optional, - Union, -) +from typing import Annotated, Any, Dict, List, Literal, Optional, Union from pydantic import Field, field_serializer, field_validator, model_validator from pydantic import ValidationError as PydanticValidationError -from typing_extensions import Annotated from pyiceberg.exceptions import ValidationError from pyiceberg.partitioning import PARTITION_FIELD_ID_START, PartitionSpec, assign_fresh_partition_spec_ids diff --git a/pyiceberg/table/refs.py b/pyiceberg/table/refs.py index d87a319a16..2c9f7ae39e 100644 --- a/pyiceberg/table/refs.py +++ b/pyiceberg/table/refs.py @@ -15,10 +15,9 @@ # specific language governing permissions and limitations # under the License. from enum import Enum -from typing import Optional +from typing import Annotated, Optional from pydantic import Field, model_validator -from typing_extensions import Annotated from pyiceberg.exceptions import ValidationError from pyiceberg.typedef import IcebergBaseModel diff --git a/pyiceberg/table/sorting.py b/pyiceberg/table/sorting.py index e7c409fcff..244c8ba867 100644 --- a/pyiceberg/table/sorting.py +++ b/pyiceberg/table/sorting.py @@ -16,14 +16,7 @@ # under the License. # pylint: disable=keyword-arg-before-vararg from enum import Enum -from typing import ( - Any, - Callable, - Dict, - List, - Optional, - Union, -) +from typing import Annotated, Any, Callable, Dict, List, Optional, Union from pydantic import ( BeforeValidator, @@ -32,7 +25,6 @@ WithJsonSchema, model_validator, ) -from typing_extensions import Annotated from pyiceberg.schema import Schema from pyiceberg.transforms import IdentityTransform, Transform, parse_transform diff --git a/pyiceberg/table/update/__init__.py b/pyiceberg/table/update/__init__.py index 02b9719e31..935a105047 100644 --- a/pyiceberg/table/update/__init__.py +++ b/pyiceberg/table/update/__init__.py @@ -20,10 +20,9 @@ from abc import ABC, abstractmethod from datetime import datetime from functools import singledispatch -from typing import TYPE_CHECKING, Any, Dict, Generic, List, Literal, Optional, Tuple, TypeVar, Union, cast +from typing import TYPE_CHECKING, Annotated, Any, Dict, Generic, List, Literal, Optional, Tuple, TypeVar, Union, cast from pydantic import Field, field_validator, model_validator -from typing_extensions import Annotated from pyiceberg.exceptions import CommitFailedException from pyiceberg.partitioning import PARTITION_FIELD_ID_START, PartitionSpec diff --git a/tests/test_transforms.py b/tests/test_transforms.py index 3088719a06..51e8e23953 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -18,7 +18,7 @@ # pylint: disable=eval-used,protected-access,redefined-outer-name from datetime import date from decimal import Decimal -from typing import Any, Callable, Optional, Union +from typing import Annotated, Any, Callable, Optional, Union from uuid import UUID import mmh3 as mmh3 @@ -30,7 +30,6 @@ RootModel, WithJsonSchema, ) -from typing_extensions import Annotated from pyiceberg.expressions import ( AlwaysFalse,