From c0b4e2594431f8f38072ca6c9af7745a341c0721 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Mon, 14 Sep 2026 20:09:23 +0000 Subject: [PATCH 1/4] Remove 2892 type errors --- pyiceberg/expressions/__init__.py | 46 ++++++++++ pyiceberg/expressions/literals.py | 6 ++ tests/catalog/integration_test_glue.py | 2 +- tests/catalog/test_dynamodb.py | 64 +++++++++---- tests/catalog/test_glue.py | 122 +++++++++++++++---------- tests/conftest.py | 10 +- tests/table/test_init.py | 8 +- tests/table/test_metadata.py | 4 +- tests/table/test_snapshots.py | 4 +- 9 files changed, 185 insertions(+), 81 deletions(-) diff --git a/pyiceberg/expressions/__init__.py b/pyiceberg/expressions/__init__.py index ef4cb2506e..ece0db82db 100644 --- a/pyiceberg/expressions/__init__.py +++ b/pyiceberg/expressions/__init__.py @@ -600,6 +600,9 @@ def as_unbound(self) -> type[NotNull]: class IsNull(UnaryPredicate): type: TypingLiteral["is-null"] = Field(default="is-null") + def __init__(self, term: str | UnboundTerm, **_: Any) -> None: + super().__init__(term) + def __invert__(self) -> NotNull: """Transform the Expression into its negated version.""" return NotNull(self.term) @@ -612,6 +615,9 @@ def as_bound(self) -> type[BoundIsNull]: # type: ignore class NotNull(UnaryPredicate): type: TypingLiteral["not-null"] = Field(default="not-null") + def __init__(self, term: str | UnboundTerm, **_: Any) -> None: + super().__init__(term) + def __invert__(self) -> IsNull: """Transform the Expression into its negated version.""" return IsNull(self.term) @@ -656,6 +662,9 @@ def as_unbound(self) -> type[NotNaN]: class IsNaN(UnaryPredicate): type: TypingLiteral["is-nan"] = Field(default="is-nan") + def __init__(self, term: str | UnboundTerm, **_: Any) -> None: + super().__init__(term) + def __invert__(self) -> NotNaN: """Transform the Expression into its negated version.""" return NotNaN(self.term) @@ -668,6 +677,9 @@ def as_bound(self) -> type[BoundIsNaN]: # type: ignore class NotNaN(UnaryPredicate): type: TypingLiteral["not-nan"] = Field(default="not-nan") + def __init__(self, term: str | UnboundTerm, **_: Any) -> None: + super().__init__(term) + def __invert__(self) -> IsNaN: """Transform the Expression into its negated version.""" return IsNaN(self.term) @@ -811,6 +823,11 @@ def as_unbound(self) -> type[NotIn]: class In(SetPredicate): type: TypingLiteral["in"] = Field(default="in", alias="type") + def __init__( + self, term: str | UnboundTerm, literals: Iterable[Any] | Iterable[LiteralValue] | None = None, **kwargs: Any + ) -> None: + super().__init__(term, literals, **kwargs) + def __new__( # pylint: disable=W0221 cls, term: str | UnboundTerm, literals: Iterable[Any] | Iterable[LiteralValue] | None = None, **kwargs: Any ) -> In: @@ -841,6 +858,11 @@ def as_bound(self) -> type[BoundIn]: # type: ignore class NotIn(SetPredicate, ABC): type: TypingLiteral["not-in"] = Field(default="not-in", alias="type") + def __init__( + self, term: str | UnboundTerm, literals: Iterable[Any] | Iterable[LiteralValue] | None = None, **kwargs: Any + ) -> None: + super().__init__(term, literals, **kwargs) + def __new__( # pylint: disable=W0221 cls, term: str | UnboundTerm, literals: Iterable[Any] | Iterable[LiteralValue] | None = None, **kwargs: Any ) -> NotIn: @@ -1028,6 +1050,9 @@ def as_unbound(self) -> type[NotStartsWith]: class EqualTo(LiteralPredicate): type: TypingLiteral["eq"] = Field(default="eq", alias="type") + def __init__(self, term: str | UnboundTerm, literal: Any | None = None, **kwargs: Any) -> None: + super().__init__(term, literal, **kwargs) + def __invert__(self) -> NotEqualTo: """Transform the Expression into its negated version.""" return NotEqualTo(self.term, self.literal) @@ -1040,6 +1065,9 @@ def as_bound(self) -> type[BoundEqualTo]: # type: ignore class NotEqualTo(LiteralPredicate): type: TypingLiteral["not-eq"] = Field(default="not-eq", alias="type") + def __init__(self, term: str | UnboundTerm, literal: Any | None = None, **kwargs: Any) -> None: + super().__init__(term, literal, **kwargs) + def __invert__(self) -> EqualTo: """Transform the Expression into its negated version.""" return EqualTo(self.term, self.literal) @@ -1052,6 +1080,9 @@ def as_bound(self) -> type[BoundNotEqualTo]: # type: ignore class LessThan(LiteralPredicate): type: TypingLiteral["lt"] = Field(default="lt", alias="type") + def __init__(self, term: str | UnboundTerm, literal: Any | None = None, **kwargs: Any) -> None: + super().__init__(term, literal, **kwargs) + def __invert__(self) -> GreaterThanOrEqual: """Transform the Expression into its negated version.""" return GreaterThanOrEqual(self.term, self.literal) @@ -1064,6 +1095,9 @@ def as_bound(self) -> type[BoundLessThan]: # type: ignore class GreaterThanOrEqual(LiteralPredicate): type: TypingLiteral["gt-eq"] = Field(default="gt-eq", alias="type") + def __init__(self, term: str | UnboundTerm, literal: Any | None = None, **kwargs: Any) -> None: + super().__init__(term, literal, **kwargs) + def __invert__(self) -> LessThan: """Transform the Expression into its negated version.""" return LessThan(self.term, self.literal) @@ -1076,6 +1110,9 @@ def as_bound(self) -> type[BoundGreaterThanOrEqual]: # type: ignore class GreaterThan(LiteralPredicate): type: TypingLiteral["gt"] = Field(default="gt", alias="type") + def __init__(self, term: str | UnboundTerm, literal: Any | None = None, **kwargs: Any) -> None: + super().__init__(term, literal, **kwargs) + def __invert__(self) -> LessThanOrEqual: """Transform the Expression into its negated version.""" return LessThanOrEqual(self.term, self.literal) @@ -1088,6 +1125,9 @@ def as_bound(self) -> type[BoundGreaterThan]: # type: ignore class LessThanOrEqual(LiteralPredicate): type: TypingLiteral["lt-eq"] = Field(default="lt-eq", alias="type") + def __init__(self, term: str | UnboundTerm, literal: Any | None = None, **kwargs: Any) -> None: + super().__init__(term, literal, **kwargs) + def __invert__(self) -> GreaterThan: """Transform the Expression into its negated version.""" return GreaterThan(self.term, self.literal) @@ -1100,6 +1140,9 @@ def as_bound(self) -> type[BoundLessThanOrEqual]: # type: ignore class StartsWith(LiteralPredicate): type: TypingLiteral["starts-with"] = Field(default="starts-with", alias="type") + def __init__(self, term: str | UnboundTerm, literal: Any | None = None, **kwargs: Any) -> None: + super().__init__(term, literal, **kwargs) + def __invert__(self) -> NotStartsWith: """Transform the Expression into its negated version.""" return NotStartsWith(self.term, self.literal) @@ -1112,6 +1155,9 @@ def as_bound(self) -> type[BoundStartsWith]: # type: ignore class NotStartsWith(LiteralPredicate): type: TypingLiteral["not-starts-with"] = Field(default="not-starts-with", alias="type") + def __init__(self, term: str | UnboundTerm, literal: Any | None = None, **kwargs: Any) -> None: + super().__init__(term, literal, **kwargs) + def __invert__(self) -> StartsWith: """Transform the Expression into its negated version.""" return StartsWith(self.term, self.literal) diff --git a/pyiceberg/expressions/literals.py b/pyiceberg/expressions/literals.py index 39922fde33..01f6b92693 100644 --- a/pyiceberg/expressions/literals.py +++ b/pyiceberg/expressions/literals.py @@ -174,6 +174,9 @@ def literal(value: L) -> Literal[L]: class AboveMax(Literal[L]): + def __init__(self, value: Any, value_type: type[Any], /, **data: Any) -> None: + super().__init__(value, value_type, **data) + def __repr__(self) -> str: """Return the string representation of the AboveMax class.""" return f"{self.__class__.__name__}()" @@ -184,6 +187,9 @@ def __str__(self) -> str: class BelowMin(Literal[L]): + def __init__(self, value: Any, value_type: type[Any], /, **data: Any) -> None: + super().__init__(value, value_type, **data) + def __repr__(self) -> str: """Return the string representation of the BelowMin class.""" return f"{self.__class__.__name__}()" diff --git a/tests/catalog/integration_test_glue.py b/tests/catalog/integration_test_glue.py index c429770268..d8bc7f95ff 100644 --- a/tests/catalog/integration_test_glue.py +++ b/tests/catalog/integration_test_glue.py @@ -53,7 +53,7 @@ def fixture_glue_client() -> boto3.client: def fixture_test_catalog() -> Generator[Catalog, None, None]: """Configure the pre- and post-setting of aws integration test.""" test_catalog = GlueCatalog( - CATALOG_NAME, **{"warehouse": get_s3_path(get_bucket_name()), GLUE_CATALOG_ENDPOINT: get_glue_endpoint()} + CATALOG_NAME, client=None, **{"warehouse": get_s3_path(get_bucket_name()), GLUE_CATALOG_ENDPOINT: get_glue_endpoint()} ) yield test_catalog clean_up(test_catalog) diff --git a/tests/catalog/test_dynamodb.py b/tests/catalog/test_dynamodb.py index 5933e7d472..dabaf5e418 100644 --- a/tests/catalog/test_dynamodb.py +++ b/tests/catalog/test_dynamodb.py @@ -57,7 +57,7 @@ def test_create_dynamodb_catalog_with_table_name(_dynamodb, _bucket_initialize: assert response["Table"]["TableStatus"] == ACTIVE custom_table_name = "custom_table_name" - DynamoDbCatalog("test_ddb_catalog", **{"table-name": custom_table_name}) + DynamoDbCatalog("test_ddb_catalog", client=None, **{"table-name": custom_table_name}) response = _dynamodb.describe_table(TableName=custom_table_name) assert response["Table"]["TableName"] == custom_table_name assert response["Table"]["TableStatus"] == ACTIVE @@ -69,7 +69,7 @@ def test_create_table_with_database_location( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name, properties={"location": f"s3://{BUCKET_NAME}/{database_name}.db"}) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -86,7 +86,7 @@ def test_create_table_with_pyarrow_schema( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name, properties={"location": f"s3://{BUCKET_NAME}/{database_name}.db"}) table = test_catalog.create_table(identifier, pyarrow_schema_simple_without_ids) assert table.name() == identifier @@ -99,7 +99,9 @@ def test_create_table_with_default_warehouse( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog = DynamoDbCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"} + ) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -112,7 +114,7 @@ def test_create_table_with_given_location( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table( identifier=identifier, schema=table_schema_nested, location=f"s3://{BUCKET_NAME}/{database_name}.db/{table_name}" @@ -127,7 +129,7 @@ def test_create_table_removes_trailing_slash_in_location( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name) location = f"s3://{BUCKET_NAME}/{database_name}.db/{table_name}" table = test_catalog.create_table(identifier=identifier, schema=table_schema_nested, location=f"{location}/") @@ -153,7 +155,7 @@ def test_create_table_with_strips( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name, properties={"location": f"s3://{BUCKET_NAME}/{database_name}.db/"}) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -166,7 +168,9 @@ def test_create_table_with_strips_bucket_root( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = DynamoDbCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"} + ) test_catalog.create_namespace(namespace=database_name) table_strip = test_catalog.create_table(identifier, table_schema_nested) assert table_strip.name() == identifier @@ -188,7 +192,9 @@ def test_create_duplicated_table( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str ) -> None: identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog("test_ddb_catalog", **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + "test_ddb_catalog", client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) with pytest.raises(TableAlreadyExistsError): @@ -200,7 +206,9 @@ def test_create_table_if_not_exists_duplicated_table( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str ) -> None: identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog("test_ddb_catalog", **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + "test_ddb_catalog", client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) table1 = test_catalog.create_table(identifier, table_schema_nested) table2 = test_catalog.create_table_if_not_exists(identifier, table_schema_nested) @@ -213,7 +221,9 @@ def test_load_table( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + catalog_name, client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) table = test_catalog.load_table(identifier) @@ -227,7 +237,9 @@ def test_load_table_from_self_identifier( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + catalog_name, client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) intermediate = test_catalog.load_table(identifier) @@ -251,7 +263,9 @@ def test_drop_table( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + catalog_name, client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) table = test_catalog.load_table(identifier) @@ -268,7 +282,9 @@ def test_drop_table_from_self_identifier( ) -> None: catalog_name = "test_ddb_catalog" identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + catalog_name, client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) table = test_catalog.load_table(identifier) @@ -297,7 +313,9 @@ def test_rename_table( new_table_name = f"{table_name}_new" identifier = (database_name, table_name) new_identifier = (database_name, new_table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + catalog_name, client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -320,7 +338,9 @@ def test_rename_table_from_self_identifier( new_table_name = f"{table_name}_new" identifier = (database_name, table_name) new_identifier = (database_name, new_table_name) - test_catalog = DynamoDbCatalog(catalog_name, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + catalog_name, client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -394,7 +414,9 @@ def test_fail_on_rename_non_iceberg_table( def test_list_tables( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_list: list[str] ) -> None: - test_catalog = DynamoDbCatalog("test_ddb_catalog", **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + "test_ddb_catalog", client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) for table_name in table_list: test_catalog.create_table((database_name, table_name), table_schema_nested) @@ -469,7 +491,9 @@ def test_drop_non_empty_namespace( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str ) -> None: identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog("test_ddb_catalog", **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + "test_ddb_catalog", client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) assert len(test_catalog.list_tables(database_name)) == 1 @@ -618,7 +642,9 @@ def test_table_exists( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str ) -> None: identifier = (database_name, table_name) - test_catalog = DynamoDbCatalog("test_ddb_catalog", **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url}) + test_catalog = DynamoDbCatalog( + "test_ddb_catalog", client=None, **{"warehouse": f"s3://{BUCKET_NAME}", "s3.endpoint": moto_endpoint_url} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) # Act and Assert for an existing table diff --git a/tests/catalog/test_glue.py b/tests/catalog/test_glue.py index 89646f5719..fd476c978a 100644 --- a/tests/catalog/test_glue.py +++ b/tests/catalog/test_glue.py @@ -106,7 +106,7 @@ def test_create_table_with_database_location( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name, properties={"location": f"s3://{BUCKET_NAME}/{database_name}.db"}) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -140,7 +140,7 @@ def test_create_v1_table( table_name: str, ) -> None: catalog_name = "glue" - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name, properties={"location": f"s3://{BUCKET_NAME}/{database_name}.db"}) table = test_catalog.create_table((database_name, table_name), table_schema_nested, properties={"format-version": "1"}) assert table.format_version == 1 @@ -168,7 +168,9 @@ def test_create_table_with_default_warehouse( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"} + ) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -182,7 +184,7 @@ def test_create_table_with_given_location( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table( identifier=identifier, schema=table_schema_nested, location=f"s3://{BUCKET_NAME}/{database_name}.db/{table_name}" @@ -198,7 +200,7 @@ def test_create_table_removes_trailing_slash_in_location( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name) location = f"s3://{BUCKET_NAME}/{database_name}.db/{table_name}" table = test_catalog.create_table(identifier=identifier, schema=table_schema_nested, location=f"{location}/") @@ -218,7 +220,7 @@ def test_create_table_with_pyarrow_schema( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table( identifier=identifier, @@ -236,7 +238,7 @@ def test_create_table_with_no_location( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name) with pytest.raises(ValueError): test_catalog.create_table(identifier=identifier, schema=table_schema_nested) @@ -248,7 +250,7 @@ def test_create_table_with_strips( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog(catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name, properties={"location": f"s3://{BUCKET_NAME}/{database_name}.db/"}) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -261,7 +263,7 @@ def test_create_table_with_strips_bucket_root( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str ) -> None: identifier = (database_name, table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) table_strip = test_catalog.create_table(identifier, table_schema_nested) assert table_strip.name() == identifier @@ -274,7 +276,7 @@ def test_create_table_with_no_database( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str ) -> None: identifier = (database_name, table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) with pytest.raises(NoSuchNamespaceError): test_catalog.create_table(identifier=identifier, schema=table_schema_nested) @@ -287,7 +289,7 @@ def test_create_table_with_glue_catalog_id( catalog_id = "444444444444" identifier = (database_name, table_name) test_catalog = GlueCatalog( - catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}", "glue.id": catalog_id} + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}", "glue.id": catalog_id} ) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier, table_schema_nested) @@ -305,7 +307,7 @@ def test_create_duplicated_table( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str ) -> None: identifier = (database_name, table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) with pytest.raises(TableAlreadyExistsError): @@ -318,7 +320,9 @@ def test_load_table( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) table = test_catalog.load_table(identifier) @@ -333,7 +337,9 @@ def test_load_table_from_self_identifier( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"} + ) test_catalog.create_namespace(namespace=database_name) intermediate = test_catalog.create_table(identifier, table_schema_nested) table = test_catalog.load_table(intermediate.name()) @@ -344,7 +350,7 @@ def test_load_table_from_self_identifier( @mock_aws def test_load_non_exist_table(_bucket_initialize: None, moto_endpoint_url: str, database_name: str, table_name: str) -> None: identifier = (database_name, table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) with pytest.raises(NoSuchTableError): test_catalog.load_table(identifier) @@ -356,7 +362,9 @@ def test_drop_table( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) table = test_catalog.load_table(identifier) @@ -373,7 +381,9 @@ def test_drop_table_from_self_identifier( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) table = test_catalog.load_table(identifier) @@ -389,7 +399,7 @@ def test_drop_table_from_self_identifier( @mock_aws def test_drop_non_exist_table(_bucket_initialize: None, moto_endpoint_url: str, database_name: str, table_name: str) -> None: identifier = (database_name, table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) with pytest.raises(NoSuchTableError): test_catalog.drop_table(identifier) @@ -401,7 +411,7 @@ def test_rename_table( new_table_name = f"{table_name}_new" identifier = (database_name, table_name) new_identifier = (database_name, new_table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -424,7 +434,7 @@ def test_rename_table_from_self_identifier( new_table_name = f"{table_name}_new" identifier = (database_name, table_name) new_identifier = (database_name, new_table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier, table_schema_nested) assert table.name() == identifier @@ -449,7 +459,7 @@ def test_rename_table_no_params( new_table_name = f"{table_name}_new" identifier = (database_name, table_name) new_identifier = (new_database_name, new_table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) test_catalog.create_namespace(namespace=new_database_name) _glue.create_table( @@ -468,7 +478,7 @@ def test_rename_non_iceberg_table( new_table_name = f"{table_name}_new" identifier = (database_name, table_name) new_identifier = (new_database_name, new_table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) test_catalog.create_namespace(namespace=new_database_name) _glue.create_table( @@ -491,7 +501,7 @@ def test_list_tables( database_name: str, table_list: list[str], ) -> None: - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) non_iceberg_table_name = "non_iceberg_table" @@ -526,7 +536,7 @@ def test_list_tables( @mock_aws def test_list_namespaces(_bucket_initialize: None, moto_endpoint_url: str, database_list: list[str]) -> None: - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) for database_name in database_list: test_catalog.create_namespace(namespace=database_name) loaded_database_list = test_catalog.list_namespaces() @@ -536,7 +546,7 @@ def test_list_namespaces(_bucket_initialize: None, moto_endpoint_url: str, datab @mock_aws def test_create_namespace_no_properties(_bucket_initialize: None, moto_endpoint_url: str, database_name: str) -> None: - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name) loaded_database_list = test_catalog.list_namespaces() assert len(loaded_database_list) == 1 @@ -552,7 +562,7 @@ def test_create_namespace_with_comment_and_location(_bucket_initialize: None, mo "comment": "this is a test description", "location": test_location, } - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name, properties=test_properties) loaded_database_list = test_catalog.list_namespaces() assert len(loaded_database_list) == 1 @@ -564,7 +574,7 @@ def test_create_namespace_with_comment_and_location(_bucket_initialize: None, mo @mock_aws def test_create_duplicated_namespace(_bucket_initialize: None, moto_endpoint_url: str, database_name: str) -> None: - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name) loaded_database_list = test_catalog.list_namespaces() assert len(loaded_database_list) == 1 @@ -575,7 +585,7 @@ def test_create_duplicated_namespace(_bucket_initialize: None, moto_endpoint_url @mock_aws def test_drop_namespace(_bucket_initialize: None, moto_endpoint_url: str, database_name: str) -> None: - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(namespace=database_name) loaded_database_list = test_catalog.list_namespaces() assert len(loaded_database_list) == 1 @@ -590,7 +600,7 @@ def test_drop_non_empty_namespace( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str ) -> None: identifier = (database_name, table_name) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier, table_schema_nested) assert len(test_catalog.list_tables(database_name)) == 1 @@ -602,7 +612,7 @@ def test_drop_non_empty_namespace( def test_drop_namespace_that_contains_non_iceberg_tables( _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str ) -> None: - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}/"}) test_catalog.create_namespace(namespace=database_name) test_catalog.glue.create_table(DatabaseName=database_name, TableInput={"Name": "hive_table"}) @@ -612,7 +622,7 @@ def test_drop_namespace_that_contains_non_iceberg_tables( @mock_aws def test_drop_non_exist_namespace(_bucket_initialize: None, moto_endpoint_url: str, database_name: str) -> None: - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) with pytest.raises(NoSuchNamespaceError): test_catalog.drop_namespace(database_name) @@ -627,7 +637,7 @@ def test_load_namespace_properties(_bucket_initialize: None, moto_endpoint_url: "test_property2": "2", "test_property3": "3", } - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(database_name, test_properties) listed_properties = test_catalog.load_namespace_properties(database_name) for k, v in listed_properties.items(): @@ -637,7 +647,7 @@ def test_load_namespace_properties(_bucket_initialize: None, moto_endpoint_url: @mock_aws def test_load_non_exist_namespace_properties(_bucket_initialize: None, moto_endpoint_url: str, database_name: str) -> None: - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) with pytest.raises(NoSuchNamespaceError): test_catalog.load_namespace_properties(database_name) @@ -653,7 +663,7 @@ def test_update_namespace_properties(_bucket_initialize: None, moto_endpoint_url } removals = {"test_property1", "test_property2", "test_property3", "should_not_removed"} updates = {"test_property4": "4", "test_property5": "5", "comment": "updated test description"} - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(database_name, test_properties) update_report = test_catalog.update_namespace_properties(database_name, removals, updates) for k in updates.keys(): @@ -669,7 +679,7 @@ def test_update_namespace_properties(_bucket_initialize: None, moto_endpoint_url @mock_aws def test_load_empty_namespace_properties(_bucket_initialize: None, moto_endpoint_url: str, database_name: str) -> None: - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(database_name) listed_properties = test_catalog.load_namespace_properties(database_name) assert listed_properties == {} @@ -679,7 +689,7 @@ def test_load_empty_namespace_properties(_bucket_initialize: None, moto_endpoint def test_load_default_namespace_properties(_glue, _bucket_initialize: None, moto_endpoint_url: str, database_name: str) -> None: # type: ignore # simulate creating database with default settings through AWS Glue Web Console _glue.create_database(DatabaseInput={"Name": database_name}) - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) listed_properties = test_catalog.load_namespace_properties(database_name) assert listed_properties == {} @@ -697,7 +707,7 @@ def test_update_namespace_properties_overlap_update_removal( } removals = {"test_property1", "test_property2", "test_property3", "should_not_removed"} updates = {"test_property1": "4", "test_property5": "5", "comment": "updated test description"} - test_catalog = GlueCatalog("glue", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("glue", client=None, **{"s3.endpoint": moto_endpoint_url}) test_catalog.create_namespace(database_name, test_properties) with pytest.raises(ValueError): test_catalog.update_namespace_properties(database_name, removals, updates) @@ -762,7 +772,9 @@ def test_commit_table_update_schema( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"} + ) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier, table_schema_nested) original_table_metadata = table.metadata @@ -821,7 +833,9 @@ def test_commit_table_properties( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"} + ) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier=identifier, schema=table_schema_nested, properties={"test_a": "test_a"}) @@ -851,7 +865,9 @@ def test_commit_append_table_snapshot_properties( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"} + ) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier=identifier, schema=table_schema_simple) @@ -878,7 +894,9 @@ def test_commit_overwrite_table_snapshot_properties( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"} + ) test_catalog.create_namespace(namespace=database_name) table = test_catalog.create_table(identifier=identifier, schema=table_schema_simple) @@ -924,7 +942,9 @@ def test_create_table_transaction( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"} + ) test_catalog.create_namespace(namespace=database_name) with test_catalog.create_table_transaction( @@ -965,7 +985,9 @@ def test_table_exists( ) -> None: catalog_name = "glue" identifier = (database_name, table_name) - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"} + ) test_catalog.create_namespace(namespace=database_name) test_catalog.create_table(identifier=identifier, schema=table_schema_simple) # Act and Assert for an existing table @@ -981,7 +1003,9 @@ def test_register_table_with_given_location( catalog_name = "glue" identifier = (database_name, table_name) location = metadata_location - test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog = GlueCatalog( + catalog_name, client=None, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"} + ) test_catalog.create_namespace(namespace=database_name, properties={"location": f"s3://{BUCKET_NAME}/{database_name}.db"}) table = test_catalog.register_table(identifier, location) assert table.name() == identifier @@ -993,7 +1017,9 @@ def test_glue_endpoint_override(_bucket_initialize: None, moto_endpoint_url: str catalog_name = "glue" test_endpoint = "https://test-endpoint" test_catalog = GlueCatalog( - catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}", "glue.endpoint": test_endpoint} + catalog_name, + client=None, + **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}", "glue.endpoint": test_endpoint}, ) assert test_catalog.glue.meta.endpoint_url == test_endpoint @@ -1031,7 +1057,7 @@ def test_create_table_s3tables( _patch_moto_for_s3tables(monkeypatch) identifier = (database_name, table_name) - test_catalog = GlueCatalog("s3tables", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("s3tables", client=None, **{"s3.endpoint": moto_endpoint_url}) _create_s3tables_database(test_catalog, database_name) table = test_catalog.create_table(identifier, table_schema_nested) @@ -1054,7 +1080,7 @@ def test_create_table_s3tables_rejects_location( _patch_moto_for_s3tables(monkeypatch) identifier = (database_name, table_name) - test_catalog = GlueCatalog("s3tables", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("s3tables", client=None, **{"s3.endpoint": moto_endpoint_url}) _create_s3tables_database(test_catalog, database_name) with pytest.raises(ValueError, match="Cannot specify a location for S3 Tables table"): @@ -1073,7 +1099,7 @@ def test_create_table_s3tables_duplicate( _patch_moto_for_s3tables(monkeypatch) identifier = (database_name, table_name) - test_catalog = GlueCatalog("s3tables", **{"s3.endpoint": moto_endpoint_url}) + test_catalog = GlueCatalog("s3tables", client=None, **{"s3.endpoint": moto_endpoint_url}) _create_s3tables_database(test_catalog, database_name) test_catalog.create_table(identifier, table_schema_nested) diff --git a/tests/conftest.py b/tests/conftest.py index a9b2a76934..316499ba53 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -667,7 +667,7 @@ def all_avro_types() -> dict[str, Any]: } -EXAMPLE_TABLE_METADATA_V1 = { +EXAMPLE_TABLE_METADATA_V1: dict[str, Any] = { "format-version": 1, "table-uuid": "d20125c8-7284-442c-9aea-15fee620737c", "location": "s3://bucket/test/location", @@ -693,7 +693,7 @@ def example_table_metadata_v1() -> dict[str, Any]: return EXAMPLE_TABLE_METADATA_V1 -EXAMPLE_TABLE_METADATA_WITH_SNAPSHOT_V1 = { +EXAMPLE_TABLE_METADATA_WITH_SNAPSHOT_V1: dict[str, Any] = { "format-version": 1, "table-uuid": "b55d9dda-6561-423a-8bfc-787980ce421f", "location": "s3://warehouse/database/table", @@ -767,7 +767,7 @@ def example_table_metadata_with_snapshot_v1() -> dict[str, Any]: return EXAMPLE_TABLE_METADATA_WITH_SNAPSHOT_V1 -EXAMPLE_TABLE_METADATA_NO_SNAPSHOT_V1 = { +EXAMPLE_TABLE_METADATA_NO_SNAPSHOT_V1: dict[str, Any] = { "format-version": 1, "table-uuid": "bf289591-dcc0-4234-ad4f-5c3eed811a29", "location": "s3://warehouse/database/table", @@ -891,7 +891,7 @@ def generate_snapshot( } -EXAMPLE_TABLE_METADATA_V2 = { +EXAMPLE_TABLE_METADATA_V2: dict[str, Any] = { "format-version": 2, "table-uuid": "9c12d441-03fe-4693-9a96-a0705ddf69c1", "location": "s3://bucket/test/location", @@ -953,7 +953,7 @@ def generate_snapshot( "refs": {"test": {"snapshot-id": 3051729675574597004, "type": "tag", "max-ref-age-ms": 10000000}}, } -EXAMPLE_TABLE_METADATA_V3 = { +EXAMPLE_TABLE_METADATA_V3: dict[str, Any] = { "format-version": 3, "table-uuid": "9c12d441-03fe-4693-9a96-a0705ddf69c1", "location": "s3://bucket/test/location", diff --git a/tests/table/test_init.py b/tests/table/test_init.py index 739039debb..3bc70afc8b 100644 --- a/tests/table/test_init.py +++ b/tests/table/test_init.py @@ -1452,8 +1452,8 @@ def test_assert_default_sort_order_id(table_v2: Table) -> None: def test_correct_schema() -> None: - table_metadata = TableMetadataV2( - **{ + table_metadata = TableMetadataV2.model_validate( + { "format-version": 2, "table-uuid": "9c12d441-03fe-4693-9a96-a0705ddf69c1", "location": "s3://bucket/test/location", @@ -1551,7 +1551,7 @@ def test_table_properties(example_table_metadata_v2: dict[str, Any]) -> None: # property can be set to int, but still serialized as string property_with_int = {"property_name": 42} - new_example_table_metadata_v2 = {**example_table_metadata_v2, "properties": property_with_int} + new_example_table_metadata_v2: dict[str, Any] = {**example_table_metadata_v2, "properties": property_with_int} assert isinstance(new_example_table_metadata_v2["properties"]["property_name"], int) new_metadata = TableMetadataV2(**new_example_table_metadata_v2) assert isinstance(new_metadata.properties["property_name"], str) @@ -1965,7 +1965,7 @@ def model_roundtrips(model: BaseModel) -> bool: def test_check_uuid_raises_when_mismatch(table_v2: Table, example_table_metadata_v2: dict[str, Any]) -> None: different_uuid = "550e8400-e29b-41d4-a716-446655440000" - metadata_with_different_uuid = {**example_table_metadata_v2, "table-uuid": different_uuid} + metadata_with_different_uuid: dict[str, Any] = {**example_table_metadata_v2, "table-uuid": different_uuid} new_metadata = TableMetadataV2(**metadata_with_different_uuid) with pytest.raises(ValueError) as exc_info: diff --git a/tests/table/test_metadata.py b/tests/table/test_metadata.py index d696a16205..fb20f9726a 100644 --- a/tests/table/test_metadata.py +++ b/tests/table/test_metadata.py @@ -497,7 +497,7 @@ def test_v1_write_metadata_for_v2() -> None: - partition-spec is no longer required and should be omitted; use partition-specs and default-spec-id instead """ - minimal_example_v1 = { + minimal_example_v1: dict[str, Any] = { "format-version": 1, "location": "s3://bucket/test/location", "last-updated-ms": 1602638573874, @@ -571,7 +571,7 @@ def test_v2_ref_creation(example_table_metadata_v2: dict[str, Any]) -> None: def test_metadata_v1() -> None: - valid_v1 = { + valid_v1: dict[str, Any] = { "format-version": 1, "table-uuid": "bf289591-dcc0-4234-ad4f-5c3eed811a29", "location": "s3://tabular-wh-us-west-2-dev/8bcb0838-50fc-472d-9ddb-8feb89ef5f1e/bf289591-dcc0-4234-ad4f-5c3eed811a29", diff --git a/tests/table/test_snapshots.py b/tests/table/test_snapshots.py index efb4145927..39aeb7b349 100644 --- a/tests/table/test_snapshots.py +++ b/tests/table/test_snapshots.py @@ -588,8 +588,8 @@ def test_latest_ancestor_before_timestamp() -> None: from pyiceberg.table.metadata import TableMetadataV2 # Create metadata with 4 snapshots at ordered timestamps - metadata = TableMetadataV2( - **{ + metadata = TableMetadataV2.model_validate( + { "format-version": 2, "table-uuid": "9c12d441-03fe-4693-9a96-a0705ddf69c1", "location": "s3://bucket/test/location", From 74798220a06b76916db0ac0eb46f4cf3a58ce6c3 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Mon, 14 Sep 2026 13:47:46 -0700 Subject: [PATCH 2/4] Update pyiceberg/expressions/literals.py --- pyiceberg/expressions/literals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiceberg/expressions/literals.py b/pyiceberg/expressions/literals.py index 01f6b92693..c19ba3ebe3 100644 --- a/pyiceberg/expressions/literals.py +++ b/pyiceberg/expressions/literals.py @@ -174,7 +174,7 @@ def literal(value: L) -> Literal[L]: class AboveMax(Literal[L]): - def __init__(self, value: Any, value_type: type[Any], /, **data: Any) -> None: + def __init__(self, value: L, value_type: type[L], /, **data: Any) -> None: super().__init__(value, value_type, **data) def __repr__(self) -> str: From 24a356e5b5c0bd802b550fdbcea5ca2253cae7e5 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Mon, 14 Sep 2026 13:47:53 -0700 Subject: [PATCH 3/4] Update pyiceberg/expressions/literals.py --- pyiceberg/expressions/literals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiceberg/expressions/literals.py b/pyiceberg/expressions/literals.py index c19ba3ebe3..1f0d5d3889 100644 --- a/pyiceberg/expressions/literals.py +++ b/pyiceberg/expressions/literals.py @@ -187,7 +187,7 @@ def __str__(self) -> str: class BelowMin(Literal[L]): - def __init__(self, value: Any, value_type: type[Any], /, **data: Any) -> None: + def __init__(self, value: L, value_type: type[L], /, **data: Any) -> None: super().__init__(value, value_type, **data) def __repr__(self) -> str: From 03d3610479e850c319eacf6fac404d7fe1316e6a Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Mon, 14 Sep 2026 20:59:46 +0000 Subject: [PATCH 4/4] make lint was complaining --- pyiceberg/expressions/literals.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyiceberg/expressions/literals.py b/pyiceberg/expressions/literals.py index 1f0d5d3889..61581d9b3c 100644 --- a/pyiceberg/expressions/literals.py +++ b/pyiceberg/expressions/literals.py @@ -175,7 +175,7 @@ def literal(value: L) -> Literal[L]: class AboveMax(Literal[L]): def __init__(self, value: L, value_type: type[L], /, **data: Any) -> None: - super().__init__(value, value_type, **data) + Literal.__init__(self, value, value_type, **data) def __repr__(self) -> str: """Return the string representation of the AboveMax class.""" @@ -188,7 +188,7 @@ def __str__(self) -> str: class BelowMin(Literal[L]): def __init__(self, value: L, value_type: type[L], /, **data: Any) -> None: - super().__init__(value, value_type, **data) + Literal.__init__(self, value, value_type, **data) def __repr__(self) -> str: """Return the string representation of the BelowMin class."""