jgdv.structs.chainguard._interface

Type Aliases

ProxyWrapper

TomlTypes

Protocols

ChainGuard_i

The interface for a base ChainGuard object

ChainGuard_p

The interface for a base ChainGuard object

ChainProxy_p

The proxy interface

ProxyEntry_p

Base class for protocol classes.

Module Contents

jgdv.structs.chainguard._interface.ProxyWrapper: TypeAlias = Callable[[*Any], T]
jgdv.structs.chainguard._interface.TomlTypes: TypeAlias = str | int | float | bool | list[TomlTypes] | dict[str, TomlTypes] | datetime.datetime
class jgdv.structs.chainguard._interface.ChainGuard_i(
data=None,
*,
index=None,
mutable=False,
)[source]

Bases: ChainGuard_p, Protocol

The interface for a base ChainGuard object

Parameters:
  • data (jgdv.Maybe)

  • index (jgdv.Maybe[list[str]])

  • mutable (bool)

class jgdv.structs.chainguard._interface.ChainGuard_p(
data=None,
*,
index=None,
mutable=False,
)[source]

Bases: ProxyEntry_p, jgdv._abstract.protocols.stdlib.Mapping_p, Protocol

The interface for a base ChainGuard object

Parameters:
  • data (jgdv.Maybe)

  • index (jgdv.Maybe[list[str]])

  • mutable (bool)

_index() <Unknown>[source]
Return type:

list[str]

_table() <Unknown>[source]
Return type:

dict[str, Any]

classmethod from_dict(data) <Unknown>[source]
Parameters:

data (dict)

Return type:

Self

get(key, default=None) <Unknown>[source]
Parameters:
  • key (str)

  • default (jgdv.Maybe)

Return type:

jgdv.Maybe

classmethod load(*paths) <Unknown>[source]
Parameters:

paths (str | pathlib.Path)

Return type:

Self

classmethod load_dir(dirp) <Unknown>[source]
Parameters:

dirp (str | pathlib.Path)

Return type:

Self

classmethod read(text) <Unknown>[source]
Parameters:

text (str)

Return type:

ChainGuard_p.read.T

static report_defaulted() <Unknown>[source]
Return type:

list[str]

to_file(path) <Unknown>[source]
Parameters:

path (pathlib.Path)

Return type:

None

class jgdv.structs.chainguard._interface.ChainProxy_p[source]

Bases: Protocol

The proxy interface

Used for special access like:

cg.on_fail(...).val()
class jgdv.structs.chainguard._interface.ProxyEntry_p[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
all_of(fallback=None, types=None) <Unknown>[source]
Parameters:
  • fallback (jgdv.Maybe[ProxyEntry_p.all_of.T])

  • types (jgdv.Maybe[type[ProxyEntry_p.all_of.T]])

Return type:

ChainProxy_p[ProxyEntry_p.all_of.T]

first_of(
fallback=None,
types=None,
) <Unknown>[source]
Parameters:
  • fallback (jgdv.Maybe[ProxyEntry_p.first_of.T])

  • types (jgdv.Maybe[type[ProxyEntry_p.first_of.T]])

Return type:

ChainProxy_p[ProxyEntry_p.first_of.T]

flatten_on(fallback) <Unknown>[source]
Parameters:

fallback (jgdv.Maybe[ProxyEntry_p.flatten_on.T])

Return type:

ChainProxy_p[ProxyEntry_p.flatten_on.T]

match_on(**kwargs) <Unknown>[source]
Parameters:

kwargs (tuple[str, Any])

Return type:

ChainProxy_p

on_fail(
fallback=None,
types=None,
*,
non_root=False,
) <Unknown>[source]
Parameters:
  • fallback (jgdv.Maybe[ProxyEntry_p.on_fail.T])

  • types (jgdv.Maybe[type[ProxyEntry_p.on_fail.T]])

  • non_root (bool)

Return type:

ChainProxy_p[ProxyEntry_p.on_fail.T]