Skip to content

Commit

Permalink
refactor: clean up type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Nov 13, 2023
1 parent bcc8844 commit 7966140
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 178 deletions.
10 changes: 5 additions & 5 deletions src/dask_awkward/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import operator
import sys
import warnings
from collections.abc import Callable, Hashable, Sequence
from collections.abc import Callable, Hashable, Mapping, Sequence
from enum import IntEnum
from functools import cached_property, partial, wraps
from numbers import Number
Expand Down Expand Up @@ -1479,8 +1479,8 @@ def new_array_object(
name: str,
*,
meta: ak.Array | None = None,
behavior: dict | None = None,
attrs: dict | None = None,
behavior: Mapping | None = None,
attrs: Mapping[str, Any] | None = None,
npartitions: int | None = None,
divisions: tuple[int, ...] | tuple[None, ...] | None = None,
) -> Array:
Expand Down Expand Up @@ -1877,8 +1877,8 @@ def non_trivial_reduction(
keepdims: bool,
mask_identity: bool,
reducer: Callable,
behavior: dict | None = None,
attrs: dict | None = None,
behavior: Mapping | None = None,
attrs: Mapping[str, Any] | None = None,
combiner: Callable | None = None,
token: str | None = None,
dtype: Any | None = None,
Expand Down
16 changes: 10 additions & 6 deletions src/dask_awkward/lib/io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import functools
import logging
import math
from collections.abc import Callable, Iterable
from collections.abc import Callable, Iterable, Mapping
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, cast

Expand Down Expand Up @@ -65,7 +65,7 @@ def __call__(self, start: int, stop: int, **kwargs: Any) -> ak.Array:
def from_awkward(
source: ak.Array,
npartitions: int,
behavior: dict | None = None,
behavior: Mapping | None = None,
label: str | None = None,
) -> Array:
"""Create an Array collection from a concrete :class:`awkward.Array` object.
Expand Down Expand Up @@ -116,7 +116,9 @@ def from_awkward(


class _FromListsFn:
def __init__(self, behavior: dict | None = None, attrs: dict | None = None):
def __init__(
self, behavior: Mapping | None = None, attrs: Mapping[str, Any] | None = None
):
self.behavior = behavior
self.attrs = attrs

Expand All @@ -125,7 +127,9 @@ def __call__(self, x: list) -> ak.Array:


def from_lists(
source: list, behavior: dict | None = None, attrs: dict | None = None
source: list,
behavior: Mapping | None = None,
attrs: Mapping[str, Any] | None = None,
) -> Array:
"""Create an Array collection from a list of lists.
Expand Down Expand Up @@ -166,7 +170,7 @@ def from_lists(
def from_delayed(
source: list[Delayed] | Delayed,
meta: ak.Array | None = None,
behavior: dict | None = None,
behavior: Mapping | None = None,
divisions: tuple[int, ...] | tuple[None, ...] | None = None,
prefix: str = "from-delayed",
) -> Array:
Expand Down Expand Up @@ -349,7 +353,7 @@ def to_dask_array(
return new_da_object(graph, name, meta=None, chunks=chunks, dtype=dtype)


def from_dask_array(array: DaskArray, behavior: dict | None = None) -> Array:
def from_dask_array(array: DaskArray, behavior: Mapping | None = None) -> Array:
"""Convert a Dask Array collection to a Dask Awkard Array collection.
Parameters
Expand Down
14 changes: 7 additions & 7 deletions src/dask_awkward/lib/io/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import abc
import logging
import math
from collections.abc import Callable
from collections.abc import Callable, Mapping
from typing import TYPE_CHECKING, Any, Literal, overload

import awkward as ak
Expand Down Expand Up @@ -43,7 +43,7 @@ def __init__(
form: Form,
compression: str | None = None,
schema: str | dict | list | None = None,
behavior: dict | None = None,
behavior: Mapping | None = None,
**kwargs: Any,
) -> None:
self.compression = compression
Expand Down Expand Up @@ -91,7 +91,7 @@ def __init__(
form: Form,
compression: str | None = None,
schema: str | dict | list | None = None,
behavior: dict | None = None,
behavior: Mapping | None = None,
**kwargs: Any,
) -> None:
super().__init__(
Expand Down Expand Up @@ -125,7 +125,7 @@ def __init__(
form: Form,
compression: str | None = None,
schema: str | dict | list | None = None,
behavior: dict | None = None,
behavior: Mapping | None = None,
**kwargs: Any,
) -> None:
super().__init__(
Expand Down Expand Up @@ -163,7 +163,7 @@ def __init__(
form: Form,
compression: str | None = None,
schema: str | dict | list | None = None,
behavior: dict | None = None,
behavior: Mapping | None = None,
**kwargs: Any,
) -> None:
super().__init__(
Expand Down Expand Up @@ -432,8 +432,8 @@ def from_json(
initial: int = 1024,
resize: float = 8,
highlevel: bool = True,
behavior: dict | None = None,
attrs: dict | None = None,
behavior: Mapping | None = None,
attrs: Mapping[str, Any] | None = None,
blocksize: int | str | None = None,
delimiter: bytes | None = None,
compression: str | None = "infer",
Expand Down
15 changes: 8 additions & 7 deletions src/dask_awkward/lib/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import math
import operator
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, Literal, TypeVar

import awkward as ak
Expand Down Expand Up @@ -41,8 +42,8 @@ def __init__(
listsep: str = "list.item",
unnamed_root: bool = False,
original_form: Form | None = None,
behavior: dict | None = None,
attrs: dict | None = None,
behavior: Mapping | None = None,
attrs: Mapping[str, Any] | None = None,
**kwargs: Any,
) -> None:
self.fs = fs
Expand Down Expand Up @@ -99,7 +100,7 @@ def __init__(
listsep: str = "list.item",
unnamed_root: bool = False,
original_form: Form | None = None,
behavior: dict | None = None,
behavior: Mapping | None = None,
**kwargs: Any,
) -> None:
super().__init__(
Expand Down Expand Up @@ -152,8 +153,8 @@ def __init__(
listsep: str = "list.item",
unnamed_root: bool = False,
original_form: Form | None = None,
behavior: dict | None = None,
attrs: dict | None = None,
behavior: Mapping | None = None,
attrs: Mapping[str, Any] | None = None,
**kwargs: Any,
) -> None:
super().__init__(
Expand Down Expand Up @@ -209,8 +210,8 @@ def from_parquet(
footer_sample_size: int = 1_000_000,
generate_bitmasks: bool = False,
highlevel: bool = True,
behavior: dict | None = None,
attrs: dict | None = None,
behavior: Mapping | None = None,
attrs: Mapping[str, Any] | None = None,
ignore_metadata: bool = True,
scan_files: bool = False,
split_row_groups: bool | None = False,
Expand Down
7 changes: 5 additions & 2 deletions src/dask_awkward/lib/operations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import annotations

from collections.abc import Mapping
from typing import Any

import awkward as ak
from dask.base import tokenize
from dask.highlevelgraph import HighLevelGraph
Expand Down Expand Up @@ -32,8 +35,8 @@ def concatenate(
axis: int = 0,
mergebool: bool = True,
highlevel: bool = True,
behavior: dict | None = None,
attrs: dict | None = None,
behavior: Mapping | None = None,
attrs: Mapping[str, Any] | None = None,
) -> Array:
label = "concatenate"
token = tokenize(arrays, axis, mergebool, highlevel, behavior)
Expand Down
Loading

0 comments on commit 7966140

Please sign in to comment.