diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a4a2682cdf..f1decf7772 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,3 +70,11 @@ repos: ] additional_dependencies: - tomli==2.0.1 + - repo: https://github.com/ikamensh/flynt + rev: 1.0.1 + hooks: + - id: flynt + args: + # --line-length is set to a high value to deal with very long lines + - --line-length + - '99999' diff --git a/pyiceberg/io/pyarrow.py b/pyiceberg/io/pyarrow.py index a3d1869cf8..f3ef5ca5a0 100644 --- a/pyiceberg/io/pyarrow.py +++ b/pyiceberg/io/pyarrow.py @@ -633,7 +633,7 @@ def visit_pyarrow(obj: Union[pa.DataType, pa.Schema], visitor: PyArrowSchemaVisi Raises: NotImplementedError: If attempting to visit an unrecognized object type. """ - raise NotImplementedError("Cannot visit non-type: %s" % obj) + raise NotImplementedError(f"Cannot visit non-type: {obj}") @visit_pyarrow.register(pa.Schema) diff --git a/pyiceberg/schema.py b/pyiceberg/schema.py index 7fdd717858..b61e4678b9 100644 --- a/pyiceberg/schema.py +++ b/pyiceberg/schema.py @@ -794,7 +794,7 @@ def visit(obj: Union[Schema, IcebergType], visitor: SchemaVisitor[T]) -> T: Raises: NotImplementedError: If attempting to visit an unrecognized object type. """ - raise NotImplementedError("Cannot visit non-type: %s" % obj) + raise NotImplementedError(f"Cannot visit non-type: {obj}") @visit.register(Schema) @@ -862,7 +862,7 @@ def pre_order_visit(obj: Union[Schema, IcebergType], visitor: PreOrderSchemaVisi Raises: NotImplementedError: If attempting to visit an unrecognized object type. """ - raise NotImplementedError("Cannot visit non-type: %s" % obj) + raise NotImplementedError(f"Cannot visit non-type: {obj}") @pre_order_visit.register(Schema) diff --git a/tests/test_schema.py b/tests/test_schema.py index c12910a4b4..8e34423cf9 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -877,24 +877,21 @@ def test_identifier_fields_fails(table_schema_nested_with_struct_key_map: Schema with pytest.raises(ValueError) as exc_info: Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1, identifier_field_ids=[23]) assert ( - "Cannot add field zip as an identifier field: must not be nested in %s" - % table_schema_nested_with_struct_key_map.find_field("location") + f"Cannot add field zip as an identifier field: must not be nested in {table_schema_nested_with_struct_key_map.find_field('location')}" in str(exc_info.value) ) with pytest.raises(ValueError) as exc_info: Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1, identifier_field_ids=[26]) assert ( - "Cannot add field x as an identifier field: must not be nested in %s" - % table_schema_nested_with_struct_key_map.find_field("points") + f"Cannot add field x as an identifier field: must not be nested in {table_schema_nested_with_struct_key_map.find_field('points')}" in str(exc_info.value) ) with pytest.raises(ValueError) as exc_info: Schema(*table_schema_nested_with_struct_key_map.fields, schema_id=1, identifier_field_ids=[17]) assert ( - "Cannot add field age as an identifier field: must not be nested in an optional field %s" - % table_schema_nested_with_struct_key_map.find_field("person") + f"Cannot add field age as an identifier field: must not be nested in an optional field {table_schema_nested_with_struct_key_map.find_field('person')}" in str(exc_info.value) )