This is an automated email from the ASF dual-hosted git repository.

dweeks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new 6c510d6f37 Python: Add Flake8 for simple checks (#5073)
6c510d6f37 is described below

commit 6c510d6f37727a889602651bf6551fac623c66aa
Author: Fokko Driesprong <[email protected]>
AuthorDate: Fri Jun 17 17:33:56 2022 +0200

    Python: Add Flake8 for simple checks (#5073)
---
 python/.pre-commit-config.yaml                    | 5 +++++
 python/tests/expressions/test_expressions_base.py | 6 +++---
 python/tests/io/test_io_base.py                   | 2 +-
 python/tests/test_conversions.py                  | 4 ++--
 python/tests/test_schema.py                       | 6 +++---
 5 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/python/.pre-commit-config.yaml b/python/.pre-commit-config.yaml
index b30c653478..8a8b31418e 100644
--- a/python/.pre-commit-config.yaml
+++ b/python/.pre-commit-config.yaml
@@ -50,3 +50,8 @@ repos:
     hooks:
       - id: pyupgrade
         args: [--py38-plus]
+  - repo: https://github.com/pycqa/flake8
+    rev: '4.0.1'
+    hooks:
+      - id: flake8
+        args: [ "--ignore=E501,W503" ]
diff --git a/python/tests/expressions/test_expressions_base.py 
b/python/tests/expressions/test_expressions_base.py
index 773d7ecc53..a6f8f07f76 100644
--- a/python/tests/expressions/test_expressions_base.py
+++ b/python/tests/expressions/test_expressions_base.py
@@ -275,8 +275,8 @@ def test_accessor_base_class(foo_struct):
     assert base.Accessor(position=6).get(foo_struct) == 1.234
     assert base.Accessor(position=7).get(foo_struct) == Decimal("1.234")
     assert base.Accessor(position=8).get(foo_struct) == uuid_value
-    assert base.Accessor(position=9).get(foo_struct) == True
-    assert base.Accessor(position=10).get(foo_struct) == False
+    assert base.Accessor(position=9).get(foo_struct) is True
+    assert base.Accessor(position=10).get(foo_struct) is False
     assert base.Accessor(position=11).get(foo_struct) == b"\x19\x04\x9e?"
 
 
@@ -317,7 +317,7 @@ def test_bound_reference(table_schema_simple, foo_struct):
 
     assert bound_ref1.eval(foo_struct) == "foovalue"
     assert bound_ref2.eval(foo_struct) == 123
-    assert bound_ref3.eval(foo_struct) == True
+    assert bound_ref3.eval(foo_struct) is True
 
 
 def test_boolean_expression_visitor():
diff --git a/python/tests/io/test_io_base.py b/python/tests/io/test_io_base.py
index 3cccd90a05..72495e19b6 100644
--- a/python/tests/io/test_io_base.py
+++ b/python/tests/io/test_io_base.py
@@ -322,7 +322,7 @@ def 
test_raise_file_not_found_error_for_fileio_delete(CustomFileIO):
         with pytest.raises(FileNotFoundError) as exc_info:
             file_io.delete(output_file_location)
 
-        assert (f"Cannot delete file") in str(exc_info.value)
+        assert "Cannot delete file" in str(exc_info.value)
 
         # Confirm that the file no longer exists
         assert not os.path.exists(output_file_location)
diff --git a/python/tests/test_conversions.py b/python/tests/test_conversions.py
index 76816a50c4..0f50868f7d 100644
--- a/python/tests/test_conversions.py
+++ b/python/tests/test_conversions.py
@@ -179,7 +179,7 @@ def test_partition_to_py(primitive_type, value_str, 
expected_result):
 )
 def test_none_partition_values(primitive_type):
     """Test converting a partition value to a python built-in"""
-    assert conversions.partition_to_py(primitive_type, None) == None
+    assert conversions.partition_to_py(primitive_type, None) is None
 
 
 @pytest.mark.parametrize(
@@ -203,7 +203,7 @@ def test_none_partition_values(primitive_type):
 )
 def test_hive_default_partition_values(primitive_type):
     """Test converting a partition value to a python built-in"""
-    assert conversions.partition_to_py(primitive_type, 
"__HIVE_DEFAULT_PARTITION__") == None
+    assert conversions.partition_to_py(primitive_type, 
"__HIVE_DEFAULT_PARTITION__") is None
 
 
 @pytest.mark.parametrize(
diff --git a/python/tests/test_schema.py b/python/tests/test_schema.py
index e5afe5fb74..81ebcf3556 100644
--- a/python/tests/test_schema.py
+++ b/python/tests/test_schema.py
@@ -218,19 +218,19 @@ def test_schema_find_field_by_id(table_schema_simple):
     assert isinstance(column1, NestedField)
     assert column1.field_id == 1
     assert column1.field_type == StringType()
-    assert column1.required == False
+    assert column1.required is False
 
     column2 = index[2]
     assert isinstance(column2, NestedField)
     assert column2.field_id == 2
     assert column2.field_type == IntegerType()
-    assert column2.required == True
+    assert column2.required is True
 
     column3 = index[3]
     assert isinstance(column3, NestedField)
     assert column3.field_id == 3
     assert column3.field_type == BooleanType()
-    assert column3.required == False
+    assert column3.required is False
 
 
 def test_schema_find_field_by_id_raise_on_unknown_field(table_schema_simple):

Reply via email to