Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions python/src/iceberg/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ def is_primitive(self) -> bool:

class FixedType(Type):
def __init__(self, length: int):
super().__init__(
f"fixed[{length}]", f"FixedType(length={length})", is_primitive=True
)
super().__init__(f"fixed[{length}]", f"FixedType(length={length})", is_primitive=True)
self._length = length

@property
Expand Down Expand Up @@ -125,8 +123,7 @@ def __repr__(self):

def __str__(self):
return (
f"{self._id}: {self._name}: {'optional' if self._is_optional else 'required'} {self._type}"
""
f"{self._id}: {self._name}: {'optional' if self._is_optional else 'required'} {self._type}" ""
if self._doc is None
else f" ({self._doc})"
)
Expand Down
4 changes: 1 addition & 3 deletions python/src/iceberg/utils/bin_packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@


class PackingIterator:
def __init__(
self, items, target_weight, lookback, weight_func, largest_bin_first=False
):
def __init__(self, items, target_weight, lookback, weight_func, largest_bin_first=False):
self.items = iter(items)
self.target_weight = target_weight
self.lookback = lookback
Expand Down
30 changes: 7 additions & 23 deletions python/tests/io/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ class LocalInputFile(InputFile):
def __init__(self, location: str):

parsed_location = urlparse(location) # Create a ParseResult from the uri
if (
parsed_location.scheme != "file"
): # Validate that a uri is provided with a scheme of `file`
if parsed_location.scheme != "file": # Validate that a uri is provided with a scheme of `file`
raise ValueError("LocalInputFile location must have a scheme of `file`")
elif parsed_location.netloc:
raise ValueError(
f"Network location is not allowed for LocalInputFile: {parsed_location.netloc}"
)
raise ValueError(f"Network location is not allowed for LocalInputFile: {parsed_location.netloc}")

super().__init__(location=location)
self._parsed_location = parsed_location
Expand All @@ -63,14 +59,10 @@ class LocalOutputFile(OutputFile):
def __init__(self, location: str):

parsed_location = urlparse(location) # Create a ParseResult from the uri
if (
parsed_location.scheme != "file"
): # Validate that a uri is provided with a scheme of `file`
if parsed_location.scheme != "file": # Validate that a uri is provided with a scheme of `file`
raise ValueError("LocalOutputFile location must have a scheme of `file`")
elif parsed_location.netloc:
raise ValueError(
f"Network location is not allowed for LocalOutputFile: {parsed_location.netloc}"
)
raise ValueError(f"Network location is not allowed for LocalOutputFile: {parsed_location.netloc}")

super().__init__(location=location)
self._parsed_location = parsed_location
Expand Down Expand Up @@ -102,11 +94,7 @@ def new_output(self, location: str):
return LocalOutputFile(location=location)

def delete(self, location: Union[str, LocalInputFile, LocalOutputFile]):
parsed_location = (
location.parsed_location
if isinstance(location, (InputFile, OutputFile))
else urlparse(location)
)
parsed_location = location.parsed_location if isinstance(location, (InputFile, OutputFile)) else urlparse(location)
os.remove(parsed_location.path)


Expand Down Expand Up @@ -262,9 +250,7 @@ def test_deleting_local_file_using_file_io(CustomFileIO):
assert not os.path.exists(output_file_location)


@pytest.mark.parametrize(
"CustomFileIO, CustomInputFile", [(LocalFileIO, LocalInputFile)]
)
@pytest.mark.parametrize("CustomFileIO, CustomInputFile", [(LocalFileIO, LocalInputFile)])
def test_deleting_local_file_using_file_io_InputFile(CustomFileIO, CustomInputFile):

with tempfile.TemporaryDirectory() as tmpdirname:
Expand All @@ -289,9 +275,7 @@ def test_deleting_local_file_using_file_io_InputFile(CustomFileIO, CustomInputFi
assert not os.path.exists(file_location)


@pytest.mark.parametrize(
"CustomFileIO, CustomOutputFile", [(LocalFileIO, LocalOutputFile)]
)
@pytest.mark.parametrize("CustomFileIO, CustomOutputFile", [(LocalFileIO, LocalOutputFile)])
def test_deleting_local_file_using_file_io_OutputFile(CustomFileIO, CustomOutputFile):

with tempfile.TemporaryDirectory() as tmpdirname:
Expand Down
15 changes: 3 additions & 12 deletions python/tests/utils/test_bin_packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def test_bin_packing(splits, lookback, split_size, open_cost):
def weight_func(x):
return max(x, open_cost)

item_list_sums = [
sum(item) for item in PackingIterator(splits, split_size, lookback, weight_func)
]
item_list_sums = [sum(item) for item in PackingIterator(splits, split_size, lookback, weight_func)]
assert all([split_size >= item_sum >= 0 for item_sum in item_list_sums])


Expand Down Expand Up @@ -78,15 +76,8 @@ def weight_func(x):
),
],
)
def test_bin_packing_lookback(
splits, target_weight, lookback, largest_bin_first, expected_lists
):
def test_bin_packing_lookback(splits, target_weight, lookback, largest_bin_first, expected_lists):
def weight_func(x):
return x

assert [
item
for item in PackingIterator(
splits, target_weight, lookback, weight_func, largest_bin_first
)
] == expected_lists
assert [item for item in PackingIterator(splits, target_weight, lookback, weight_func, largest_bin_first)] == expected_lists
4 changes: 2 additions & 2 deletions python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ deps =
commands =
autoflake -r --check --ignore-init-module-imports --remove-all-unused-imports setup.py src tests
isort --profile black --check-only setup.py src tests
black --check setup.py src tests
black --line-length 130 --check setup.py src tests

[testenv:format]
deps =
{[testenv:format-check]deps}
commands =
autoflake -r --in-place --ignore-init-module-imports --remove-all-unused-imports setup.py src tests
isort --profile black setup.py src tests
black setup.py src tests
black --line-length 130 setup.py src tests

[testenv:type-check]
deps =
Expand Down