From a2cb02aaa61d55f87728093f1df301d43d72cce9 Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Thu, 19 Oct 2023 15:39:38 +0200 Subject: [PATCH 1/2] Add flake8-pie to ruff --- pyiceberg/io/pyarrow.py | 2 +- pyproject.toml | 1 + tests/test_integration.py | 10 +++------- tests/test_types.py | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pyiceberg/io/pyarrow.py b/pyiceberg/io/pyarrow.py index 29d4a4b170..0a419d2be4 100644 --- a/pyiceberg/io/pyarrow.py +++ b/pyiceberg/io/pyarrow.py @@ -1502,7 +1502,7 @@ def fill_parquet_file_metadata( invalidate_col: Set[int] = set() - for pos in range(0, parquet_metadata.num_columns): + for pos in range(parquet_metadata.num_columns): column = row_group.column(pos) field_id = parquet_column_mapping[column.path_in_schema] diff --git a/pyproject.toml b/pyproject.toml index 442a76b6c3..80759925db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -298,6 +298,7 @@ select = [ "W", # pycodestyle "F", # Pyflakes "B", # flake8-bugbear + "PIE", # flake8-pie "C4", # flake8-comprehensions "I", # isort "UP", # pyupgrade diff --git a/tests/test_integration.py b/tests/test_integration.py index 6e874b68fa..972647e229 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -116,7 +116,7 @@ def test_table_properties(table: Table) -> None: with table.transaction() as transaction: transaction.set_properties(abc="🤪") - assert table.properties == dict(**{"abc": "🤪"}, **DEFAULT_PROPERTIES) + assert table.properties == dict(abc="🤪", **DEFAULT_PROPERTIES) with table.transaction() as transaction: transaction.remove_properties("abc") @@ -125,7 +125,7 @@ def test_table_properties(table: Table) -> None: table = table.transaction().set_properties(abc="def").commit_transaction() - assert table.properties == dict(**{"abc": "def"}, **DEFAULT_PROPERTIES) + assert table.properties == dict(abc="def", **DEFAULT_PROPERTIES) table = table.transaction().remove_properties("abc").commit_transaction() @@ -225,11 +225,7 @@ def test_ray_all_types(table_test_all_types: Table) -> None: @pytest.mark.integration def test_pyarrow_to_iceberg_all_types(table_test_all_types: Table) -> None: fs = S3FileSystem( - **{ - "endpoint_override": "http://localhost:9000", - "access_key": "admin", - "secret_key": "password", - } + endpoint_override="http://localhost:9000", access_key="admin", secret_key="password" ) data_file_paths = [task.file.file_path for task in table_test_all_types.scan().plan_files()] for data_file_path in data_file_paths: diff --git a/tests/test_types.py b/tests/test_types.py index 6aed56c58f..ab2a81853b 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -496,7 +496,7 @@ def test_repr_nestedfield() -> None: def test_nestedfield_by_alias() -> None: # We should be able to initialize a NestedField by alias expected = NestedField(1, "required_field", StringType(), True, "this is a doc") - actual = NestedField(**{"id": 1, "name": "required_field", "type": "string", "required": True, "doc": "this is a doc"}) # type: ignore + actual = NestedField(id=1, name="required_field", type="string", required=True, doc="this is a doc") # type: ignore assert expected == actual From 0a535e697275250d17e19d780d61bff1b7c1f34f Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Thu, 19 Oct 2023 16:26:03 +0200 Subject: [PATCH 2/2] Fix tests --- tests/test_integration.py | 4 +--- tests/test_types.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 972647e229..282b38ae1b 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -224,9 +224,7 @@ def test_ray_all_types(table_test_all_types: Table) -> None: @pytest.mark.integration def test_pyarrow_to_iceberg_all_types(table_test_all_types: Table) -> None: - fs = S3FileSystem( - endpoint_override="http://localhost:9000", access_key="admin", secret_key="password" - ) + fs = S3FileSystem(endpoint_override="http://localhost:9000", access_key="admin", secret_key="password") data_file_paths = [task.file.file_path for task in table_test_all_types.scan().plan_files()] for data_file_path in data_file_paths: uri = urlparse(data_file_path) diff --git a/tests/test_types.py b/tests/test_types.py index ab2a81853b..38922f7fe5 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -496,7 +496,7 @@ def test_repr_nestedfield() -> None: def test_nestedfield_by_alias() -> None: # We should be able to initialize a NestedField by alias expected = NestedField(1, "required_field", StringType(), True, "this is a doc") - actual = NestedField(id=1, name="required_field", type="string", required=True, doc="this is a doc") # type: ignore + actual = NestedField(id=1, name="required_field", type="string", required=True, doc="this is a doc") assert expected == actual