liblaf.grapes
¶
Modules:
-
attrs– -
bench– -
compat– -
conf– -
deps– -
errors– -
fieldz– -
functools– -
icecream– -
itertools– -
logging– -
magic– -
pretty– -
rich– -
sentinel– -
serde–This module provides functions for serialization and deserialization of various data formats, including JSON, TOML, YAML, and Pydantic models. It also includes registries for mapping file extensions to their respective serialization and deserialization functions.
-
timing– -
typing– -
wadler_lindig– -
warnings–
Type Aliases:
Classes:
-
BaseTimer– -
BenchResults– -
Bencher– -
DispatchLookupError– -
LazyRepr– -
LazyStr– -
MatchError– -
Progress– -
Timer– -
TodoError– -
UnreachableError–
Functions:
-
areidentical–Determine if sequences are identical element-wise. This lazily evaluates the sequences and stops as soon as the result is determined.
-
array_kind– -
as_iterable–.
-
as_sequence–.
-
auto_rich_repr– -
compact–Filter an iterable on "truthy" values.
-
contains–.
-
dec_hook– -
enc_hook– -
entrypoint– -
first_not_none–Returns the first
not Nonevalue in theargs. -
get_console– -
get_timer– -
getitem–.
-
has_ansi–.
-
in_ci– -
is_array– -
keyjoin–Inner join two sequences of dictionaries on specified keys, merging matches with right value precedence.
-
len_or_none– -
load– -
memorize– -
omit–Return a subset of the provided dictionary with keys not contained in the denylist.
-
optional_deps– -
pdoc– -
pformat– -
pick–Return a subset of the provided dictionary with keys contained in the allowlist.
-
pprint–Pretty-prints an object to stdout.
-
pretty_call–.
-
pretty_duration–.
-
pretty_durations–.
-
pretty_func– -
pretty_quantities–.
-
pretty_quantity–.
-
pretty_quantity_components– -
pretty_throughput–.
-
save– -
timer– -
todo– -
track– -
unreachable– -
warn– -
wraps– -
wrapt_getattr– -
wrapt_setattr–
Attributes:
-
MISSING(Final[MissingType]) – -
__commit_id__(str | None) – -
__version__(str) – -
__version_tuple__(tuple[int | str, ...]) – -
config(Config) – -
json– -
toml– -
yaml–
__version_tuple__
module-attribute
¶
BaseTimer
¶
Bases: Timings
flowchart TD
liblaf.grapes.BaseTimer[BaseTimer]
liblaf.grapes.timing._timings.Timings[Timings]
liblaf.grapes.timing._timings.Timings --> liblaf.grapes.BaseTimer
click liblaf.grapes.BaseTimer href "" "liblaf.grapes.BaseTimer"
click liblaf.grapes.timing._timings.Timings href "" "liblaf.grapes.timing._timings.Timings"
Parameters:
-
(label¶str | None, default:None) – -
(name¶str | None, default:None) – -
(clocks¶Sequence[ClockName], default:('perf',)) – -
(cb_start¶Callback | None, default:None) – -
(cb_stop¶Callback | None, default:<function log_record at 0x7f8a6ee77320>) – -
(cb_finish¶Callback | None, default:<function log_summary at 0x7f8a6ee77740>) –
Attributes:
Methods:
-
__attrs_post_init__– -
__bool__– -
__len__– -
clear– -
elapsed– -
finish– -
log_record– -
log_summary– -
pretty_record– -
pretty_summary– -
start– -
stop–
clocks
class-attribute
instance-attribute
¶
clocks: Sequence[ClockName] = field(default=DEFAULT_CLOCKS)
timings
class-attribute
instance-attribute
¶
__attrs_post_init__
¶
Source code in src/liblaf/grapes/timing/_timings.py
clear
¶
elapsed
¶
Source code in src/liblaf/grapes/timing/_timings.py
finish
¶
log_record
¶
log_record(
*,
index: int = -1,
level: int = LOG_RECORD_DEFAULT_LEVEL,
limits: str | RateLimitItem | None = "1/second",
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
log_summary
¶
log_summary(
*,
level: int = LOG_SUMMARY_DEFAULT_LEVEL,
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
limits: str | RateLimitItem | None = None,
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
pretty_record
¶
Source code in src/liblaf/grapes/timing/_timings.py
pretty_summary
¶
pretty_summary(
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
*,
rich_markup: bool = False,
) -> str
Source code in src/liblaf/grapes/timing/_timings.py
start
¶
stop
¶
Source code in src/liblaf/grapes/timing/_base.py
BenchResults
¶
Parameters:
Methods:
-
plot–
Attributes:
plot
¶
plot(
*,
relative_to: str | None = None,
xlabel: str = "Size",
ylabel: str = "Time (sec)",
log_scale: bool = True,
) -> Figure
Source code in src/liblaf/grapes/bench/_results.py
Bencher
¶
Parameters:
-
(min_time¶float, default:0.2) – -
(timeout¶float, default:10.0) – -
(warmup¶int, default:1) –
Methods:
Attributes:
run
¶
run() -> BenchResults
Source code in src/liblaf/grapes/bench/_bencher.py
setup
¶
DispatchLookupError
¶
Bases: LookupError
flowchart TD
liblaf.grapes.DispatchLookupError[DispatchLookupError]
click liblaf.grapes.DispatchLookupError href "" "liblaf.grapes.DispatchLookupError"
Parameters:
Methods:
-
__str__–
Attributes:
Source code in src/liblaf/grapes/errors/_dispatch.py
LazyRepr
¶
MatchError
¶
Bases: ValueError
flowchart TD
liblaf.grapes.MatchError[MatchError]
click liblaf.grapes.MatchError href "" "liblaf.grapes.MatchError"
Parameters:
Methods:
-
__str__–
Attributes:
Progress
¶
Progress(
*columns: str | ProgressColumn,
limit: str | RateLimitItem | None = None,
limiter: RateLimiter | None = None,
logger: Logger | None = None,
speed_estimate_period: float = 30.0,
get_time: GetTimeCallable | None = None,
disable: bool = False,
expand: bool = False,
)
Bases: Progress
flowchart TD
liblaf.grapes.Progress[Progress]
click liblaf.grapes.Progress href "" "liblaf.grapes.Progress"
Methods:
Attributes:
Source code in src/liblaf/grapes/rich/progress/_progress.py
get_default_columns
classmethod
¶
Source code in src/liblaf/grapes/rich/progress/_progress.py
reset
¶
reset(
task_id: TaskID,
*,
start: bool = True,
total: float | None = None,
completed: int = 0,
visible: bool | None = None,
description: str | None = None,
**fields: Any,
) -> None
Source code in src/liblaf/grapes/rich/progress/_progress.py
start
¶
stop
¶
update
¶
update(
task_id: TaskID,
*,
total: float | None = None,
completed: float | None = None,
advance: float | None = None,
description: str | None = None,
visible: bool | None = None,
refresh: bool = False,
**fields: Any,
) -> None
Source code in src/liblaf/grapes/rich/progress/_progress.py
Timer
¶
Bases: BaseTimer, AbstractContextManager
flowchart TD
liblaf.grapes.Timer[Timer]
liblaf.grapes.timing._base.BaseTimer[BaseTimer]
liblaf.grapes.timing._timings.Timings[Timings]
liblaf.grapes.timing._base.BaseTimer --> liblaf.grapes.Timer
liblaf.grapes.timing._timings.Timings --> liblaf.grapes.timing._base.BaseTimer
click liblaf.grapes.Timer href "" "liblaf.grapes.Timer"
click liblaf.grapes.timing._base.BaseTimer href "" "liblaf.grapes.timing._base.BaseTimer"
click liblaf.grapes.timing._timings.Timings href "" "liblaf.grapes.timing._timings.Timings"
Parameters:
-
(label¶str | None, default:None) – -
(name¶str | None, default:None) – -
(clocks¶Sequence[ClockName], default:('perf',)) – -
(cb_start¶Callback | None, default:None) – -
(cb_stop¶Callback | None, default:<function log_record at 0x7f8a6ee77320>) – -
(cb_finish¶Callback | None, default:<function log_summary at 0x7f8a6ee77740>) –
Attributes:
Methods:
-
__attrs_post_init__– -
__bool__– -
__call__– -
__enter__– -
__exit__– -
__len__– -
clear– -
elapsed– -
finish– -
log_record– -
log_summary– -
pretty_record– -
pretty_summary– -
start– -
stop–
clocks
class-attribute
instance-attribute
¶
clocks: Sequence[ClockName] = field(default=DEFAULT_CLOCKS)
timings
class-attribute
instance-attribute
¶
__attrs_post_init__
¶
Source code in src/liblaf/grapes/timing/_timings.py
__call__
¶
__exit__
¶
__exit__(
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
traceback: TracebackType | None,
) -> None
Source code in src/liblaf/grapes/timing/_timer.py
clear
¶
elapsed
¶
Source code in src/liblaf/grapes/timing/_timings.py
finish
¶
log_record
¶
log_record(
*,
index: int = -1,
level: int = LOG_RECORD_DEFAULT_LEVEL,
limits: str | RateLimitItem | None = "1/second",
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
log_summary
¶
log_summary(
*,
level: int = LOG_SUMMARY_DEFAULT_LEVEL,
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
limits: str | RateLimitItem | None = None,
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
pretty_record
¶
Source code in src/liblaf/grapes/timing/_timings.py
pretty_summary
¶
pretty_summary(
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
*,
rich_markup: bool = False,
) -> str
Source code in src/liblaf/grapes/timing/_timings.py
start
¶
stop
¶
Source code in src/liblaf/grapes/timing/_base.py
TodoError
¶
Bases: NotImplementedError
flowchart TD
liblaf.grapes.TodoError[TodoError]
click liblaf.grapes.TodoError href "" "liblaf.grapes.TodoError"
Parameters:
Methods:
-
__str__–
Attributes:
UnreachableError
¶
Bases: AssertionError
flowchart TD
liblaf.grapes.UnreachableError[UnreachableError]
click liblaf.grapes.UnreachableError href "" "liblaf.grapes.UnreachableError"
Parameters:
Methods:
-
__str__–
Attributes:
areidentical
¶
Determine if sequences are identical element-wise. This lazily evaluates the sequences and stops as soon as the result is determined.
Examples:
Source code in src/liblaf/grapes/itertools/_toolz.py
array_kind
¶
Source code in src/liblaf/grapes/typing/_array.py
as_iterable
¶
.
Examples:
If obj is iterable, return an iterator over its items:
If obj is not iterable, return a one-item iterable containing obj:
If obj is None, return an empty iterable:
By default, binary and text strings are not considered iterable:
If base_type is set, objects for which isinstance(obj, base_type) returns True won't be considered iterable.
>>> obj = {"a": 1}
>>> as_iterable(obj)
{'a': 1}
>>> as_iterable(obj, base_type=dict) # Treat dicts as a unit
({'a': 1},)
Set base_type to None to avoid any special handling and treat objects Python considers iterable as iterable:
References
Source code in src/liblaf/grapes/itertools/_as_iterable.py
as_sequence
¶
.
Examples:
If obj is iterable, return an iterator over its items:
If obj is not iterable, return a one-item iterable containing obj:
If obj is None, return an empty iterable:
By default, binary and text strings are not considered iterable:
If base_type is set, objects for which isinstance(obj, base_type) returns True won't be considered iterable.
>>> obj = {"a": 1}
>>> as_sequence(obj)
({'a': 1},)
>>> as_sequence(obj, base_type=dict) # Treat dicts as a unit
({'a': 1},)
Set base_type to None to avoid any special handling and treat objects Python considers iterable as iterable:
References
Source code in src/liblaf/grapes/itertools/_as_sequence.py
auto_rich_repr
¶
Source code in src/liblaf/grapes/rich/repr/_auto.py
compact
¶
Filter an iterable on "truthy" values.
Examples:
Source code in src/liblaf/grapes/itertools/_toolz.py
contains
¶
contains[T](
obj: Container[T],
key: T,
deprecated_keys: Iterable[T] = (),
*,
msg: str = _DEPRECATED_MESSAGE,
) -> bool
.
Examples:
>>> import pytest
>>> data = {"a": 1, "b": 2}
>>> contains(data, "a")
True
>>> contains(data, "missing")
False
>>> with pytest.deprecated_call():
... contains(data, "c", deprecated_keys=["missing", "b"])
True
Source code in src/liblaf/grapes/compat/_operator.py
dec_hook
¶
dec_hook(
typ: type,
obj: Any,
/,
*,
pydantic_options: PydanticValidateOptions | None = None,
) -> Any
Source code in src/liblaf/grapes/serde/_decode.py
enc_hook
¶
first_not_none
¶
Returns the first not None value in the args.
Examples:
References
Source code in src/liblaf/grapes/itertools/_first_not_none.py
get_console
cached
¶
Source code in src/liblaf/grapes/rich/_get_console.py
get_timer
¶
getitem
¶
getitem[KT, VT](
obj: SupportsGetItem[KT, VT],
key: KT,
deprecated_keys: Iterable[KT] = (),
*,
msg: str = _DEPRECATED_MESSAGE,
) -> VT
.
Examples:
>>> import pytest
>>> data = {"a": 1, "b": 2}
>>> getitem(data, "a")
1
>>> with pytest.raises(KeyError):
... getitem(data, "missing")
>>> with pytest.deprecated_call():
... getitem(data, "c", deprecated_keys=["missing", "b"])
2
Source code in src/liblaf/grapes/compat/_operator.py
has_ansi
¶
.
Examples:
is_array
¶
keyjoin
¶
keyjoin[KT, VT](
leftkey: KT,
leftseq: Iterable[Mapping[KT, VT]],
rightkey: KT,
rightseq: Iterable[Mapping[KT, VT]],
) -> Iterator[Mapping[KT, VT]]
Inner join two sequences of dictionaries on specified keys, merging matches with right value precedence.
Examples:
>>> people = [
... {"id": 0, "name": "Anonymous Guy", "location": "Unknown"},
... {"id": 1, "name": "Karan", "location": "San Francisco"},
... {"id": 2, "name": "Matthew", "location": "Oakland"},
... ]
>>> hobbies = [
... {"person_id": 1, "hobby": "Tennis"},
... {"person_id": 1, "hobby": "Acting"},
... {"person_id": 2, "hobby": "Biking"},
... ]
>>> list(keyjoin("id", people, "person_id", hobbies))
[{'id': 1, 'name': 'Karan', 'location': 'San Francisco', 'person_id': 1, 'hobby': 'Tennis'}, {'id': 1, 'name': 'Karan', 'location': 'San Francisco', 'person_id': 1, 'hobby': 'Acting'}, {'id': 2, 'name': 'Matthew', 'location': 'Oakland', 'person_id': 2, 'hobby': 'Biking'}]
Source code in src/liblaf/grapes/itertools/_toolz.py
len_or_none
¶
load
¶
load(
path: StrPath,
/,
*,
dec_hook: DecHook | None = ...,
force_ext: str | None = None,
pydantic: PydanticValidateOptions | None = None,
strict: bool = True,
) -> Any
load[T](
path: StrPath,
/,
*,
dec_hook: DecHook | None = ...,
force_ext: str | None = None,
pydantic: PydanticValidateOptions | None = None,
strict: bool = True,
type: type[T],
) -> T
memorize
¶
memorize[**P, T](
func: Callable[P, T],
/,
*,
memory: Memory | None = ...,
ignore: list[str] | None = ...,
verbose: int | None = ...,
mmap_mode: Literal["r+", "r", "w+", "c"] | None = ...,
cache_validation_callback: Callable[[Metadata], bool]
| None = ...,
bytes_limit: int | str | None = ...,
items_limit: int | None = ...,
age_limit: timedelta | None = ...,
) -> MemorizedFunc[P, T]
memorize[**P, T](
*,
memory: Memory | None = None,
ignore: list[str] | None = ...,
verbose: int | None = ...,
mmap_mode: Literal["r+", "r", "w+", "c"] | None = ...,
cache_validation_callback: Callable[[Metadata], bool]
| None = ...,
bytes_limit: int | str | None = ...,
items_limit: int | None = ...,
age_limit: timedelta | None = ...,
) -> Callable[[Callable[P, T]], MemorizedFunc[P, T]]
Source code in src/liblaf/grapes/functools/_memorize.py
omit
¶
Return a subset of the provided dictionary with keys not contained in the denylist.
Examples:
Source code in src/liblaf/grapes/itertools/_toolz.py
optional_deps
¶
Source code in src/liblaf/grapes/deps/_optional.py
pdoc
¶
pdoc(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
pformat
¶
pformat(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> str
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
pick
¶
Return a subset of the provided dictionary with keys contained in the allowlist.
Examples:
Source code in src/liblaf/grapes/itertools/_toolz.py
pprint
¶
pprint(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> None
Pretty-prints an object to stdout.
Examples:
array:
>>> import numpy as np
>>> pprint(np.zeros((2, 3)))
array([[0., 0., 0.],
[0., 0., 0.]])
>>> pprint(np.zeros((20, 30)))
f64[20,30](numpy)
datetime:
>>> import datetime
>>> pprint(datetime.datetime(1970, 1, 1, tzinfo=datetime.UTC))
1970-01-01T00:00:00+00:00
dataclass:
>>> import dataclasses
>>> import numpy as np
>>> @dataclasses.dataclass
... class MyDataclass:
... x: list[str]
... y: np.ndarray
>>> obj = MyDataclass(["lorem", "ipsum", "dolor sit amet"], np.zeros((2, 3)))
>>> pprint(obj, width=30, indent=4)
MyDataclass(
x=[
'lorem',
'ipsum',
'dolor sit amet'
],
y=array([[0., 0., 0.],
[0., 0., 0.]])
)
dict:
pydantic:
>>> import pydantic
>>> class MyModel(pydantic.RootModel[list[str]]): ...
>>> obj = MyModel(["lorem", "ipsum", "dolor sit amet"])
>>> pprint(obj)
MyModel['lorem', 'ipsum', 'dolor sit amet']
rich.repr:
>>> import rich
>>> class Bird:
... def __rich_repr__(self):
... yield "penguin"
... yield "eats", ["fish"]
... yield "fly", False, True
... yield "extinct", False, False
>>> pprint(Bird())
Bird('penguin', eats=['fish'], fly=False)
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/_pprint.py
pretty_call
¶
pretty_call(
func: Callable,
args: Sequence[Any] = (),
kwargs: Mapping[str, Any] = {},
**wl_kwargs,
) -> str
.
Examples:
>>> def foo(a: int, b: int, c: int = 3): ...
>>> print(pretty_call(foo, (1, 2), {"c": 4}))
foo(1, 2, 4)
Source code in src/liblaf/grapes/pretty/_call.py
pretty_duration
¶
.
Examples:
Source code in src/liblaf/grapes/pretty/_duration.py
pretty_durations
¶
pretty_durations(
seconds: Iterable[float], *, prec: int = 2, **kwargs
) -> PrettyQuantitiesComponents
.
Examples:
>>> pretty_durations([0.1234, 0.01234, 0.001234])
PrettyQuantitiesComponents(mantissas=['123.', '12.', '1.'], spacer=' ', units='ms')
Source code in src/liblaf/grapes/pretty/_duration.py
pretty_func
¶
pretty_quantities
¶
pretty_quantities(
values: Iterable[float],
unit: str | None = None,
*,
prec: int = 2,
**kwargs,
) -> PrettyQuantitiesComponents
.
Examples:
>>> pretty_quantities([0.1234, 0.01234, 0.001234], "s")
PrettyQuantitiesComponents(mantissas=['123.', '12.', '1.'], spacer=' ', units='ms')
Source code in src/liblaf/grapes/pretty/_quantiphy.py
pretty_quantity
¶
.
Examples:
Source code in src/liblaf/grapes/pretty/_quantiphy.py
pretty_quantity_components
¶
pretty_quantity_components(
value: float,
unit: str | None = None,
*,
prec: int = 2,
**kwargs,
) -> PrettyQuantityComponents
Source code in src/liblaf/grapes/pretty/_quantiphy.py
pretty_throughput
¶
.
Examples:
Source code in src/liblaf/grapes/pretty/_throughput.py
save
¶
save(
path: StrPath,
obj: Any,
/,
*,
enc_hook: EncHook | None = ...,
force_ext: str | None = None,
order: Literal["deterministic", "sorted"] | None = None,
pydantic: PydanticDumpOptions | None = None,
) -> None
timer
¶
timer(
*,
label: str | None = ...,
clocks: Sequence[ClockName] = ...,
cb_finish: Callback | None = ...,
cb_start: Callback | None = ...,
cb_stop: Callback | None = ...,
) -> Timer
todo
¶
track
¶
track[T](
sequence: Iterable[T],
total: float | None = None,
completed: int = 0,
description: str = "Working...",
*,
progress: Progress | None = None,
) -> Iterable[T]
Source code in src/liblaf/grapes/rich/progress/_track.py
unreachable
¶
warn
¶
Source code in src/liblaf/grapes/warnings/_warn.py
wraps
¶
wrapt_getattr
¶
Source code in src/liblaf/grapes/functools/_wrapt.py
wrapt_setattr
¶
bench
¶
Classes:
-
BenchResults– -
Bencher–
BenchResults
¶
Parameters:
Methods:
-
plot–
Attributes:
plot
¶
plot(
*,
relative_to: str | None = None,
xlabel: str = "Size",
ylabel: str = "Time (sec)",
log_scale: bool = True,
) -> Figure
Source code in src/liblaf/grapes/bench/_results.py
Bencher
¶
Parameters:
-
(min_time¶float, default:0.2) – -
(timeout¶float, default:10.0) – -
(warmup¶int, default:1) –
Methods:
Attributes:
run
¶
run() -> BenchResults
Source code in src/liblaf/grapes/bench/_bencher.py
setup
¶
compat
¶
Functions:
contains
¶
contains[T](
obj: Container[T],
key: T,
deprecated_keys: Iterable[T] = (),
*,
msg: str = _DEPRECATED_MESSAGE,
) -> bool
.
Examples:
>>> import pytest
>>> data = {"a": 1, "b": 2}
>>> contains(data, "a")
True
>>> contains(data, "missing")
False
>>> with pytest.deprecated_call():
... contains(data, "c", deprecated_keys=["missing", "b"])
True
Source code in src/liblaf/grapes/compat/_operator.py
getitem
¶
getitem[KT, VT](
obj: SupportsGetItem[KT, VT],
key: KT,
deprecated_keys: Iterable[KT] = (),
*,
msg: str = _DEPRECATED_MESSAGE,
) -> VT
.
Examples:
>>> import pytest
>>> data = {"a": 1, "b": 2}
>>> getitem(data, "a")
1
>>> with pytest.raises(KeyError):
... getitem(data, "missing")
>>> with pytest.deprecated_call():
... getitem(data, "c", deprecated_keys=["missing", "b"])
2
Source code in src/liblaf/grapes/compat/_operator.py
conf
¶
Classes:
-
BaseConfig–.
-
Entry– -
Field–.
-
FieldMethod– -
GroupEntry– -
ListFieldMethod– -
VarEntry–
Functions:
-
group–
Attributes:
-
METADATA_KEY– -
bool(FieldMethod[bool]) – -
decimal(FieldMethod[Decimal]) – -
float(FieldMethod[float]) – -
int(FieldMethod[int]) – -
list(ListFieldMethod) – -
path(FieldMethod[Path]) – -
str(FieldMethod[str]) –
BaseConfig
¶
BaseConfig(name: str = '')
.
Examples:
>>> from liblaf.grapes import conf
>>> class Config(BaseConfig):
... a: conf.Field[int] = conf.int(default=0)
>>> config = Config()
>>> config.get()
{'a': 0}
>>> config.a.get()
0
>>> with config.a.overrides(1):
... config.get()
{'a': 1}
>>> config.get()
{'a': 0}
>>> with config.overrides(a=1):
... config.get()
{'a': 1}
>>> config.get()
{'a': 0}
Methods:
Source code in src/liblaf/grapes/conf/_config.py
__pdoc__
¶
__rich_repr__
¶
get
¶
Source code in src/liblaf/grapes/conf/_config.py
overrides
¶
Source code in src/liblaf/grapes/conf/_config.py
set
¶
Entry
¶
Field
¶
Field(
name: str,
*,
default: T | MissingType = MISSING,
env: str | None = None,
factory: Callable[[], T] | None = None,
getter: Callable[[str], T],
)
.
Examples:
>>> from environs import env
>>> a = Field("a", default=0, getter=env.int)
>>> a
Field(name='a', value=0)
>>> a.name
'a'
>>> a.get()
0
>>> with a.overrides(1):
... a.get()
1
>>> a.get()
0
>>> a = Field("a", factory=lambda: 0, getter=env.int)
>>> a.get()
0
Methods:
Attributes:
Source code in src/liblaf/grapes/conf/_field.py
FieldMethod
¶
Parameters:
-
(wrapped¶FieldMethod[T]) –
Methods:
-
__call__–
Attributes:
-
wrapped(FieldMethod[T]) –
__call__
¶
__call__(
*,
default: None,
env: str | None = None,
**kwargs: Unpack[BaseMethodKwargs],
) -> Field[T | None]
Parameters:
Source code in src/liblaf/grapes/conf/_field_method.py
GroupEntry
¶
Bases: Entry[T]
flowchart TD
liblaf.grapes.conf.GroupEntry[GroupEntry]
liblaf.grapes.conf._entry.Entry[Entry]
liblaf.grapes.conf._entry.Entry --> liblaf.grapes.conf.GroupEntry
click liblaf.grapes.conf.GroupEntry href "" "liblaf.grapes.conf.GroupEntry"
click liblaf.grapes.conf._entry.Entry href "" "liblaf.grapes.conf._entry.Entry"
Methods:
-
make–
ListFieldMethod
¶
Parameters:
-
(wrapped¶ListFieldMethod) –
Methods:
-
__call__–
Attributes:
-
wrapped(ListFieldMethod) –
__call__
¶
__call__(
subcast: Subcast[T] | None = None,
*,
delimiter: str | None = None,
env: str | None = None,
factory: Callable[[], list[T]] | None = list,
validate: Callable[[Any], Any]
| Iterable[Callable[[Any], Any]]
| None = ...,
) -> Field[list[T]]
Parameters:
Source code in src/liblaf/grapes/conf/_field_method.py
VarEntry
¶
flowchart TD
liblaf.grapes.conf.VarEntry[VarEntry]
liblaf.grapes.conf._entry.Entry[Entry]
liblaf.grapes.conf._entry.Entry --> liblaf.grapes.conf.VarEntry
click liblaf.grapes.conf.VarEntry href "" "liblaf.grapes.conf.VarEntry"
click liblaf.grapes.conf._entry.Entry href "" "liblaf.grapes.conf._entry.Entry"
Parameters:
-
(getter¶Callable[[str], T]) – -
(default¶T | MissingType, default:<MISSING>) – -
(env¶str | None, default:None) – -
(factory¶Callable[[], T] | None, default:None) –
Methods:
-
make–
Attributes:
-
default(T | MissingType) – -
env(str | None) – -
factory(Callable[[], T] | None) – -
getter(Callable[[str], T]) –
make
¶
errors
¶
Classes:
Functions:
-
todo– -
unreachable–
DispatchLookupError
¶
Bases: LookupError
flowchart TD
liblaf.grapes.errors.DispatchLookupError[DispatchLookupError]
click liblaf.grapes.errors.DispatchLookupError href "" "liblaf.grapes.errors.DispatchLookupError"
Parameters:
Methods:
-
__str__–
Attributes:
Source code in src/liblaf/grapes/errors/_dispatch.py
MatchError
¶
Bases: ValueError
flowchart TD
liblaf.grapes.errors.MatchError[MatchError]
click liblaf.grapes.errors.MatchError href "" "liblaf.grapes.errors.MatchError"
Parameters:
Methods:
-
__str__–
Attributes:
TodoError
¶
Bases: NotImplementedError
flowchart TD
liblaf.grapes.errors.TodoError[TodoError]
click liblaf.grapes.errors.TodoError href "" "liblaf.grapes.errors.TodoError"
Parameters:
Methods:
-
__str__–
Attributes:
UnreachableError
¶
Bases: AssertionError
flowchart TD
liblaf.grapes.errors.UnreachableError[UnreachableError]
click liblaf.grapes.errors.UnreachableError href "" "liblaf.grapes.errors.UnreachableError"
Parameters:
Methods:
-
__str__–
Attributes:
todo
¶
fieldz
¶
functools
¶
Classes:
Functions:
-
memorize– -
wraps– -
wrapt_getattr– -
wrapt_setattr–
MemorizedFunc
¶
memorize
¶
memorize[**P, T](
func: Callable[P, T],
/,
*,
memory: Memory | None = ...,
ignore: list[str] | None = ...,
verbose: int | None = ...,
mmap_mode: Literal["r+", "r", "w+", "c"] | None = ...,
cache_validation_callback: Callable[[Metadata], bool]
| None = ...,
bytes_limit: int | str | None = ...,
items_limit: int | None = ...,
age_limit: timedelta | None = ...,
) -> MemorizedFunc[P, T]
memorize[**P, T](
*,
memory: Memory | None = None,
ignore: list[str] | None = ...,
verbose: int | None = ...,
mmap_mode: Literal["r+", "r", "w+", "c"] | None = ...,
cache_validation_callback: Callable[[Metadata], bool]
| None = ...,
bytes_limit: int | str | None = ...,
items_limit: int | None = ...,
age_limit: timedelta | None = ...,
) -> Callable[[Callable[P, T]], MemorizedFunc[P, T]]
Source code in src/liblaf/grapes/functools/_memorize.py
wraps
¶
wrapt_getattr
¶
Source code in src/liblaf/grapes/functools/_wrapt.py
icecream
¶
Classes:
Functions:
-
install–
Attributes:
IceCreamDebugger
¶
Parameters:
Methods:
-
__call__–
Attributes:
__call__
¶
__call__[T1, T2, *Ts](
arg1: T1, arg2: T2, *args: *Ts, **kwargs
) -> tuple[T1, T2, *Ts]
Source code in src/liblaf/grapes/icecream/_icecream.py
itertools
¶
Functions:
-
areidentical–Determine if sequences are identical element-wise. This lazily evaluates the sequences and stops as soon as the result is determined.
-
as_iterable–.
-
as_sequence–.
-
compact–Filter an iterable on "truthy" values.
-
first_not_none–Returns the first
not Nonevalue in theargs. -
keyjoin–Inner join two sequences of dictionaries on specified keys, merging matches with right value precedence.
-
len_or_none– -
omit–Return a subset of the provided dictionary with keys not contained in the denylist.
-
pick–Return a subset of the provided dictionary with keys contained in the allowlist.
areidentical
¶
Determine if sequences are identical element-wise. This lazily evaluates the sequences and stops as soon as the result is determined.
Examples:
Source code in src/liblaf/grapes/itertools/_toolz.py
as_iterable
¶
.
Examples:
If obj is iterable, return an iterator over its items:
If obj is not iterable, return a one-item iterable containing obj:
If obj is None, return an empty iterable:
By default, binary and text strings are not considered iterable:
If base_type is set, objects for which isinstance(obj, base_type) returns True won't be considered iterable.
>>> obj = {"a": 1}
>>> as_iterable(obj)
{'a': 1}
>>> as_iterable(obj, base_type=dict) # Treat dicts as a unit
({'a': 1},)
Set base_type to None to avoid any special handling and treat objects Python considers iterable as iterable:
References
Source code in src/liblaf/grapes/itertools/_as_iterable.py
as_sequence
¶
.
Examples:
If obj is iterable, return an iterator over its items:
If obj is not iterable, return a one-item iterable containing obj:
If obj is None, return an empty iterable:
By default, binary and text strings are not considered iterable:
If base_type is set, objects for which isinstance(obj, base_type) returns True won't be considered iterable.
>>> obj = {"a": 1}
>>> as_sequence(obj)
({'a': 1},)
>>> as_sequence(obj, base_type=dict) # Treat dicts as a unit
({'a': 1},)
Set base_type to None to avoid any special handling and treat objects Python considers iterable as iterable:
References
Source code in src/liblaf/grapes/itertools/_as_sequence.py
compact
¶
Filter an iterable on "truthy" values.
Examples:
Source code in src/liblaf/grapes/itertools/_toolz.py
first_not_none
¶
Returns the first not None value in the args.
Examples:
References
Source code in src/liblaf/grapes/itertools/_first_not_none.py
keyjoin
¶
keyjoin[KT, VT](
leftkey: KT,
leftseq: Iterable[Mapping[KT, VT]],
rightkey: KT,
rightseq: Iterable[Mapping[KT, VT]],
) -> Iterator[Mapping[KT, VT]]
Inner join two sequences of dictionaries on specified keys, merging matches with right value precedence.
Examples:
>>> people = [
... {"id": 0, "name": "Anonymous Guy", "location": "Unknown"},
... {"id": 1, "name": "Karan", "location": "San Francisco"},
... {"id": 2, "name": "Matthew", "location": "Oakland"},
... ]
>>> hobbies = [
... {"person_id": 1, "hobby": "Tennis"},
... {"person_id": 1, "hobby": "Acting"},
... {"person_id": 2, "hobby": "Biking"},
... ]
>>> list(keyjoin("id", people, "person_id", hobbies))
[{'id': 1, 'name': 'Karan', 'location': 'San Francisco', 'person_id': 1, 'hobby': 'Tennis'}, {'id': 1, 'name': 'Karan', 'location': 'San Francisco', 'person_id': 1, 'hobby': 'Acting'}, {'id': 2, 'name': 'Matthew', 'location': 'Oakland', 'person_id': 2, 'hobby': 'Biking'}]
Source code in src/liblaf/grapes/itertools/_toolz.py
len_or_none
¶
omit
¶
Return a subset of the provided dictionary with keys not contained in the denylist.
Examples:
Source code in src/liblaf/grapes/itertools/_toolz.py
pick
¶
Return a subset of the provided dictionary with keys contained in the allowlist.
Examples:
Source code in src/liblaf/grapes/itertools/_toolz.py
logging
¶
Modules:
Classes:
-
CleanLogger– -
LazyRepr– -
LazyStr– -
LimitsFilter– -
LimitsHitArgs– -
LoggerTree– -
RichFileHandler–
Functions:
-
init–.
-
init_levels– -
install_excepthook– -
install_unraisablehook– -
remove_non_root_stream_handlers– -
set_default_logger_level_by_release_type–
Attributes:
CleanLogger
¶
Bases: Logger
flowchart TD
liblaf.grapes.logging.CleanLogger[CleanLogger]
click liblaf.grapes.logging.CleanLogger href "" "liblaf.grapes.logging.CleanLogger"
Methods:
Attributes:
Source code in src/liblaf/grapes/logging/helpers/_logger.py
LazyRepr
¶
LimitsFilter
¶
Parameters:
-
(limiter¶RateLimiter, default:<limits.strategies.FixedWindowRateLimiter object at 0x7f8a2e5730e0>) –
Methods:
-
filter–
Attributes:
-
limiter(RateLimiter) –
limiter
class-attribute
instance-attribute
¶
filter
¶
Source code in src/liblaf/grapes/logging/filters/_limits.py
LimitsHitArgs
¶
Parameters:
-
(item¶RateLimitItem | None) – -
(namespace¶Iterable[str] | None, default:None) – -
(identifiers¶Iterable[str], default:()) – -
(cost¶int, default:1) –
Methods:
Attributes:
LoggerTree
¶
flowchart TD
liblaf.grapes.logging.LoggerTree[LoggerTree]
click liblaf.grapes.logging.LoggerTree href "" "liblaf.grapes.logging.LoggerTree"
Methods:
-
__rich__– -
add_logger–
Source code in src/liblaf/grapes/logging/helpers/_tree.py
RichFileHandler
¶
RichFileHandler(
filename: StrPath,
mode: str = "w",
*,
encoding: str | None = None,
errors: str | None = None,
columns: Iterable[RichHandlerColumn] | None = None,
level: int = NOTSET,
)
Bases: RichHandler
flowchart TD
liblaf.grapes.logging.RichFileHandler[RichFileHandler]
liblaf.grapes.rich.logging.handlers._handler.RichHandler[RichHandler]
liblaf.grapes.rich.logging.handlers._handler.RichHandler --> liblaf.grapes.logging.RichFileHandler
click liblaf.grapes.logging.RichFileHandler href "" "liblaf.grapes.logging.RichFileHandler"
click liblaf.grapes.rich.logging.handlers._handler.RichHandler href "" "liblaf.grapes.rich.logging.handlers._handler.RichHandler"
Methods:
Attributes:
-
columns(list[RichHandlerColumn]) – -
console(Console) – -
highlighter(Highlighter) –
Source code in src/liblaf/grapes/logging/handlers/_file.py
init
¶
init(
*,
file: StrPath | None = None,
force: bool = False,
time_relative: bool | None = None,
) -> None
.
Examples:
Source code in src/liblaf/grapes/logging/_init.py
init_levels
¶
install_excepthook
¶
Source code in src/liblaf/grapes/logging/helpers/_excepthook.py
install_unraisablehook
¶
Source code in src/liblaf/grapes/logging/helpers/_unraisablehook.py
remove_non_root_stream_handlers
¶
Source code in src/liblaf/grapes/logging/helpers/_remove_handlers.py
set_default_logger_level_by_release_type
¶
set_default_logger_level_by_release_type(
dev_level: int | str | None = None,
pre_level: int | str | None = None,
) -> None
Source code in src/liblaf/grapes/logging/helpers/_logger.py
filters
¶
Classes:
LimitsFilter
¶
Parameters:
-
(limiter¶RateLimiter, default:<limits.strategies.FixedWindowRateLimiter object at 0x7f8a2e5730e0>) –
Methods:
-
filter–
Attributes:
-
limiter(RateLimiter) –
limiter
class-attribute
instance-attribute
¶
filter
¶
Source code in src/liblaf/grapes/logging/filters/_limits.py
LimitsHitArgs
¶
Parameters:
-
(item¶RateLimitItem | None) – -
(namespace¶Iterable[str] | None, default:None) – -
(identifiers¶Iterable[str], default:()) – -
(cost¶int, default:1) –
Methods:
Attributes:
handlers
¶
Classes:
RichFileHandler
¶
RichFileHandler(
filename: StrPath,
mode: str = "w",
*,
encoding: str | None = None,
errors: str | None = None,
columns: Iterable[RichHandlerColumn] | None = None,
level: int = NOTSET,
)
Bases: RichHandler
flowchart TD
liblaf.grapes.logging.handlers.RichFileHandler[RichFileHandler]
liblaf.grapes.rich.logging.handlers._handler.RichHandler[RichHandler]
liblaf.grapes.rich.logging.handlers._handler.RichHandler --> liblaf.grapes.logging.handlers.RichFileHandler
click liblaf.grapes.logging.handlers.RichFileHandler href "" "liblaf.grapes.logging.handlers.RichFileHandler"
click liblaf.grapes.rich.logging.handlers._handler.RichHandler href "" "liblaf.grapes.rich.logging.handlers._handler.RichHandler"
Methods:
Attributes:
-
columns(list[RichHandlerColumn]) – -
console(Console) – -
highlighter(Highlighter) –
Source code in src/liblaf/grapes/logging/handlers/_file.py
helpers
¶
Classes:
-
CleanLogger– -
LazyRepr– -
LazyStr– -
LoggerTree–
Functions:
-
init_levels– -
install_excepthook– -
install_unraisablehook– -
remove_non_root_stream_handlers– -
set_default_logger_level_by_release_type–
Attributes:
CleanLogger
¶
Bases: Logger
flowchart TD
liblaf.grapes.logging.helpers.CleanLogger[CleanLogger]
click liblaf.grapes.logging.helpers.CleanLogger href "" "liblaf.grapes.logging.helpers.CleanLogger"
Methods:
Attributes:
Source code in src/liblaf/grapes/logging/helpers/_logger.py
LazyRepr
¶
LoggerTree
¶
flowchart TD
liblaf.grapes.logging.helpers.LoggerTree[LoggerTree]
click liblaf.grapes.logging.helpers.LoggerTree href "" "liblaf.grapes.logging.helpers.LoggerTree"
Methods:
-
__rich__– -
add_logger–
Source code in src/liblaf/grapes/logging/helpers/_tree.py
init_levels
¶
install_excepthook
¶
Source code in src/liblaf/grapes/logging/helpers/_excepthook.py
install_unraisablehook
¶
Source code in src/liblaf/grapes/logging/helpers/_unraisablehook.py
remove_non_root_stream_handlers
¶
Source code in src/liblaf/grapes/logging/helpers/_remove_handlers.py
magic
¶
Functions:
-
abbr_path– -
entrypoint– -
get_frame– -
get_frame_with_stacklevel– -
hidden_from_logging– -
hidden_from_traceback– -
hidden_from_warnings– -
in_ci– -
is_dev_release– -
is_pre_release–
abbr_path
¶
get_frame
¶
Source code in src/liblaf/grapes/magic/_frame.py
get_frame_with_stacklevel
¶
get_frame_with_stacklevel(
depth: int = 1,
hidden: Callable[[FrameType], bool] | None = None,
) -> tuple[FrameType | None, int]
Source code in src/liblaf/grapes/magic/_frame.py
hidden_from_logging
¶
Source code in src/liblaf/grapes/magic/_frame.py
hidden_from_traceback
¶
hidden_from_traceback(
frame: FrameType | None,
*,
hide_stable_release: bool | None = None,
) -> bool
Source code in src/liblaf/grapes/magic/_frame.py
hidden_from_warnings
¶
hidden_from_warnings(
frame: FrameType | None,
*,
hide_stable_release: bool | None = None,
) -> bool
Source code in src/liblaf/grapes/magic/_frame.py
is_dev_release
¶
is_pre_release
¶
pretty
¶
Classes:
-
PrettyQuantitiesComponents–PrettyQuantitiesComponents(mantissas, spacer, units)
-
PrettyQuantityComponents–PrettyQuantityComponents(whole, frac, units)
Functions:
-
get_name– -
has_ansi–.
-
pretty_call–.
-
pretty_duration–.
-
pretty_durations–.
-
pretty_func– -
pretty_quantities–.
-
pretty_quantity–.
-
pretty_quantity_components– -
pretty_throughput–.
PrettyQuantitiesComponents
¶
Bases: NamedTuple
flowchart TD
liblaf.grapes.pretty.PrettyQuantitiesComponents[PrettyQuantitiesComponents]
click liblaf.grapes.pretty.PrettyQuantitiesComponents href "" "liblaf.grapes.pretty.PrettyQuantitiesComponents"
PrettyQuantitiesComponents(mantissas, spacer, units)
Parameters:
-
(mantissas¶list[str], default:None) – -
(spacer¶str, default:None) – -
(units¶str, default:None) –
Attributes:
PrettyQuantityComponents
¶
Bases: NamedTuple
flowchart TD
liblaf.grapes.pretty.PrettyQuantityComponents[PrettyQuantityComponents]
click liblaf.grapes.pretty.PrettyQuantityComponents href "" "liblaf.grapes.pretty.PrettyQuantityComponents"
PrettyQuantityComponents(whole, frac, units)
Parameters:
Attributes:
get_name
¶
has_ansi
¶
.
Examples:
pretty_call
¶
pretty_call(
func: Callable,
args: Sequence[Any] = (),
kwargs: Mapping[str, Any] = {},
**wl_kwargs,
) -> str
.
Examples:
>>> def foo(a: int, b: int, c: int = 3): ...
>>> print(pretty_call(foo, (1, 2), {"c": 4}))
foo(1, 2, 4)
Source code in src/liblaf/grapes/pretty/_call.py
pretty_duration
¶
.
Examples:
Source code in src/liblaf/grapes/pretty/_duration.py
pretty_durations
¶
pretty_durations(
seconds: Iterable[float], *, prec: int = 2, **kwargs
) -> PrettyQuantitiesComponents
.
Examples:
>>> pretty_durations([0.1234, 0.01234, 0.001234])
PrettyQuantitiesComponents(mantissas=['123.', '12.', '1.'], spacer=' ', units='ms')
Source code in src/liblaf/grapes/pretty/_duration.py
pretty_func
¶
pretty_quantities
¶
pretty_quantities(
values: Iterable[float],
unit: str | None = None,
*,
prec: int = 2,
**kwargs,
) -> PrettyQuantitiesComponents
.
Examples:
>>> pretty_quantities([0.1234, 0.01234, 0.001234], "s")
PrettyQuantitiesComponents(mantissas=['123.', '12.', '1.'], spacer=' ', units='ms')
Source code in src/liblaf/grapes/pretty/_quantiphy.py
pretty_quantity
¶
.
Examples:
Source code in src/liblaf/grapes/pretty/_quantiphy.py
pretty_quantity_components
¶
pretty_quantity_components(
value: float,
unit: str | None = None,
*,
prec: int = 2,
**kwargs,
) -> PrettyQuantityComponents
Source code in src/liblaf/grapes/pretty/_quantiphy.py
pretty_throughput
¶
.
Examples:
Source code in src/liblaf/grapes/pretty/_throughput.py
rich
¶
Modules:
Functions:
get_console
cached
¶
Source code in src/liblaf/grapes/rich/_get_console.py
logging
¶
Modules:
-
handlers–
Classes:
RichHandler
¶
RichHandler(
console: Console | None = None,
*,
columns: Iterable[RichHandlerColumn] | None = None,
level: int = NOTSET,
time_relative: bool | None = None,
)
Bases: Handler
flowchart TD
liblaf.grapes.rich.logging.RichHandler[RichHandler]
click liblaf.grapes.rich.logging.RichHandler href "" "liblaf.grapes.rich.logging.RichHandler"
Methods:
-
emit–
Attributes:
-
columns(list[RichHandlerColumn]) – -
console(Console) – -
highlighter(Highlighter) –
Source code in src/liblaf/grapes/rich/logging/handlers/_handler.py
handlers
¶
Modules:
-
columns–
Classes:
-
RichHandler– -
RichHandlerColumn– -
RichHandlerColumnLevel– -
RichHandlerColumnLocation– -
RichHandlerColumnTime–
RichHandler
¶
RichHandler(
console: Console | None = None,
*,
columns: Iterable[RichHandlerColumn] | None = None,
level: int = NOTSET,
time_relative: bool | None = None,
)
Bases: Handler
flowchart TD
liblaf.grapes.rich.logging.handlers.RichHandler[RichHandler]
click liblaf.grapes.rich.logging.handlers.RichHandler href "" "liblaf.grapes.rich.logging.handlers.RichHandler"
Methods:
-
emit–
Attributes:
-
columns(list[RichHandlerColumn]) – -
console(Console) – -
highlighter(Highlighter) –
Source code in src/liblaf/grapes/rich/logging/handlers/_handler.py
RichHandlerColumn
¶
RichHandlerColumnLevel
¶
Bases: RichHandlerColumn
flowchart TD
liblaf.grapes.rich.logging.handlers.RichHandlerColumnLevel[RichHandlerColumnLevel]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn[RichHandlerColumn]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn --> liblaf.grapes.rich.logging.handlers.RichHandlerColumnLevel
click liblaf.grapes.rich.logging.handlers.RichHandlerColumnLevel href "" "liblaf.grapes.rich.logging.handlers.RichHandlerColumnLevel"
click liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn href "" "liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn"
Parameters:
Methods:
-
render–
Attributes:
RichHandlerColumnLocation
¶
Bases: RichHandlerColumn
flowchart TD
liblaf.grapes.rich.logging.handlers.RichHandlerColumnLocation[RichHandlerColumnLocation]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn[RichHandlerColumn]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn --> liblaf.grapes.rich.logging.handlers.RichHandlerColumnLocation
click liblaf.grapes.rich.logging.handlers.RichHandlerColumnLocation href "" "liblaf.grapes.rich.logging.handlers.RichHandlerColumnLocation"
click liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn href "" "liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn"
Methods:
-
render–
RichHandlerColumnTime
¶
Bases: RichHandlerColumn
flowchart TD
liblaf.grapes.rich.logging.handlers.RichHandlerColumnTime[RichHandlerColumnTime]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn[RichHandlerColumn]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn --> liblaf.grapes.rich.logging.handlers.RichHandlerColumnTime
click liblaf.grapes.rich.logging.handlers.RichHandlerColumnTime href "" "liblaf.grapes.rich.logging.handlers.RichHandlerColumnTime"
click liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn href "" "liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn"
Parameters:
Methods:
-
render–
Attributes:
columns
¶
Classes:
RichHandlerColumn
¶
RichHandlerColumnLevel
¶
Bases: RichHandlerColumn
flowchart TD
liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnLevel[RichHandlerColumnLevel]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn[RichHandlerColumn]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn --> liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnLevel
click liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnLevel href "" "liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnLevel"
click liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn href "" "liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn"
Parameters:
Methods:
-
render–
Attributes:
RichHandlerColumnLocation
¶
Bases: RichHandlerColumn
flowchart TD
liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnLocation[RichHandlerColumnLocation]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn[RichHandlerColumn]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn --> liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnLocation
click liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnLocation href "" "liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnLocation"
click liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn href "" "liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn"
Methods:
-
render–
RichHandlerColumnTime
¶
Bases: RichHandlerColumn
flowchart TD
liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnTime[RichHandlerColumnTime]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn[RichHandlerColumn]
liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn --> liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnTime
click liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnTime href "" "liblaf.grapes.rich.logging.handlers.columns.RichHandlerColumnTime"
click liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn href "" "liblaf.grapes.rich.logging.handlers.columns._abc.RichHandlerColumn"
Parameters:
Methods:
-
render–
Attributes:
progress
¶
Classes:
-
Progress– -
RateColumn–
Functions:
-
track–
Progress
¶
Progress(
*columns: str | ProgressColumn,
limit: str | RateLimitItem | None = None,
limiter: RateLimiter | None = None,
logger: Logger | None = None,
speed_estimate_period: float = 30.0,
get_time: GetTimeCallable | None = None,
disable: bool = False,
expand: bool = False,
)
Bases: Progress
flowchart TD
liblaf.grapes.rich.progress.Progress[Progress]
click liblaf.grapes.rich.progress.Progress href "" "liblaf.grapes.rich.progress.Progress"
Methods:
Attributes:
Source code in src/liblaf/grapes/rich/progress/_progress.py
get_default_columns
classmethod
¶
Source code in src/liblaf/grapes/rich/progress/_progress.py
reset
¶
reset(
task_id: TaskID,
*,
start: bool = True,
total: float | None = None,
completed: int = 0,
visible: bool | None = None,
description: str | None = None,
**fields: Any,
) -> None
Source code in src/liblaf/grapes/rich/progress/_progress.py
start
¶
stop
¶
update
¶
update(
task_id: TaskID,
*,
total: float | None = None,
completed: float | None = None,
advance: float | None = None,
description: str | None = None,
visible: bool | None = None,
refresh: bool = False,
**fields: Any,
) -> None
Source code in src/liblaf/grapes/rich/progress/_progress.py
RateColumn
¶
RateColumn(
unit: str = "it", table_column: Column | None = None
)
Bases: ProgressColumn
flowchart TD
liblaf.grapes.rich.progress.RateColumn[RateColumn]
click liblaf.grapes.rich.progress.RateColumn href "" "liblaf.grapes.rich.progress.RateColumn"
Methods:
-
render–
Attributes:
Source code in src/liblaf/grapes/rich/progress/_rate_column.py
render
¶
Source code in src/liblaf/grapes/rich/progress/_rate_column.py
track
¶
track[T](
sequence: Iterable[T],
total: float | None = None,
completed: int = 0,
description: str = "Working...",
*,
progress: Progress | None = None,
) -> Iterable[T]
Source code in src/liblaf/grapes/rich/progress/_track.py
repr
¶
Functions:
auto_rich_repr
¶
Source code in src/liblaf/grapes/rich/repr/_auto.py
rich_repr_fieldz
¶
rich_repr_fieldz(obj: object) -> RichReprResult
Source code in src/liblaf/grapes/rich/repr/_fieldz.py
traceback
¶
Classes:
Functions:
-
install–
RichExceptionSummary
¶
Parameters:
-
(exc_type¶type[BaseException]) – -
(exc_value¶BaseException) – -
(traceback¶traceback | None) –
Attributes:
-
highlighter(Highlighter) –Highlights the text typically produced from
__repr__methods.
Methods:
highlighter
class-attribute
instance-attribute
¶
__attrs_post_init__
¶
__rich_console__
¶
render
¶
render(
options: RichTracebackOptions | None = None,
) -> Generator[RenderableType]
Source code in src/liblaf/grapes/rich/traceback/_exception.py
RichFrameSummary
¶
Parameters:
Methods:
Attributes:
-
end_column(int | None) – -
end_line(int | None) – -
filename(str) – -
frame(FrameType) – -
hidden(bool) – -
lasti(int) – -
lineno(int) – -
locals(dict[str, Any]) – -
name(str) – -
position(tuple[int | None, int | None, int | None, int | None]) – -
qualname(str) – -
start_column(int | None) – -
start_line(int | None) –
__rich_console__
¶
render
¶
render(
options: RichTracebackOptions | None = None,
) -> Generator[RenderableType]
Source code in src/liblaf/grapes/rich/traceback/_frame.py
RichStackSummary
¶
Parameters:
Methods:
Attributes:
-
frames(list[RichFrameSummary]) – -
traceback(TracebackType | None) –
__rich_console__
¶
render
¶
render(
options: RichTracebackOptions | None = None,
) -> Generator[RenderableType]
Source code in src/liblaf/grapes/rich/traceback/_stack.py
install
¶
Source code in src/liblaf/grapes/rich/traceback/_install.py
sentinel
¶
serde
¶
This module provides functions for serialization and deserialization of various data formats, including JSON, TOML, YAML, and Pydantic models. It also includes registries for mapping file extensions to their respective serialization and deserialization functions.
Type Aliases:
Classes:
Functions:
Attributes:
PydanticDumpOptions
typed-dict
¶
PydanticDumpOptions(
*,
mode: Literal["json", "python"] = ...,
include: IncEx | None = ...,
exclude: IncEx | None = ...,
context: Any | None = ...,
by_alias: bool | None = ...,
exclude_unset: bool = ...,
exclude_defaults: bool = ...,
exclude_none: bool = ...,
round_trip: bool = ...,
warnings: bool | Literal["none", "warn", "error"] = ...,
fallback: Callable[[Any], Any] | None = ...,
serialize_as_any: bool = ...,
)
Bases: TypedDict
flowchart TD
liblaf.grapes.serde.PydanticDumpOptions[PydanticDumpOptions]
click liblaf.grapes.serde.PydanticDumpOptions href "" "liblaf.grapes.serde.PydanticDumpOptions"
Parameters:
-
(mode¶ForwardRef) – -
(include¶ForwardRef) – -
(exclude¶ForwardRef) – -
(context¶ForwardRef) – -
(by_alias¶ForwardRef) – -
(exclude_unset¶ForwardRef) – -
(exclude_defaults¶ForwardRef) – -
(exclude_none¶ForwardRef) – -
(round_trip¶ForwardRef) – -
(warnings¶ForwardRef) – -
(fallback¶ForwardRef) – -
(serialize_as_any¶ForwardRef) –
Parameters:
-
(mode¶Literal['json', 'python'], default:...) – -
(include¶IncEx | None, default:...) – -
(exclude¶IncEx | None, default:...) – -
(context¶Any | None, default:...) – -
(by_alias¶bool | None, default:...) – -
(exclude_unset¶bool, default:...) – -
(exclude_defaults¶bool, default:...) – -
(exclude_none¶bool, default:...) – -
(round_trip¶bool, default:...) – -
(warnings¶bool | Literal['none', 'warn', 'error'], default:...) – -
(fallback¶Callable[[Any], Any] | None, default:...) – -
(serialize_as_any¶bool, default:...) –
PydanticValidateOptions
typed-dict
¶
PydanticValidateOptions(
*,
strict: bool | None = ...,
from_attributes: bool | None = ...,
context: Any | None = ...,
by_alias: bool | None = ...,
by_name: bool | None = ...,
)
Bases: TypedDict
flowchart TD
liblaf.grapes.serde.PydanticValidateOptions[PydanticValidateOptions]
click liblaf.grapes.serde.PydanticValidateOptions href "" "liblaf.grapes.serde.PydanticValidateOptions"
Parameters:
-
(strict¶bool | None) –Whether to enforce types strictly.
-
(from_attributes¶bool | None) –Whether to extract data from object attributes.
-
(context¶Any | None) –Additional context to pass to the validator.
-
(by_alias¶bool | None) –Whether to use the field's alias when validating against the provided input data.
-
(by_name¶bool | None) –Whether to use the field's name when validating against the provided input data.
Parameters:
-
(strict¶bool | None, default:...) –Whether to enforce types strictly.
-
(from_attributes¶bool | None, default:...) –Whether to extract data from object attributes.
-
(context¶Any | None, default:...) –Additional context to pass to the validator.
-
(by_alias¶bool | None, default:...) –Whether to use the field's alias when validating against the provided input data.
-
(by_name¶bool | None, default:...) –Whether to use the field's name when validating against the provided input data.
Serde
¶
Parameters:
Methods:
Attributes:
decode
¶
decode(
buf: Buffer | str,
/,
*,
dec_hook: DecHook | None = ...,
pydantic: PydanticValidateOptions | None = None,
strict: bool = True,
) -> Any
encode
¶
encode(
obj: Any,
/,
*,
enc_hook: EncHook | None = ...,
order: Literal["deterministic", "sorted"] | None = None,
pydantic: PydanticDumpOptions | None = None,
) -> bytes
load
¶
load(
path: StrPath,
/,
*,
dec_hook: DecHook | None = ...,
pydantic: PydanticValidateOptions | None = None,
strict: bool = True,
) -> Any
load[T](
path: StrPath,
/,
*,
dec_hook: DecHook | None = ...,
pydantic: PydanticValidateOptions | None = None,
strict: bool = True,
type: type[T],
) -> T
load[T](
path: StrPath,
/,
*,
dec_hook: DecHook | None = ...,
pydantic: PydanticValidateOptions | None = None,
strict: bool = True,
type: Any,
) -> Any
save
¶
save(
path: StrPath,
obj: Any,
/,
*,
enc_hook: EncHook | None = ...,
order: Literal["deterministic", "sorted"] | None = None,
pydantic: PydanticDumpOptions | None = None,
) -> None
dec_hook
¶
dec_hook(
typ: type,
obj: Any,
/,
*,
pydantic_options: PydanticValidateOptions | None = None,
) -> Any
Source code in src/liblaf/grapes/serde/_decode.py
enc_hook
¶
load
¶
load(
path: StrPath,
/,
*,
dec_hook: DecHook | None = ...,
force_ext: str | None = None,
pydantic: PydanticValidateOptions | None = None,
strict: bool = True,
) -> Any
load[T](
path: StrPath,
/,
*,
dec_hook: DecHook | None = ...,
force_ext: str | None = None,
pydantic: PydanticValidateOptions | None = None,
strict: bool = True,
type: type[T],
) -> T
timing
¶
Modules:
Type Aliases:
Classes:
Functions:
-
clock– -
get_timer– -
log_record– -
log_summary– -
timer–
Attributes:
ClockName
¶
ClockName = Literal[
"monotonic",
"perf",
"process",
"thread",
"time",
"children-system",
"children-user",
"elapsed",
"system",
"user",
]
BaseTimer
¶
Bases: Timings
flowchart TD
liblaf.grapes.timing.BaseTimer[BaseTimer]
liblaf.grapes.timing._timings.Timings[Timings]
liblaf.grapes.timing._timings.Timings --> liblaf.grapes.timing.BaseTimer
click liblaf.grapes.timing.BaseTimer href "" "liblaf.grapes.timing.BaseTimer"
click liblaf.grapes.timing._timings.Timings href "" "liblaf.grapes.timing._timings.Timings"
Parameters:
-
(label¶str | None, default:None) – -
(name¶str | None, default:None) – -
(clocks¶Sequence[ClockName], default:('perf',)) – -
(cb_start¶Callback | None, default:None) – -
(cb_stop¶Callback | None, default:<function log_record at 0x7f8a6ee77320>) – -
(cb_finish¶Callback | None, default:<function log_summary at 0x7f8a6ee77740>) –
Attributes:
Methods:
-
__attrs_post_init__– -
__bool__– -
__len__– -
clear– -
elapsed– -
finish– -
log_record– -
log_summary– -
pretty_record– -
pretty_summary– -
start– -
stop–
clocks
class-attribute
instance-attribute
¶
clocks: Sequence[ClockName] = field(default=DEFAULT_CLOCKS)
timings
class-attribute
instance-attribute
¶
__attrs_post_init__
¶
Source code in src/liblaf/grapes/timing/_timings.py
clear
¶
elapsed
¶
Source code in src/liblaf/grapes/timing/_timings.py
finish
¶
log_record
¶
log_record(
*,
index: int = -1,
level: int = LOG_RECORD_DEFAULT_LEVEL,
limits: str | RateLimitItem | None = "1/second",
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
log_summary
¶
log_summary(
*,
level: int = LOG_SUMMARY_DEFAULT_LEVEL,
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
limits: str | RateLimitItem | None = None,
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
pretty_record
¶
Source code in src/liblaf/grapes/timing/_timings.py
pretty_summary
¶
pretty_summary(
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
*,
rich_markup: bool = False,
) -> str
Source code in src/liblaf/grapes/timing/_timings.py
start
¶
stop
¶
Source code in src/liblaf/grapes/timing/_base.py
Timer
¶
Bases: BaseTimer, AbstractContextManager
flowchart TD
liblaf.grapes.timing.Timer[Timer]
liblaf.grapes.timing._base.BaseTimer[BaseTimer]
liblaf.grapes.timing._timings.Timings[Timings]
liblaf.grapes.timing._base.BaseTimer --> liblaf.grapes.timing.Timer
liblaf.grapes.timing._timings.Timings --> liblaf.grapes.timing._base.BaseTimer
click liblaf.grapes.timing.Timer href "" "liblaf.grapes.timing.Timer"
click liblaf.grapes.timing._base.BaseTimer href "" "liblaf.grapes.timing._base.BaseTimer"
click liblaf.grapes.timing._timings.Timings href "" "liblaf.grapes.timing._timings.Timings"
Parameters:
-
(label¶str | None, default:None) – -
(name¶str | None, default:None) – -
(clocks¶Sequence[ClockName], default:('perf',)) – -
(cb_start¶Callback | None, default:None) – -
(cb_stop¶Callback | None, default:<function log_record at 0x7f8a6ee77320>) – -
(cb_finish¶Callback | None, default:<function log_summary at 0x7f8a6ee77740>) –
Attributes:
Methods:
-
__attrs_post_init__– -
__bool__– -
__call__– -
__enter__– -
__exit__– -
__len__– -
clear– -
elapsed– -
finish– -
log_record– -
log_summary– -
pretty_record– -
pretty_summary– -
start– -
stop–
clocks
class-attribute
instance-attribute
¶
clocks: Sequence[ClockName] = field(default=DEFAULT_CLOCKS)
timings
class-attribute
instance-attribute
¶
__attrs_post_init__
¶
Source code in src/liblaf/grapes/timing/_timings.py
__call__
¶
__exit__
¶
__exit__(
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
traceback: TracebackType | None,
) -> None
Source code in src/liblaf/grapes/timing/_timer.py
clear
¶
elapsed
¶
Source code in src/liblaf/grapes/timing/_timings.py
finish
¶
log_record
¶
log_record(
*,
index: int = -1,
level: int = LOG_RECORD_DEFAULT_LEVEL,
limits: str | RateLimitItem | None = "1/second",
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
log_summary
¶
log_summary(
*,
level: int = LOG_SUMMARY_DEFAULT_LEVEL,
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
limits: str | RateLimitItem | None = None,
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
pretty_record
¶
Source code in src/liblaf/grapes/timing/_timings.py
pretty_summary
¶
pretty_summary(
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
*,
rich_markup: bool = False,
) -> str
Source code in src/liblaf/grapes/timing/_timings.py
start
¶
stop
¶
Source code in src/liblaf/grapes/timing/_base.py
Timings
¶
Parameters:
-
(label¶str | None, default:None) – -
(name¶str | None, default:None) – -
(clocks¶Sequence[ClockName], default:('perf',)) –
Attributes:
Methods:
-
__attrs_post_init__– -
__len__– -
clear– -
elapsed– -
log_record– -
log_summary– -
pretty_record– -
pretty_summary–
clocks
class-attribute
instance-attribute
¶
clocks: Sequence[ClockName] = field(default=DEFAULT_CLOCKS)
timings
class-attribute
instance-attribute
¶
__attrs_post_init__
¶
Source code in src/liblaf/grapes/timing/_timings.py
clear
¶
elapsed
¶
Source code in src/liblaf/grapes/timing/_timings.py
log_record
¶
log_record(
*,
index: int = -1,
level: int = LOG_RECORD_DEFAULT_LEVEL,
limits: str | RateLimitItem | None = "1/second",
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
log_summary
¶
log_summary(
*,
level: int = LOG_SUMMARY_DEFAULT_LEVEL,
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
limits: str | RateLimitItem | None = None,
) -> None
Source code in src/liblaf/grapes/timing/_timings.py
pretty_record
¶
Source code in src/liblaf/grapes/timing/_timings.py
pretty_summary
¶
pretty_summary(
stats: Iterable[
StatisticName
] = LOG_SUMMARY_DEFAULT_STATISTICS,
*,
rich_markup: bool = False,
) -> str
Source code in src/liblaf/grapes/timing/_timings.py
clock
¶
get_timer
¶
log_record
¶
log_summary
¶
timer
¶
timer(
*,
label: str | None = ...,
clocks: Sequence[ClockName] = ...,
cb_finish: Callback | None = ...,
cb_start: Callback | None = ...,
cb_stop: Callback | None = ...,
) -> Timer
callback
¶
Functions:
log_record
¶
defaults
¶
Attributes:
-
DEFAULT_CLOCKS(Sequence[ClockName]) – -
LOG_RECORD_DEFAULT_LEVEL(int) – -
LOG_SUMMARY_DEFAULT_LEVEL(int) – -
LOG_SUMMARY_DEFAULT_STATISTICS(Iterable[StatisticName]) –
typing
¶
Functions:
array_kind
¶
Source code in src/liblaf/grapes/typing/_array.py
clone_param_spec
¶
clone_signature
¶
wadler_lindig
¶
Modules:
-
custom–
Type Aliases:
Classes:
Functions:
-
auto_pdoc– -
chain_custom– -
make_kwargs– -
pdoc– -
pdoc_array– -
pdoc_datetime– -
pdoc_enum– -
pdoc_fieldz– -
pdoc_mapping– -
pdoc_pydantic_root_model– -
pdoc_rich_repr– -
pdoc_type– -
pformat– -
pprint–Pretty-prints an object to stdout.
Attributes:
PdocCustomDispatcher
¶
Methods:
Source code in src/liblaf/grapes/wadler_lindig/custom/_dispatch.py
__call__
¶
__call__(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc | None
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_dispatch.py
WadlerLindigOptions
typed-dict
¶
WadlerLindigOptions(
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
)
Bases: TypedDict
flowchart TD
liblaf.grapes.wadler_lindig.WadlerLindigOptions[WadlerLindigOptions]
click liblaf.grapes.wadler_lindig.WadlerLindigOptions href "" "liblaf.grapes.wadler_lindig.WadlerLindigOptions"
Parameters:
-
(custom¶CustomCallable) – -
(hide_defaults¶bool) – -
(indent¶int) – -
(respect_pdoc¶bool) – -
(short_arrays¶bool) – -
(show_dataclass_module¶bool) – -
(show_type_module¶bool) – -
(width¶int) –
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
auto_pdoc
¶
Source code in src/liblaf/grapes/wadler_lindig/_auto.py
chain_custom
¶
chain_custom(
*custom: Callable[..., AbstractDoc | None] | None,
) -> Callable[[Any], AbstractDoc | None]
Source code in src/liblaf/grapes/wadler_lindig/custom/_chain.py
make_kwargs
¶
make_kwargs(
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> WadlerLindigOptions
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/_options.py
pdoc
¶
pdoc(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
pdoc_array
¶
pdoc_array(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc | None
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_array.py
pdoc_enum
¶
pdoc_enum(
obj: Enum,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
pdoc_fieldz
¶
pdoc_fieldz(
obj: object,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc | None
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_fieldz.py
pdoc_mapping
¶
pdoc_mapping(
obj: Mapping[Any, Any],
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_mapping.py
pdoc_pydantic_root_model
¶
pdoc_pydantic_root_model(
obj: RootModel,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
pdoc_rich_repr
¶
pdoc_rich_repr(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc | None
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_rich_repr.py
pdoc_type
¶
pdoc_type(
obj: type,
*,
dataclass: bool = False,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_type.py
pformat
¶
pformat(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> str
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
pprint
¶
pprint(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> None
Pretty-prints an object to stdout.
Examples:
array:
>>> import numpy as np
>>> pprint(np.zeros((2, 3)))
array([[0., 0., 0.],
[0., 0., 0.]])
>>> pprint(np.zeros((20, 30)))
f64[20,30](numpy)
datetime:
>>> import datetime
>>> pprint(datetime.datetime(1970, 1, 1, tzinfo=datetime.UTC))
1970-01-01T00:00:00+00:00
dataclass:
>>> import dataclasses
>>> import numpy as np
>>> @dataclasses.dataclass
... class MyDataclass:
... x: list[str]
... y: np.ndarray
>>> obj = MyDataclass(["lorem", "ipsum", "dolor sit amet"], np.zeros((2, 3)))
>>> pprint(obj, width=30, indent=4)
MyDataclass(
x=[
'lorem',
'ipsum',
'dolor sit amet'
],
y=array([[0., 0., 0.],
[0., 0., 0.]])
)
dict:
pydantic:
>>> import pydantic
>>> class MyModel(pydantic.RootModel[list[str]]): ...
>>> obj = MyModel(["lorem", "ipsum", "dolor sit amet"])
>>> pprint(obj)
MyModel['lorem', 'ipsum', 'dolor sit amet']
rich.repr:
>>> import rich
>>> class Bird:
... def __rich_repr__(self):
... yield "penguin"
... yield "eats", ["fish"]
... yield "fly", False, True
... yield "extinct", False, False
>>> pprint(Bird())
Bird('penguin', eats=['fish'], fly=False)
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/_pprint.py
custom
¶
Classes:
Functions:
-
chain_custom– -
pdoc_array– -
pdoc_datetime– -
pdoc_enum– -
pdoc_fieldz– -
pdoc_mapping– -
pdoc_pydantic_root_model– -
pdoc_rich_repr– -
pdoc_type–
Attributes:
PdocCustomDispatcher
¶
Methods:
Source code in src/liblaf/grapes/wadler_lindig/custom/_dispatch.py
__call__
¶
__call__(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc | None
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_dispatch.py
chain_custom
¶
chain_custom(
*custom: Callable[..., AbstractDoc | None] | None,
) -> Callable[[Any], AbstractDoc | None]
Source code in src/liblaf/grapes/wadler_lindig/custom/_chain.py
pdoc_array
¶
pdoc_array(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc | None
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_array.py
pdoc_enum
¶
pdoc_enum(
obj: Enum,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
pdoc_fieldz
¶
pdoc_fieldz(
obj: object,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc | None
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_fieldz.py
pdoc_mapping
¶
pdoc_mapping(
obj: Mapping[Any, Any],
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_mapping.py
pdoc_pydantic_root_model
¶
pdoc_pydantic_root_model(
obj: RootModel,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
pdoc_rich_repr
¶
pdoc_rich_repr(
obj: Any,
*,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc | None
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –
Source code in src/liblaf/grapes/wadler_lindig/custom/_rich_repr.py
pdoc_type
¶
pdoc_type(
obj: type,
*,
dataclass: bool = False,
custom: CustomCallable = ...,
hide_defaults: bool = ...,
indent: int = ...,
respect_pdoc: bool = ...,
short_arrays: bool = ...,
show_dataclass_module: bool = ...,
show_type_module: bool = ...,
width: int = ...,
) -> AbstractDoc
Parameters:
-
(custom¶CustomCallable, default:...) – -
(hide_defaults¶bool, default:...) – -
(indent¶int, default:...) – -
(respect_pdoc¶bool, default:...) – -
(short_arrays¶bool, default:...) – -
(show_dataclass_module¶bool, default:...) – -
(show_type_module¶bool, default:...) – -
(width¶int, default:...) –