Skip to content

Commit

Permalink
add cr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperrealist authored and danielballan committed Jun 18, 2024
1 parent 3b15912 commit 49c2bea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions tiled/_tests/test_slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def test_slicer_malicious_exec(slice: str):
_ = slice_(slice)


@pytest.mark.parametrize("slice", slice_typo_data + slice_malicious_data)
def test_slicer_fastapi_query_rejectsion(slice, client):
@pytest.mark.parametrize("slice_", slice_typo_data + slice_malicious_data)
def test_slicer_fastapi_query_rejection(slice_, client):
http_client = client.context.http_client
response = http_client.get(f"/api/v1/array/block/x?block=0&slice={slice}")
response = http_client.get(f"/api/v1/array/block/x?block=0&slice={slice_}")
assert response.status_code == HTTP_422_UNPROCESSABLE_ENTITY
2 changes: 1 addition & 1 deletion tiled/client/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def read_block(self, block, slice=None):

def read(self, slice=None):
"""
Acess the entire array or a slice.
Access the entire array or a slice.
The array will be internally chunked with dask.
"""
Expand Down
18 changes: 9 additions & 9 deletions tiled/server/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,17 @@ def expected_shape(
return tuple(map(int, expected_shape.split(",")))


def np_style_slicer(indices: tuple):
return indices[0] if len(indices) == 1 else slice_func(*indices)


def parse_slice_str(dim: str):
return np_style_slicer(tuple(int(idx) if idx else None for idx in dim.split(":")))


def slice_(
slice: str = Query(None, pattern=SLICE_REGEX),
slice: Optional[str] = Query(None, pattern=SLICE_REGEX),
):
"Specify and parse a block index parameter."

def np_style_slicer(indices: tuple):
return indices[0] if len(indices) == 1 else slice_func(*indices)

def parse_slice_str(dim: str):
return np_style_slicer(
tuple(int(idx) if idx else None for idx in dim.split(":"))
)

return tuple(parse_slice_str(dim) for dim in (slice or "").split(",") if dim)

0 comments on commit 49c2bea

Please sign in to comment.