Skip to content

Commit

Permalink
Bump pre-commit versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Fokko committed Nov 19, 2024
1 parent 93ebd39 commit bbd68ae
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 289 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exclude: ^vendor/

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -29,7 +29,7 @@ repos:
- id: check-ast
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version (Used for linting)
rev: v0.1.8
rev: v0.7.4
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix, --preview ]
Expand All @@ -47,7 +47,7 @@ repos:
- id: pycln
args: [--config=pyproject.toml]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
rev: v0.42.0
hooks:
- id: markdownlint
args: ["--fix"]
Expand Down
4 changes: 2 additions & 2 deletions pyiceberg/catalog/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def rename_table(self, from_identifier: Union[str, Identifier], to_identifier: U
log_message += f"Rolled back table creation for {to_database_name}.{to_table_name}."
except (NoSuchTableError, GenericDynamoDbError):
log_message += (
f"Failed to roll back table creation for {to_database_name}.{to_table_name}. " f"Please clean up manually"
f"Failed to roll back table creation for {to_database_name}.{to_table_name}. Please clean up manually"
)

raise ValueError(log_message) from e
Expand Down Expand Up @@ -635,7 +635,7 @@ def _convert_dynamo_table_item_to_iceberg_table(self, dynamo_table_item: Dict[st

if table_type.lower() != ICEBERG:
raise NoSuchIcebergTableError(
f"Property table_type is {table_type}, expected {ICEBERG}: " f"{database_name}.{table_name}"
f"Property table_type is {table_type}, expected {ICEBERG}: {database_name}.{table_name}"
)

io = load_file_io(properties=self.properties, location=metadata_location)
Expand Down
2 changes: 1 addition & 1 deletion pyiceberg/catalog/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def rename_table(self, from_identifier: Union[str, Identifier], to_identifier: U
log_message += f"Rolled back table creation for {to_database_name}.{to_table_name}."
except NoSuchTableError:
log_message += (
f"Failed to roll back table creation for {to_database_name}.{to_table_name}. " f"Please clean up manually"
f"Failed to roll back table creation for {to_database_name}.{to_table_name}. Please clean up manually"
)

raise ValueError(log_message) from e
Expand Down
2 changes: 1 addition & 1 deletion pyiceberg/io/pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,7 @@ def write_parquet(task: WriteTask) -> DataFile:
for batch in task.record_batches
]
arrow_table = pa.Table.from_batches(batches)
file_path = f'{table_metadata.location}/data/{task.generate_data_file_path("parquet")}'
file_path = f"{table_metadata.location}/data/{task.generate_data_file_path('parquet')}"
fo = io.new_output(file_path)
with fo.create(overwrite=True) as fos:
with pq.ParquetWriter(fos, schema=arrow_table.schema, **parquet_writer_kwargs) as writer:
Expand Down
2 changes: 1 addition & 1 deletion pyiceberg/table/update/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def add_column(

if required and not self._allow_incompatible_changes:
# Table format version 1 and 2 cannot add required column because there is no initial value
raise ValueError(f'Incompatible change: cannot add required column: {".".join(path)}')
raise ValueError(f"Incompatible change: cannot add required column: {'.'.join(path)}")

name = path[-1]
parent = path[:-1]
Expand Down
2 changes: 1 addition & 1 deletion pyiceberg/typedef.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class IcebergRootModel(RootModel[T], Generic[T]):

@lru_cache
def _get_struct_fields(struct_type: StructType) -> Tuple[str, ...]:
return tuple([field.name for field in struct_type.fields])
return tuple(field.name for field in struct_type.fields)


class Record(StructProtocol):
Expand Down
2 changes: 1 addition & 1 deletion pyiceberg/utils/schema_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def _convert_logical_map_type(self, avro_type: Dict[str, Any]) -> MapType:
"""
fields = avro_type["items"]["fields"]
if len(fields) != 2:
raise ValueError(f'Invalid key-value pair schema: {avro_type["items"]}')
raise ValueError(f"Invalid key-value pair schema: {avro_type['items']}")
key = self._convert_field(list(filter(lambda f: f["name"] == "key", fields))[0])
value = self._convert_field(list(filter(lambda f: f["name"] == "value", fields))[0])
return MapType(
Expand Down
2 changes: 1 addition & 1 deletion tests/avro/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import inspect
from _decimal import Decimal
from copy import copy
from datetime import date, datetime, time
from enum import Enum
Expand All @@ -23,7 +24,6 @@
from uuid import UUID

import pytest
from _decimal import Decimal
from fastavro import reader, writer

import pyiceberg.avro.file as avro
Expand Down
2 changes: 1 addition & 1 deletion tests/avro/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import io
import struct
from _decimal import Decimal
from typing import Dict, List

import pytest
from _decimal import Decimal

from pyiceberg.avro.encoder import BinaryEncoder
from pyiceberg.avro.resolver import construct_writer
Expand Down
2 changes: 1 addition & 1 deletion tests/catalog/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def create_table(
self.__namespaces[namespace] = {}

if not location:
location = f'{self._warehouse_location}/{"/".join(identifier)}'
location = f"{self._warehouse_location}/{'/'.join(identifier)}"
location = location.rstrip("/")

metadata_location = self._get_metadata_location(location=location)
Expand Down
48 changes: 24 additions & 24 deletions tests/catalog/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,19 @@ def test_properties_sets_headers(requests_mock: Mocker) -> None:
**{"header.Content-Type": "application/vnd.api+json", "header.Customized-Header": "some/value"},
)

assert (
catalog._session.headers.get("Content-type") == "application/json"
), "Expected 'Content-Type' default header not to be overwritten"
assert (
requests_mock.last_request.headers["Content-type"] == "application/json"
), "Config request did not include expected 'Content-Type' header"
assert catalog._session.headers.get("Content-type") == "application/json", (
"Expected 'Content-Type' default header not to be overwritten"
)
assert requests_mock.last_request.headers["Content-type"] == "application/json", (
"Config request did not include expected 'Content-Type' header"
)

assert (
catalog._session.headers.get("Customized-Header") == "some/value"
), "Expected 'Customized-Header' header to be 'some/value'"
assert (
requests_mock.last_request.headers["Customized-Header"] == "some/value"
), "Config request did not include expected 'Customized-Header' header"
assert catalog._session.headers.get("Customized-Header") == "some/value", (
"Expected 'Customized-Header' header to be 'some/value'"
)
assert requests_mock.last_request.headers["Customized-Header"] == "some/value", (
"Config request did not include expected 'Customized-Header' header"
)


def test_config_sets_headers(requests_mock: Mocker) -> None:
Expand All @@ -328,19 +328,19 @@ def test_config_sets_headers(requests_mock: Mocker) -> None:
catalog = RestCatalog("rest", uri=TEST_URI, warehouse="s3://some-bucket")
catalog.create_namespace(namespace)

assert (
catalog._session.headers.get("Content-type") == "application/json"
), "Expected 'Content-Type' default header not to be overwritten"
assert (
requests_mock.last_request.headers["Content-type"] == "application/json"
), "Create namespace request did not include expected 'Content-Type' header"
assert catalog._session.headers.get("Content-type") == "application/json", (
"Expected 'Content-Type' default header not to be overwritten"
)
assert requests_mock.last_request.headers["Content-type"] == "application/json", (
"Create namespace request did not include expected 'Content-Type' header"
)

assert (
catalog._session.headers.get("Customized-Header") == "some/value"
), "Expected 'Customized-Header' header to be 'some/value'"
assert (
requests_mock.last_request.headers["Customized-Header"] == "some/value"
), "Create namespace request did not include expected 'Customized-Header' header"
assert catalog._session.headers.get("Customized-Header") == "some/value", (
"Expected 'Customized-Header' header to be 'some/value'"
)
assert requests_mock.last_request.headers["Customized-Header"] == "some/value", (
"Create namespace request did not include expected 'Customized-Header' header"
)


def test_token_400(rest_mock: Mocker) -> None:
Expand Down
Loading

0 comments on commit bbd68ae

Please sign in to comment.