Skip to content

Commit 28bfc40

Browse files
committed
make lint passing
1 parent ea14fe0 commit 28bfc40

File tree

11 files changed

+63
-48
lines changed

11 files changed

+63
-48
lines changed

pyiceberg/catalog/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,10 @@ def drop_view(self, identifier: str | Identifier) -> None:
688688
@abstractmethod
689689
def create_view(
690690
self,
691-
identifier: Union[str, Identifier],
692-
schema: Union[Schema, "pa.Schema"],
691+
identifier: str | Identifier,
692+
schema: Schema | pa.Schema,
693693
view_version: ViewVersion,
694-
location: Optional[str] = None,
694+
location: str | None = None,
695695
properties: Properties = EMPTY_DICT,
696696
) -> View:
697697
"""Create a view.

pyiceberg/catalog/bigquery_metastore.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
from __future__ import annotations
18+
1719
import json
18-
from typing import TYPE_CHECKING, Any, Union
20+
from typing import TYPE_CHECKING, Any
1921

2022
from google.api_core.exceptions import NotFound
2123
from google.cloud.bigquery import Client, Dataset, DatasetReference, TableReference
@@ -39,6 +41,8 @@
3941
from pyiceberg.table.update import TableRequirement, TableUpdate
4042
from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties
4143
from pyiceberg.utils.config import Config
44+
from pyiceberg.view import View
45+
from pyiceberg.view.metadata import ViewVersion
4246

4347
if TYPE_CHECKING:
4448
import pyarrow as pa
@@ -101,7 +105,7 @@ def __init__(self, name: str, **properties: str):
101105
def create_table(
102106
self,
103107
identifier: str | Identifier,
104-
schema: Union[Schema, "pa.Schema"],
108+
schema: Schema | pa.Schema,
105109
location: str | None = None,
106110
partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
107111
sort_order: SortOrder = UNSORTED_SORT_ORDER,
@@ -272,7 +276,7 @@ def register_table(self, identifier: str | Identifier, metadata_location: str) -
272276
"""Register a new table using existing metadata.
273277
274278
Args:
275-
identifier (Union[str, Identifier]): Table identifier for the table
279+
identifier (str | Identifier): Table identifier for the table
276280
metadata_location (str): The location to the metadata
277281
278282
Returns:
@@ -299,6 +303,16 @@ def register_table(self, identifier: str | Identifier, metadata_location: str) -
299303

300304
return self.load_table(identifier=identifier)
301305

306+
def create_view(
307+
self,
308+
identifier: str | Identifier,
309+
schema: Schema | pa.Schema,
310+
view_version: ViewVersion,
311+
location: str | None = None,
312+
properties: Properties = EMPTY_DICT,
313+
) -> View:
314+
raise NotImplementedError
315+
302316
def list_views(self, namespace: str | Identifier) -> list[Identifier]:
303317
raise NotImplementedError
304318

