Skip to content

Commit

Permalink
Merge pull request #461 from dask-contrib/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
martindurant authored Jan 29, 2024
2 parents d91f85a + 889c3b2 commit 7fd9351
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
language_version: python3
Expand Down
31 changes: 14 additions & 17 deletions src/dask_awkward/layers/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,35 @@ def __repr__(self) -> str:


class ImplementsIOFunction(Protocol):
def __call__(self, *args, **kwargs):
...
def __call__(self, *args, **kwargs): ...


T = TypeVar("T")


class ImplementsMocking(ImplementsIOFunction, Protocol):
def mock(self) -> AwkwardArray:
...
def mock(self) -> AwkwardArray: ...


class ImplementsMockEmpty(ImplementsIOFunction, Protocol):
def mock_empty(self, backend: BackendT) -> AwkwardArray:
...
def mock_empty(self, backend: BackendT) -> AwkwardArray: ...


class ImplementsReport(ImplementsIOFunction, Protocol):
@property
def return_report(self) -> bool:
...
def return_report(self) -> bool: ...


class ImplementsProjection(ImplementsMocking, Protocol[T]):
def prepare_for_projection(self) -> tuple[AwkwardArray, TypeTracerReport, T]:
...
def prepare_for_projection(self) -> tuple[AwkwardArray, TypeTracerReport, T]: ...

def project(self, report: TypeTracerReport, state: T) -> ImplementsIOFunction:
...
def project(self, report: TypeTracerReport, state: T) -> ImplementsIOFunction: ...


class ImplementsNecessaryColumns(ImplementsProjection[T], Protocol):
def necessary_columns(self, report: TypeTracerReport, state: T) -> frozenset[str]:
...
def necessary_columns(
self, report: TypeTracerReport, state: T
) -> frozenset[str]: ...


class IOFunctionWithMocking(ImplementsMocking, ImplementsIOFunction):
Expand Down Expand Up @@ -300,9 +295,11 @@ def mock(self) -> MaterializedLayer:
if (name, 0) in mapping:
task = mapping[(name, 0)]
task = tuple(
(prev_name, 0)
if isinstance(v, tuple) and len(v) == 2 and v[0] == prev_name
else v
(
(prev_name, 0)
if isinstance(v, tuple) and len(v) == 2 and v[0] == prev_name
else v
)
for v in task
)

Expand Down
6 changes: 2 additions & 4 deletions src/dask_awkward/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2371,13 +2371,11 @@ def meta_or_identity(obj: Any) -> Any:


@overload
def to_meta(objects: Sequence[Any]) -> tuple[Any, ...]:
...
def to_meta(objects: Sequence[Any]) -> tuple[Any, ...]: ...


@overload
def to_meta(objects: dict[str, Any]) -> dict[str, Any]:
...
def to_meta(objects: dict[str, Any]) -> dict[str, Any]: ...


def to_meta(objects):
Expand Down
9 changes: 5 additions & 4 deletions src/dask_awkward/lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ def report_necessary_columns(

assert existing_columns is not None
# Update set of touched keys
name_to_necessary_columns[
name
] = existing_columns | layer.necessary_columns(
report=report, state=layer_to_projection_state[name]
name_to_necessary_columns[name] = (
existing_columns
| layer.necessary_columns(
report=report, state=layer_to_projection_state[name]
)
)

# Populate result with names of seen layers
Expand Down
15 changes: 5 additions & 10 deletions src/dask_awkward/lib/io/columnar.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,17 @@

class ImplementsColumnProjectionMixin(ImplementsNecessaryColumns, Protocol):
@property
def form(self) -> Form:
...
def form(self) -> Form: ...

@property
def behavior(self) -> dict | None:
...
def behavior(self) -> dict | None: ...

@property
def attrs(self) -> dict | None:
...
def attrs(self) -> dict | None: ...

def project_columns(self: T, columns: frozenset[str]) -> T:
...
def project_columns(self: T, columns: frozenset[str]) -> T: ...

def __call__(self, *args, **kwargs):
...
def __call__(self, *args, **kwargs): ...


S = TypeVar("S", bound=ImplementsColumnProjectionMixin)
Expand Down
15 changes: 5 additions & 10 deletions src/dask_awkward/lib/io/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ def __init__(
self.attrs = attrs

@abc.abstractmethod
def __call__(self, source: Any) -> ak.Array:
...
def __call__(self, source: Any) -> ak.Array: ...

@property
def use_optimization(self) -> bool:
Expand Down Expand Up @@ -783,23 +782,19 @@ def to_json(


@overload
def json_type(original: str, add_null: Literal[False] = False) -> str:
...
def json_type(original: str, add_null: Literal[False] = False) -> str: ...


@overload
def json_type(original: str, add_null: Literal[True]) -> list[str]:
...
def json_type(original: str, add_null: Literal[True]) -> list[str]: ...


@overload
def json_type(original: str, add_null: bool) -> str | list[str]:
...
def json_type(original: str, add_null: bool) -> str | list[str]: ...


@overload
def json_type(original: list[str], add_null: bool) -> list[str]:
...
def json_type(original: list[str], add_null: bool) -> list[str]: ...


def json_type(original: str | list[str], add_null: bool = False) -> str | list[str]:
Expand Down
6 changes: 2 additions & 4 deletions src/dask_awkward/lib/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ def __init__(
self.kwargs = kwargs

@abc.abstractmethod
def __call__(self, *args, **kwargs):
...
def __call__(self, *args, **kwargs): ...

@abc.abstractmethod
def project_columns(self, columns):
...
def project_columns(self, columns): ...

@property
def return_report(self) -> bool:
Expand Down
8 changes: 5 additions & 3 deletions src/dask_awkward/lib/unproject_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ def _unproject_layout(form, layout, length, backend):
return BitMaskedArray(
dummy_index_of(
form.mask,
unknown_length
if length is unknown_length
else math.ceil(length / 8.0),
(
unknown_length
if length is unknown_length
else math.ceil(length / 8.0)
),
backend.index_nplike,
),
_unproject_layout(form.content, None, length, backend),
Expand Down

0 comments on commit 7fd9351

Please sign in to comment.