diff --git a/pyiceberg/avro/codecs/__init__.py b/pyiceberg/avro/codecs/__init__.py index f33f25f1cd..96a299cc45 100644 --- a/pyiceberg/avro/codecs/__init__.py +++ b/pyiceberg/avro/codecs/__init__.py @@ -26,9 +26,7 @@ from __future__ import annotations -from typing import Literal - -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias from pyiceberg.avro.codecs.bzip2 import BZip2Codec from pyiceberg.avro.codecs.codec import Codec diff --git a/pyiceberg/avro/file.py b/pyiceberg/avro/file.py index f1be9c3928..8877e8bf80 100644 --- a/pyiceberg/avro/file.py +++ b/pyiceberg/avro/file.py @@ -22,11 +22,11 @@ import io import json import os +from collections.abc import Callable from dataclasses import dataclass from enum import Enum from types import TracebackType from typing import ( - Callable, Generic, TypeVar, ) diff --git a/pyiceberg/avro/reader.py b/pyiceberg/avro/reader.py index d33c054beb..cf8e5154e7 100644 --- a/pyiceberg/avro/reader.py +++ b/pyiceberg/avro/reader.py @@ -27,13 +27,12 @@ from __future__ import annotations from abc import abstractmethod +from collections.abc import Callable, Mapping from dataclasses import dataclass from dataclasses import field as dataclassfield from decimal import Decimal from typing import ( Any, - Callable, - Mapping, ) from uuid import UUID diff --git a/pyiceberg/avro/resolver.py b/pyiceberg/avro/resolver.py index 900f47dab6..65f06ca8b1 100644 --- a/pyiceberg/avro/resolver.py +++ b/pyiceberg/avro/resolver.py @@ -15,10 +15,8 @@ # specific language governing permissions and limitations # under the License. # pylint: disable=arguments-renamed,unused-argument +from collections.abc import Callable from enum import Enum -from typing import ( - Callable, -) from pyiceberg.avro.decoder import BinaryDecoder from pyiceberg.avro.reader import ( diff --git a/pyiceberg/catalog/__init__.py b/pyiceberg/catalog/__init__.py index b13d9294a0..a4f1d47bea 100644 --- a/pyiceberg/catalog/__init__.py +++ b/pyiceberg/catalog/__init__.py @@ -22,12 +22,12 @@ import re import uuid from abc import ABC, abstractmethod +from collections.abc import Callable from dataclasses import dataclass from enum import Enum from typing import ( TYPE_CHECKING, Any, - Callable, cast, ) diff --git a/pyiceberg/cli/console.py b/pyiceberg/cli/console.py index e7774e3b2f..9baa813eff 100644 --- a/pyiceberg/cli/console.py +++ b/pyiceberg/cli/console.py @@ -15,10 +15,10 @@ # specific language governing permissions and limitations # under the License. # pylint: disable=broad-except,redefined-builtin,redefined-outer-name +from collections.abc import Callable from functools import wraps from typing import ( Any, - Callable, Literal, ) diff --git a/pyiceberg/conversions.py b/pyiceberg/conversions.py index b4eaea1b8e..8739a1ab08 100644 --- a/pyiceberg/conversions.py +++ b/pyiceberg/conversions.py @@ -31,13 +31,13 @@ import codecs import uuid +from collections.abc import Callable from datetime import date, datetime, time from decimal import Decimal from functools import singledispatch from struct import Struct from typing import ( Any, - Callable, ) from pyiceberg.typedef import UTF8, L diff --git a/pyiceberg/expressions/__init__.py b/pyiceberg/expressions/__init__.py index ff1b02bf48..c56a1de14f 100644 --- a/pyiceberg/expressions/__init__.py +++ b/pyiceberg/expressions/__init__.py @@ -19,8 +19,9 @@ import builtins from abc import ABC, abstractmethod +from collections.abc import Callable, Iterable, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence, cast +from typing import TYPE_CHECKING, Any, cast from typing import Literal as TypingLiteral from pydantic import ConfigDict, Field diff --git a/pyiceberg/expressions/visitors.py b/pyiceberg/expressions/visitors.py index 1362945a00..58143c1306 100644 --- a/pyiceberg/expressions/visitors.py +++ b/pyiceberg/expressions/visitors.py @@ -16,10 +16,10 @@ # under the License. import math from abc import ABC, abstractmethod +from collections.abc import Callable from functools import singledispatch from typing import ( Any, - Callable, Generic, SupportsFloat, TypeVar, diff --git a/pyiceberg/io/fsspec.py b/pyiceberg/io/fsspec.py index 1eef9c1eee..5898a22675 100644 --- a/pyiceberg/io/fsspec.py +++ b/pyiceberg/io/fsspec.py @@ -22,12 +22,12 @@ import logging import os import threading +from collections.abc import Callable from copy import copy from functools import lru_cache from typing import ( TYPE_CHECKING, Any, - Callable, ) from urllib.parse import urlparse diff --git a/pyiceberg/io/pyarrow.py b/pyiceberg/io/pyarrow.py index 0210839df5..ad4c761d03 100644 --- a/pyiceberg/io/pyarrow.py +++ b/pyiceberg/io/pyarrow.py @@ -37,6 +37,7 @@ import uuid import warnings from abc import ABC, abstractmethod +from collections.abc import Callable, Iterable, Iterator from copy import copy from dataclasses import dataclass from enum import Enum @@ -44,10 +45,7 @@ from typing import ( TYPE_CHECKING, Any, - Callable, Generic, - Iterable, - Iterator, TypeVar, cast, ) diff --git a/pyiceberg/manifest.py b/pyiceberg/manifest.py index ab1e951100..ca2883884f 100644 --- a/pyiceberg/manifest.py +++ b/pyiceberg/manifest.py @@ -19,12 +19,12 @@ import math import threading from abc import ABC, abstractmethod +from collections.abc import Iterator from copy import copy from enum import Enum from types import TracebackType from typing import ( Any, - Iterator, Literal, ) diff --git a/pyiceberg/schema.py b/pyiceberg/schema.py index 5d622d2549..57ef915c04 100644 --- a/pyiceberg/schema.py +++ b/pyiceberg/schema.py @@ -20,12 +20,12 @@ import builtins import itertools from abc import ABC, abstractmethod +from collections.abc import Callable from dataclasses import dataclass from functools import cached_property, partial, singledispatch from typing import ( TYPE_CHECKING, Any, - Callable, Generic, Literal, TypeVar, diff --git a/pyiceberg/serializers.py b/pyiceberg/serializers.py index e2994884c6..726e6b5f62 100644 --- a/pyiceberg/serializers.py +++ b/pyiceberg/serializers.py @@ -19,7 +19,7 @@ import codecs import gzip from abc import ABC, abstractmethod -from typing import Callable +from collections.abc import Callable from pyiceberg.io import InputFile, InputStream, OutputFile from pyiceberg.table.metadata import TableMetadata, TableMetadataUtil diff --git a/pyiceberg/table/__init__.py b/pyiceberg/table/__init__.py index 56cab7618f..027992fb47 100644 --- a/pyiceberg/table/__init__.py +++ b/pyiceberg/table/__init__.py @@ -21,6 +21,7 @@ import uuid import warnings from abc import ABC, abstractmethod +from collections.abc import Callable, Iterable, Iterator from dataclasses import dataclass from functools import cached_property from itertools import chain @@ -28,9 +29,6 @@ from typing import ( TYPE_CHECKING, Any, - Callable, - Iterable, - Iterator, TypeVar, ) diff --git a/pyiceberg/table/inspect.py b/pyiceberg/table/inspect.py index c64fcfbf12..bfe2fffa56 100644 --- a/pyiceberg/table/inspect.py +++ b/pyiceberg/table/inspect.py @@ -17,8 +17,9 @@ from __future__ import annotations import itertools +from collections.abc import Iterator from datetime import datetime, timezone -from typing import TYPE_CHECKING, Any, Iterator +from typing import TYPE_CHECKING, Any from pyiceberg.conversions import from_bytes from pyiceberg.expressions import AlwaysTrue, BooleanExpression diff --git a/pyiceberg/table/name_mapping.py b/pyiceberg/table/name_mapping.py index cce87f1468..1cf6bc0106 100644 --- a/pyiceberg/table/name_mapping.py +++ b/pyiceberg/table/name_mapping.py @@ -26,8 +26,9 @@ import builtins from abc import ABC, abstractmethod from collections import ChainMap +from collections.abc import Iterator from functools import cached_property, singledispatch -from typing import Any, Generic, Iterator, TypeVar +from typing import Any, Generic, TypeVar from pydantic import Field, conlist, field_validator, model_serializer diff --git a/pyiceberg/table/snapshots.py b/pyiceberg/table/snapshots.py index 20646b8160..4ef1645df6 100644 --- a/pyiceberg/table/snapshots.py +++ b/pyiceberg/table/snapshots.py @@ -19,8 +19,9 @@ import time import warnings from collections import defaultdict +from collections.abc import Iterable, Mapping from enum import Enum -from typing import TYPE_CHECKING, Any, Iterable, Mapping +from typing import TYPE_CHECKING, Any from pydantic import Field, PrivateAttr, model_serializer diff --git a/pyiceberg/table/sorting.py b/pyiceberg/table/sorting.py index 4a8b85c3cd..5243d7b184 100644 --- a/pyiceberg/table/sorting.py +++ b/pyiceberg/table/sorting.py @@ -15,8 +15,9 @@ # specific language governing permissions and limitations # under the License. # pylint: disable=keyword-arg-before-vararg +from collections.abc import Callable from enum import Enum -from typing import Annotated, Any, Callable +from typing import Annotated, Any from pydantic import ( BeforeValidator, diff --git a/pyiceberg/table/update/snapshot.py b/pyiceberg/table/update/snapshot.py index 15fc82f72a..e89cd45d34 100644 --- a/pyiceberg/table/update/snapshot.py +++ b/pyiceberg/table/update/snapshot.py @@ -21,10 +21,11 @@ import uuid from abc import abstractmethod from collections import defaultdict +from collections.abc import Callable from concurrent.futures import Future from datetime import datetime from functools import cached_property -from typing import TYPE_CHECKING, Callable, Generic +from typing import TYPE_CHECKING, Generic from sortedcontainers import SortedList diff --git a/pyiceberg/table/update/validate.py b/pyiceberg/table/update/validate.py index 2586c83af9..0cda688f2a 100644 --- a/pyiceberg/table/update/validate.py +++ b/pyiceberg/table/update/validate.py @@ -14,7 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from typing import Iterator +from collections.abc import Iterator from pyiceberg.exceptions import ValidationException from pyiceberg.expressions import BooleanExpression diff --git a/pyiceberg/transforms.py b/pyiceberg/transforms.py index 896a04527d..7381e85008 100644 --- a/pyiceberg/transforms.py +++ b/pyiceberg/transforms.py @@ -21,9 +21,10 @@ import struct import types from abc import ABC, abstractmethod +from collections.abc import Callable from enum import IntEnum from functools import singledispatch -from typing import TYPE_CHECKING, Any, Callable, Generic, Optional, TypeVar +from typing import TYPE_CHECKING, Any, Generic, Optional, TypeVar from typing import Literal as LiteralType from uuid import UUID diff --git a/pyiceberg/typedef.py b/pyiceberg/typedef.py index e4a9501687..ebe1ba3c24 100644 --- a/pyiceberg/typedef.py +++ b/pyiceberg/typedef.py @@ -17,15 +17,16 @@ from __future__ import annotations from abc import abstractmethod +from collections.abc import Callable from datetime import date, datetime, time from decimal import Decimal from typing import ( TYPE_CHECKING, Any, - Callable, Generic, Literal, Protocol, + TypeAlias, TypeVar, Union, runtime_checkable, @@ -33,7 +34,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, RootModel -from typing_extensions import Self, TypeAlias +from typing_extensions import Self if TYPE_CHECKING: from pyiceberg.types import StructType diff --git a/pyiceberg/utils/bin_packing.py b/pyiceberg/utils/bin_packing.py index bee7bd81b3..dc2987c3a4 100644 --- a/pyiceberg/utils/bin_packing.py +++ b/pyiceberg/utils/bin_packing.py @@ -16,10 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Callable, Iterable from typing import ( - Callable, Generic, - Iterable, TypeVar, ) diff --git a/pyiceberg/utils/deprecated.py b/pyiceberg/utils/deprecated.py index accbd9d5fe..b5bb6d01cd 100644 --- a/pyiceberg/utils/deprecated.py +++ b/pyiceberg/utils/deprecated.py @@ -16,7 +16,8 @@ # under the License. import functools import warnings -from typing import Any, Callable +from collections.abc import Callable +from typing import Any def deprecated(deprecated_in: str, removed_in: str, help_message: str | None = None) -> Callable: # type: ignore diff --git a/pyiceberg/utils/lazydict.py b/pyiceberg/utils/lazydict.py index f1a3718dc7..b110b6291b 100644 --- a/pyiceberg/utils/lazydict.py +++ b/pyiceberg/utils/lazydict.py @@ -15,10 +15,8 @@ # specific language governing permissions and limitations # under the License. +from collections.abc import Iterator, Mapping, Sequence from typing import ( - Iterator, - Mapping, - Sequence, TypeVar, cast, ) diff --git a/ruff.toml b/ruff.toml index 36391b033a..1ce052288e 100644 --- a/ruff.toml +++ b/ruff.toml @@ -58,8 +58,7 @@ select = [ "UP", # pyupgrade ] ignore = [ - "E501", - "UP035" + "E501" ] # Allow autofix for all enabled rules (when `--fix`) is provided. diff --git a/tests/avro/test_decoder.py b/tests/avro/test_decoder.py index 26b0a0d15a..163ad8405e 100644 --- a/tests/avro/test_decoder.py +++ b/tests/avro/test_decoder.py @@ -18,9 +18,9 @@ import itertools import struct +from collections.abc import Callable from io import SEEK_SET from types import TracebackType -from typing import Callable from unittest.mock import MagicMock, patch import pytest diff --git a/tests/avro/test_reader.py b/tests/avro/test_reader.py index c47b27e581..320fc33793 100644 --- a/tests/avro/test_reader.py +++ b/tests/avro/test_reader.py @@ -16,7 +16,7 @@ # under the License. # pylint:disable=protected-access import json -from typing import Callable +from collections.abc import Callable import pytest diff --git a/tests/catalog/integration_test_dynamodb.py b/tests/catalog/integration_test_dynamodb.py index 4ffe98a4b8..6ae14bca06 100644 --- a/tests/catalog/integration_test_dynamodb.py +++ b/tests/catalog/integration_test_dynamodb.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from typing import Generator +from collections.abc import Generator import boto3 import pytest diff --git a/tests/catalog/integration_test_glue.py b/tests/catalog/integration_test_glue.py index a3b8f17c30..c429770268 100644 --- a/tests/catalog/integration_test_glue.py +++ b/tests/catalog/integration_test_glue.py @@ -16,7 +16,8 @@ # under the License. import time -from typing import Any, Generator +from collections.abc import Generator +from typing import Any from uuid import uuid4 import boto3 diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py index efc89c7c7e..b8bee00225 100644 --- a/tests/catalog/test_rest.py +++ b/tests/catalog/test_rest.py @@ -17,7 +17,8 @@ # pylint: disable=redefined-outer-name,unused-argument import base64 import os -from typing import Any, Callable, cast +from collections.abc import Callable +from typing import Any, cast from unittest import mock import pytest diff --git a/tests/catalog/test_sql.py b/tests/catalog/test_sql.py index 00868a5739..22b9883c6f 100644 --- a/tests/catalog/test_sql.py +++ b/tests/catalog/test_sql.py @@ -16,8 +16,9 @@ # under the License. import os +from collections.abc import Generator from pathlib import Path -from typing import Any, Generator, cast +from typing import Any, cast import pyarrow as pa import pytest diff --git a/tests/conftest.py b/tests/conftest.py index fcd188f6a4..85c15d3e0b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,6 +31,7 @@ import string import time import uuid +from collections.abc import Generator from datetime import date, datetime, timezone from pathlib import Path from random import choice, randint @@ -38,7 +39,6 @@ from typing import ( TYPE_CHECKING, Any, - Generator, ) import boto3 diff --git a/tests/integration/test_add_files.py b/tests/integration/test_add_files.py index 653549ebb6..e78d4dfbe9 100644 --- a/tests/integration/test_add_files.py +++ b/tests/integration/test_add_files.py @@ -20,8 +20,8 @@ import os import re import threading +from collections.abc import Iterator from datetime import date -from typing import Iterator from unittest import mock import pyarrow as pa diff --git a/tests/integration/test_catalog.py b/tests/integration/test_catalog.py index 12bbdc3d2e..0c77666568 100644 --- a/tests/integration/test_catalog.py +++ b/tests/integration/test_catalog.py @@ -16,8 +16,8 @@ # under the License. import os +from collections.abc import Generator from pathlib import Path, PosixPath -from typing import Generator import pytest diff --git a/tests/integration/test_delete_count.py b/tests/integration/test_delete_count.py index d0d83a24dc..bc787ff3c5 100644 --- a/tests/integration/test_delete_count.py +++ b/tests/integration/test_delete_count.py @@ -16,8 +16,8 @@ # under the License. # pylint:disable=redefined-outer-name import random +from collections.abc import Generator from datetime import datetime, timedelta -from typing import Generator import pyarrow as pa import pytest diff --git a/tests/integration/test_deletes.py b/tests/integration/test_deletes.py index a0ee59cc46..e3b487e465 100644 --- a/tests/integration/test_deletes.py +++ b/tests/integration/test_deletes.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. # pylint:disable=redefined-outer-name +from collections.abc import Generator from datetime import datetime -from typing import Generator import pyarrow as pa import pytest diff --git a/tests/test_transforms.py b/tests/test_transforms.py index 88f53c51b0..96500907cf 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -16,9 +16,10 @@ # specific language governing permissions and limitations # under the License. # pylint: disable=eval-used,protected-access,redefined-outer-name +from collections.abc import Callable from datetime import date from decimal import Decimal -from typing import Annotated, Any, Callable +from typing import Annotated, Any from uuid import UUID import mmh3 as mmh3 diff --git a/tests/utils/test_concurrent.py b/tests/utils/test_concurrent.py index f1070a7bf8..ca82a9dc36 100644 --- a/tests/utils/test_concurrent.py +++ b/tests/utils/test_concurrent.py @@ -17,8 +17,8 @@ import multiprocessing import os +from collections.abc import Generator from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor -from typing import Generator from unittest import mock import pytest