pyiceberg/catalog/dynamodb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,10 @@ def update_namespace_properties(
541541

542542
def create_view(
543543
self,
544-
identifier: Union[str, Identifier],
544+
identifier: str | Identifier,
545545
schema: Union[Schema, "pa.Schema"],
546546
view_version: ViewVersion,
547-
location: Optional[str] = None,
547+
location: str | None = None,
548548
properties: Properties = EMPTY_DICT,
549549
) -> View:
550550
raise NotImplementedError

pyiceberg/catalog/glue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,10 @@ def update_namespace_properties(
813813

814814
def create_view(
815815
self,
816-
identifier: Union[str, Identifier],
816+
identifier: str | Identifier,
817817
schema: Union[Schema, "pa.Schema"],
818818
view_version: ViewVersion,
819-
location: Optional[str] = None,
819+
location: str | None = None,
820820
properties: Properties = EMPTY_DICT,
821821
) -> View:
822822
raise NotImplementedError

pyiceberg/catalog/hive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,10 @@ def create_table(
438438

439439
def create_view(
440440
self,
441-
identifier: Union[str, Identifier],
442-
schema: Union[Schema, "pa.Schema"],
441+
identifier: str | Identifier,
442+
schema: Schema | pa.Schema,
443443
view_version: ViewVersion,
444-
location: Optional[str] = None,
444+
location: str | None = None,
445445
properties: Properties = EMPTY_DICT,
446446
) -> View:
447447
raise NotImplementedError

pyiceberg/catalog/noop.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,10 @@ def drop_view(self, identifier: str | Identifier) -> None:
135135

136136
def create_view(
137137
self,
138-
identifier: Union[str, Identifier],
139-
schema: Union[Schema, "pa.Schema"],
138+
identifier: str | Identifier,
139+
schema: Schema | pa.Schema,
140140
view_version: ViewVersion,
141-
location: Optional[str] = None,
141+
location: str | None = None,
142142
properties: Properties = EMPTY_DICT,
143143
) -> View:
144144
raise NotImplementedError
145-
146-
def drop_view(self, identifier: str | Identifier) -> None:
147-
raise NotImplementedError

pyiceberg/catalog/rest/__init__.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
from __future__ import annotations
18+
1719
from collections import deque
1820
from enum import Enum
1921
from typing import (
2022
TYPE_CHECKING,
2123
Any,
22-
Union,
2324
)
2425
from urllib.parse import quote, unquote
2526

@@ -117,7 +118,7 @@ def __str__(self) -> str:
117118
return f"{self.http_method.value} {self.path}"
118119

119120
@classmethod
120-
def from_string(cls, endpoint: str) -> "Endpoint":
121+
def from_string(cls, endpoint: str) -> Endpoint:
121122
elements = endpoint.strip().split(None, 1)
122123
if len(elements) != 2:
123124
raise ValueError(f"Invalid endpoint (must consist of two elements separated by a single space): {endpoint}")
@@ -268,7 +269,7 @@ class TableResponse(IcebergBaseModel):
268269

269270

270271
class ViewResponse(IcebergBaseModel):
271-
metadata_location: Optional[str] = Field(alias="metadata-location", default=None)
272+
metadata_location: str | None = Field(alias="metadata-location", default=None)
272273
metadata: ViewMetadata
273274
config: Properties = Field(default_factory=dict)
274275

@@ -290,13 +291,13 @@ def transform_properties_dict_value_to_str(cls, properties: Properties) -> dict[
290291

291292
class CreateViewRequest(IcebergBaseModel):
292293
name: str = Field()
293-
location: Optional[str] = Field()
294+
location: str | None = Field()
294295
view_schema: Schema = Field(alias="schema")
295296
view_version: ViewVersion = Field(alias="view-version")
296297
properties: Properties = Field(default_factory=dict)
297298

298299
@field_validator("properties", mode="before")
299-
def transform_properties_dict_value_to_str(cls, properties: Properties) -> Dict[str, str]:
300+
def transform_properties_dict_value_to_str(cls, properties: Properties) -> dict[str, str]:
300301
return transform_dict_value_to_str(properties)
301302

302303

@@ -778,7 +779,7 @@ def _response_to_staged_table(self, identifier_tuple: tuple[str, ...], table_res
778779
catalog=self,
779780
)
780781

781-
def _response_to_view(self, identifier_tuple: Tuple[str, ...], view_response: ViewResponse) -> View:
782+
def _response_to_view(self, identifier_tuple: tuple[str, ...], view_response: ViewResponse) -> View:
782783
return View(
783784
identifier=identifier_tuple,
784785
metadata=view_response.metadata,
@@ -803,7 +804,7 @@ def _config_headers(self, session: Session) -> None:
803804
def _create_table(
804805
self,
805806
identifier: str | Identifier,
806-
schema: Union[Schema, "pa.Schema"],
807+
schema: Schema | pa.Schema,
807808
location: str | None = None,
808809
partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
809810
sort_order: SortOrder = UNSORTED_SORT_ORDER,
@@ -846,7 +847,7 @@ def _create_table(
846847
def create_table(
847848
self,
848849
identifier: str | Identifier,
849-
schema: Union[Schema, "pa.Schema"],
850+
schema: Schema | pa.Schema,
850851
location: str | None = None,
851852
partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
852853
sort_order: SortOrder = UNSORTED_SORT_ORDER,
@@ -867,7 +868,7 @@ def create_table(
867868
def create_table_transaction(
868869
self,
869870
identifier: str | Identifier,
870-
schema: Union[Schema, "pa.Schema"],
871+
schema: Schema | pa.Schema,
871872
location: str | None = None,
872873
partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
873874
sort_order: SortOrder = UNSORTED_SORT_ORDER,
@@ -888,10 +889,10 @@ def create_table_transaction(
888889
@retry(**_RETRY_ARGS)
889890
def create_view(
890891
self,
891-
identifier: Union[str, Identifier],
892-
schema: Union[Schema, "pa.Schema"],
892+
identifier: str | Identifier,
893+
schema: Schema | pa.Schema,
893894
view_version: ViewVersion,
894-
location: Optional[str] = None,
895+
location: str | None = None,
895896
properties: Properties = EMPTY_DICT,
896897
) -> View:
897898
iceberg_schema = self._convert_schema_if_needed(schema)

pyiceberg/catalog/sql.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
from __future__ import annotations
19+
1820
from typing import (
1921
TYPE_CHECKING,
20-
Union,
2122
)
2223

2324
from sqlalchemy import (
@@ -174,7 +175,7 @@ def _convert_orm_to_iceberg(self, orm_table: IcebergTables) -> Table:
174175
def create_table(
175176
self,
176177
identifier: str | Identifier,
177-
schema: Union[Schema, "pa.Schema"],
178+
schema: Schema | pa.Schema,
178179
location: str | None = None,
179180
partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
180181
sort_order: SortOrder = UNSORTED_SORT_ORDER,
@@ -726,10 +727,10 @@ def update_namespace_properties(
726727

727728
def create_view(
728729
self,
729-
identifier: Union[str, Identifier],
730-
schema: Union[Schema, "pa.Schema"],
730+
identifier: str | Identifier,
731+
schema: Schema | pa.Schema,
731732
view_version: ViewVersion,
732-
location: Optional[str] = None,
733+
location: str | None = None,
733734
properties: Properties = EMPTY_DICT,
734735
) -> View:
735736
raise NotImplementedError

pyiceberg/view/metadata.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717
from __future__ import annotations
1818

19-
from typing import Dict, List, Literal, Optional
19+
from typing import Literal
2020

2121
from pydantic import Field, RootModel, field_validator
2222

@@ -50,11 +50,11 @@ class ViewVersion(IcebergBaseModel):
5050
"""ID of the schema for the view version"""
5151
timestamp_ms: int = Field(alias="timestamp-ms")
5252
"""Timestamp when the version was created (ms from epoch)"""
53-
summary: Dict[str, str] = Field()
53+
summary: dict[str, str] = Field()
5454
"""A string to string map of summary metadata about the version"""
55-
representations: List[ViewRepresentation] = Field()
55+
representations: list[ViewRepresentation] = Field()
5656
"""A list of representations for the view definition"""
57-
default_catalog: Optional[str] = Field(alias="default-catalog", default=None)
57+
default_catalog: str | None = Field(alias="default-catalog", default=None)
5858
"""Catalog name to use when a reference in the SELECT does not contain a catalog"""
5959
default_namespace: Identifier = Field(alias="default-namespace")
6060
"""Namespace to use when a reference in the SELECT is a single identifier"""
@@ -78,17 +78,17 @@ class ViewMetadata(IcebergBaseModel):
7878
"""An integer version number for the view format; must be 1"""
7979
location: str = Field()
8080
"""The view's base location; used to create metadata file locations"""
81-
schemas: List[Schema] = Field()
81+
schemas: list[Schema] = Field()
8282
"""A list of known schemas"""
8383
current_version_id: int = Field(alias="current-version-id")
8484
"""ID of the current version of the view (version-id)"""
85-
versions: List[ViewVersion] = Field()
85+
versions: list[ViewVersion] = Field()
8686
"""A list of known versions of the view"""
87-
version_log: List[ViewHistoryEntry] = Field(alias="version-log")
87+
version_log: list[ViewHistoryEntry] = Field(alias="version-log")
8888
"""A list of version log entries"""
8989
properties: Properties = Field(default_factory=dict)
9090
"""A string to string map of view properties"""
9191

9292
@field_validator("properties", mode="before")
93-
def transform_properties_dict_value_to_str(cls, properties: Properties) -> Dict[str, str]:
93+
def transform_properties_dict_value_to_str(cls, properties: Properties) -> dict[str, str]:
9494
return transform_dict_value_to_str(properties)

tests/catalog/test_rest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
# pylint: disable=redefined-outer-name,unused-argument
18+
from __future__ import annotations
19+
1820
import base64
1921
import os
2022
from collections.abc import Callable
@@ -142,7 +144,7 @@ def example_table_metadata_no_snapshot_v1_rest_json(example_table_metadata_no_sn
142144

143145

144146
@pytest.fixture
145-
def example_view_metadata_rest_json(example_view_metadata_v1: Dict[str, Any]) -> Dict[str, Any]:
147+
def example_view_metadata_rest_json(example_view_metadata_v1: dict[str, Any]) -> dict[str, Any]:
146148
return {
147149
"metadata-location": "s3://warehouse/database/table/metadata/00001-5f2f8166-244c-4eae-ac36-384ecdec81fc.gz.metadata.json",
148150
"metadata": example_view_metadata_v1,
@@ -1282,7 +1284,7 @@ def test_create_table_409(rest_mock: Mocker, table_schema_simple: Schema) -> Non
12821284
assert "Table already exists" in str(e.value)
12831285

12841286

1285-
def test_create_view_200(rest_mock: Mocker, table_schema_simple: Schema, example_view_metadata_rest_json: Dict[str, Any]) -> None:
1287+
def test_create_view_200(rest_mock: Mocker, table_schema_simple: Schema, example_view_metadata_rest_json: dict[str, Any]) -> None:
12861288
rest_mock.post(
12871289
f"{TEST_URI}v1/namespaces/fokko/views",
12881290
json=example_view_metadata_rest_json,

0 commit comments

Comments
 (0)