Skip to content

Commit f1f0a73

Browse files
committed
make lint passing
1 parent 3269580 commit f1f0a73

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
@@ -679,10 +679,10 @@ def drop_view(self, identifier: str | Identifier) -> None:
679679
@abstractmethod
680680
def create_view(
681681
self,
682-
identifier: Union[str, Identifier],
683-
schema: Union[Schema, "pa.Schema"],
682+
identifier: str | Identifier,
683+
schema: Schema | pa.Schema,
684684
view_version: ViewVersion,
685-
location: Optional[str] = None,
685+
location: str | None = None,
686686
properties: Properties = EMPTY_DICT,
687687
) -> View:
688688
"""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
@@ -132,13 +132,10 @@ def drop_view(self, identifier: str | Identifier) -> None:
132132

133133
def create_view(
134134
self,
135-
identifier: Union[str, Identifier],
136-
schema: Union[Schema, "pa.Schema"],
135+
identifier: str | Identifier,
136+
schema: Schema | pa.Schema,
137137
view_version: ViewVersion,
138-
location: Optional[str] = None,
138+
location: str | None = None,
139139
properties: Properties = EMPTY_DICT,
140140
) -> View:
141141
raise NotImplementedError
142-
143-
def drop_view(self, identifier: str | Identifier) -> None:
144-
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

@@ -112,7 +113,7 @@ def __str__(self) -> str:
112113
return f"{self.http_method.value} {self.path}"
113114

114115
@classmethod
115-
def from_string(cls, endpoint: str) -> "Endpoint":
116+
def from_string(cls, endpoint: str) -> Endpoint:
116117
elements = endpoint.strip().split(None, 1)
117118
if len(elements) != 2:
118119
raise ValueError(f"Invalid endpoint (must consist of two elements separated by a single space): {endpoint}")
@@ -263,7 +264,7 @@ class TableResponse(IcebergBaseModel):
263264

264265

265266
class ViewResponse(IcebergBaseModel):
266-
metadata_location: Optional[str] = Field(alias="metadata-location", default=None)
267+
metadata_location: str | None = Field(alias="metadata-location", default=None)
267268
metadata: ViewMetadata
268269
config: Properties = Field(default_factory=dict)
269270

@@ -285,13 +286,13 @@ def transform_properties_dict_value_to_str(cls, properties: Properties) -> dict[
285286

286287
class CreateViewRequest(IcebergBaseModel):
287288
name: str = Field()
288-
location: Optional[str] = Field()
289+
location: str | None = Field()
289290
view_schema: Schema = Field(alias="schema")
290291
view_version: ViewVersion = Field(alias="view-version")
291292
properties: Properties = Field(default_factory=dict)
292293

293294
@field_validator("properties", mode="before")
294-
def transform_properties_dict_value_to_str(cls, properties: Properties) -> Dict[str, str]:
295+
def transform_properties_dict_value_to_str(cls, properties: Properties) -> dict[str, str]:
295296
return transform_dict_value_to_str(properties)
296297

297298

@@ -773,7 +774,7 @@ def _response_to_staged_table(self, identifier_tuple: tuple[str, ...], table_res
773774
catalog=self,
774775
)
775776

776-
def _response_to_view(self, identifier_tuple: Tuple[str, ...], view_response: ViewResponse) -> View:
777+
def _response_to_view(self, identifier_tuple: tuple[str, ...], view_response: ViewResponse) -> View:
777778
return View(
778779
identifier=identifier_tuple,
779780
metadata=view_response.metadata,
@@ -798,7 +799,7 @@ def _config_headers(self, session: Session) -> None:
798799
def _create_table(
799800
self,
800801
identifier: str | Identifier,
801-
schema: Union[Schema, "pa.Schema"],
802+
schema: Schema | pa.Schema,
802803
location: str | None = None,
803804
partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
804805
sort_order: SortOrder = UNSORTED_SORT_ORDER,
@@ -841,7 +842,7 @@ def _create_table(
841842
def create_table(
842843
self,
843844
identifier: str | Identifier,
844-
schema: Union[Schema, "pa.Schema"],
845+
schema: Schema | pa.Schema,
845846
location: str | None = None,
846847
partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
847848
sort_order: SortOrder = UNSORTED_SORT_ORDER,
@@ -862,7 +863,7 @@ def create_table(
862863
def create_table_transaction(
863864
self,
864865
identifier: str | Identifier,
865-
schema: Union[Schema, "pa.Schema"],
866+
schema: Schema | pa.Schema,
866867
location: str | None = None,
867868
partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
868869
sort_order: SortOrder = UNSORTED_SORT_ORDER,
@@ -883,10 +884,10 @@ def create_table_transaction(
883884
@retry(**_RETRY_ARGS)
884885
def create_view(
885886
self,
886-
identifier: Union[str, Identifier],
887-
schema: Union[Schema, "pa.Schema"],
887+
identifier: str | Identifier,
888+
schema: Schema | pa.Schema,
888889
view_version: ViewVersion,
889-
location: Optional[str] = None,
890+
location: str | None = None,
890891
properties: Properties = EMPTY_DICT,
891892
) -> View:
892893
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
@@ -140,7 +142,7 @@ def example_table_metadata_no_snapshot_v1_rest_json(example_table_metadata_no_sn
140142

141143

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

12821284

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

0 commit comments

Comments
 (0)