From fb88a59aa5d585007fd25fa32457cb62d02fb79d Mon Sep 17 00:00:00 2001 From: wsprague-nu Date: Wed, 8 May 2024 11:37:04 -0500 Subject: [PATCH] formatted --- doranet/__init__.py | 1 - doranet/interfaces.py | 54 +++++++++++++++--------------------------- doranet/metadata.py | 55 ++++++++++++++++--------------------------- doranet/network.py | 24 +++++++------------ doranet/strategies.py | 6 ++--- 5 files changed, 49 insertions(+), 91 deletions(-) diff --git a/doranet/__init__.py b/doranet/__init__.py index eac1825..7ccd1e4 100644 --- a/doranet/__init__.py +++ b/doranet/__init__.py @@ -1,4 +1,3 @@ """A streamlined, generic rewrite of Pickaxe.""" - from doranet.engine import create_engine # noqa:F401 diff --git a/doranet/interfaces.py b/doranet/interfaces.py index bb5f3e9..541a61c 100644 --- a/doranet/interfaces.py +++ b/doranet/interfaces.py @@ -214,8 +214,7 @@ def __init__( molecule: typing.Union[rdkit.Chem.rdchem.Mol, str], sanitize: bool = True, neutralize: bool = False, - ) -> None: - ... + ) -> None: ... @property @abc.abstractmethod @@ -450,8 +449,7 @@ def __init__( engine: "NetworkEngine", kekulize: bool = False, drop_errors: bool = False, - ) -> None: - ... + ) -> None: ... @classmethod def from_bytes( @@ -478,9 +476,9 @@ def from_bytes( pickaxe_generic.interfaces.OpDatRDKit Operator returned from processing bytestring. """ - unpacked: tuple[ - rdkit.Chem.rdChemReactions.ChemicalReaction, bool - ] = pickle.loads(data) + unpacked: tuple[rdkit.Chem.rdChemReactions.ChemicalReaction, bool] = ( + pickle.loads(data) + ) operator, kekulize = unpacked return engine.op.rdkit(operator, kekulize) @@ -1624,8 +1622,7 @@ class _max_atoms_from_num(typing.Protocol): @abc.abstractmethod def __call__( cls, max_atoms: int, proton_number: typing.Optional[int] = None - ) -> "filters.ReactionFilterMaxAtoms": - ... + ) -> "filters.ReactionFilterMaxAtoms": ... @typing.final @@ -1884,13 +1881,11 @@ def __contains__(self, item: typing.Union[Identifier, T_data]) -> bool: @abc.abstractmethod @typing.overload - def __getitem__(self, item: slice) -> collections.abc.Sequence[T_data]: - ... + def __getitem__(self, item: slice) -> collections.abc.Sequence[T_data]: ... @abc.abstractmethod @typing.overload - def __getitem__(self, item: typing.Union[T_int, Identifier]) -> T_data: - ... + def __getitem__(self, item: typing.Union[T_int, Identifier]) -> T_data: ... @abc.abstractmethod def i(self, uid: Identifier) -> T_int: @@ -1927,8 +1922,7 @@ def meta( keys: typing.Optional[ collections.abc.Iterable[collections.abc.Hashable] ] = None, - ) -> collections.abc.Mapping[typing.Hashable, typing.Any]: - ... + ) -> collections.abc.Mapping[typing.Hashable, typing.Any]: ... @abc.abstractmethod @typing.overload @@ -1940,8 +1934,7 @@ def meta( ] = None, ) -> collections.abc.Iterable[ collections.abc.Mapping[typing.Hashable, typing.Any] - ]: - ... + ]: ... @abc.abstractmethod def meta( @@ -2055,13 +2048,11 @@ class ValueQueryAssoc(typing.Protocol[T_id, T_int]): @typing.overload @abc.abstractmethod - def __getitem__(self, item: slice) -> collections.abc.Sequence[T_id]: - ... + def __getitem__(self, item: slice) -> collections.abc.Sequence[T_id]: ... @typing.overload @abc.abstractmethod - def __getitem__(self, item: T_int) -> T_id: - ... + def __getitem__(self, item: T_int) -> T_id: ... @abc.abstractmethod def i(self, item: T_id) -> T_int: @@ -2087,8 +2078,7 @@ def meta( keys: typing.Optional[ collections.abc.Iterable[collections.abc.Hashable] ] = None, - ) -> collections.abc.Mapping: - ... + ) -> collections.abc.Mapping: ... @typing.overload @abc.abstractmethod @@ -2098,8 +2088,7 @@ def meta( keys: typing.Optional[ collections.abc.Iterable[collections.abc.Hashable] ] = None, - ) -> collections.abc.Iterable[collections.abc.Mapping]: - ... + ) -> collections.abc.Iterable[collections.abc.Mapping]: ... @abc.abstractmethod def meta( @@ -2201,8 +2190,7 @@ class ChemNetwork(abc.ABC): __slots__ = () @abc.abstractmethod - def __init__(self) -> None: - ... + def __init__(self) -> None: ... @property @abc.abstractmethod @@ -2679,8 +2667,7 @@ class PriorityQueueStrategy(abc.ABC): def __init__( self, network: ChemNetwork, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def expand( @@ -2862,13 +2849,11 @@ class MetaDataCalculatorLocal(typing.Protocol): @abc.abstractmethod def __call__( self, unit: typing.Union[ReactionExplicit, RecipeExplicit] - ) -> None: - ... + ) -> None: ... @property @abc.abstractmethod - def meta_required(self) -> MetaKeyPacket: - ... + def meta_required(self) -> MetaKeyPacket: ... class MetaDataUpdate(typing.Protocol): @@ -2882,5 +2867,4 @@ def __call__( ], None, None, - ]: - ... + ]: ... diff --git a/doranet/metadata.py b/doranet/metadata.py index f8774b1..0907c47 100644 --- a/doranet/metadata.py +++ b/doranet/metadata.py @@ -15,8 +15,7 @@ class MetaSink(typing.Protocol): @property @abc.abstractmethod - def meta_required(self) -> interfaces.MetaKeyPacket: - ... + def meta_required(self) -> interfaces.MetaKeyPacket: ... _T = typing.TypeVar("_T") @@ -31,18 +30,15 @@ def TrivialMetaDataResolverFunc(a: _T, b: _T) -> _T: class LocalPropertyCalc(abc.ABC, typing.Generic[_T]): @property @abc.abstractmethod - def key(self) -> collections.abc.Hashable: - ... + def key(self) -> collections.abc.Hashable: ... @property @abc.abstractmethod - def meta_required(self) -> interfaces.MetaKeyPacket: - ... + def meta_required(self) -> interfaces.MetaKeyPacket: ... @property @abc.abstractmethod - def resolver(self) -> MetaDataResolverFunc[_T]: - ... + def resolver(self) -> MetaDataResolverFunc[_T]: ... @typing.final def __and__( @@ -121,8 +117,7 @@ def __call__( self, data: interfaces.DataPacketE[interfaces.MolDatBase], prev_value: typing.Optional[_T] = None, - ) -> typing.Optional[_T]: - ... + ) -> typing.Optional[_T]: ... class MolPropertyFromRxnCalc(LocalPropertyCalc[_T]): @@ -132,8 +127,7 @@ def __call__( data: interfaces.DataPacketE[interfaces.MolDatBase], rxn: interfaces.ReactionExplicit, prev_value: typing.Optional[_T] = None, - ) -> typing.Optional[_T]: - ... + ) -> typing.Optional[_T]: ... class OpPropertyCalc(LocalPropertyCalc[_T]): @@ -142,8 +136,7 @@ def __call__( self, data: interfaces.DataPacketE[interfaces.OpDatBase], prev_value: typing.Optional[_T] = None, - ) -> typing.Optional[_T]: - ... + ) -> typing.Optional[_T]: ... class OpPropertyFromRxnCalc(LocalPropertyCalc[_T]): @@ -153,8 +146,7 @@ def __call__( data: interfaces.DataPacketE[interfaces.OpDatBase], rxn: interfaces.ReactionExplicit, prev_value: typing.Optional[_T] = None, - ) -> typing.Optional[_T]: - ... + ) -> typing.Optional[_T]: ... class RxnPropertyCalc(LocalPropertyCalc[_T]): @@ -163,8 +155,7 @@ def __call__( self, data: interfaces.ReactionExplicit, prev_value: typing.Optional[_T] = None, - ) -> typing.Optional[_T]: - ... + ) -> typing.Optional[_T]: ... @dataclasses.dataclass(frozen=True) @@ -209,8 +200,7 @@ class ReactionFilterBase(abc.ABC): __slots__ = () @abc.abstractmethod - def __call__(self, recipe: interfaces.ReactionExplicit) -> bool: - ... + def __call__(self, recipe: interfaces.ReactionExplicit) -> bool: ... @property def meta_required(self) -> interfaces.MetaKeyPacket: @@ -303,13 +293,13 @@ def meta_required(self) -> interfaces.MetaKeyPacket: class PropertyCompositor(abc.ABC): @abc.abstractmethod - def __call__(self, rxn: interfaces.ReactionExplicit) -> "MetaPropertyState": - ... + def __call__( + self, rxn: interfaces.ReactionExplicit + ) -> "MetaPropertyState": ... @property @abc.abstractmethod - def keys(self) -> KeyOutput: - ... + def keys(self) -> KeyOutput: ... @typing.final def __and__( @@ -371,13 +361,11 @@ def __rshift__( @property @abc.abstractmethod - def meta_required(self) -> interfaces.MetaKeyPacket: - ... + def meta_required(self) -> interfaces.MetaKeyPacket: ... @property @abc.abstractmethod - def resolver(self) -> "MetaUpdateResolver": - ... + def resolver(self) -> "MetaUpdateResolver": ... class MergePropertyCompositor(PropertyCompositor): @@ -723,8 +711,7 @@ def execute( rxns: collections.abc.Iterable[ tuple[interfaces.ReactionExplicit, bool] ], - ) -> collections.abc.Iterable[tuple[interfaces.ReactionExplicit, bool]]: - ... + ) -> collections.abc.Iterable[tuple[interfaces.ReactionExplicit, bool]]: ... @typing.final def __rshift__( @@ -744,13 +731,11 @@ def __rshift__( @property @abc.abstractmethod - def meta_required(self) -> interfaces.MetaKeyPacket: - ... + def meta_required(self) -> interfaces.MetaKeyPacket: ... @property @abc.abstractmethod - def resolver(self) -> "MetaUpdateResolver": - ... + def resolver(self) -> "MetaUpdateResolver": ... @dataclasses.dataclass(frozen=True) @@ -918,7 +903,7 @@ def resolver(self) -> "MetaUpdateResolver": def _as_property_compositor( - arg: typing.Union[PropertyCompositor, LocalPropertyCalc] + arg: typing.Union[PropertyCompositor, LocalPropertyCalc], ) -> PropertyCompositor: if isinstance(arg, PropertyCompositor): return arg diff --git a/doranet/network.py b/doranet/network.py index 380ea8d..51f2783 100644 --- a/doranet/network.py +++ b/doranet/network.py @@ -55,14 +55,12 @@ def __contains__( @typing.overload def __getitem__( self, item: slice - ) -> collections.abc.Sequence[interfaces.T_data]: - ... + ) -> collections.abc.Sequence[interfaces.T_data]: ... @typing.overload def __getitem__( self, item: typing.Union[interfaces.T_int, interfaces.Identifier] - ) -> interfaces.T_data: - ... + ) -> interfaces.T_data: ... def __getitem__( self, item: typing.Union[slice, interfaces.T_int, interfaces.Identifier] @@ -86,8 +84,7 @@ def meta( keys: typing.Optional[ collections.abc.Iterable[collections.abc.Hashable] ] = None, - ) -> collections.abc.Mapping[collections.abc.Hashable, typing.Any]: - ... + ) -> collections.abc.Mapping[collections.abc.Hashable, typing.Any]: ... @typing.overload def meta( @@ -100,8 +97,7 @@ def meta( ] = None, ) -> collections.abc.Iterable[ collections.abc.Mapping[collections.abc.Hashable, typing.Any] - ]: - ... + ]: ... def meta( self, @@ -165,12 +161,10 @@ class _ValueQueryAssoc(typing.Generic[interfaces.T_id, interfaces.T_int]): @typing.overload def __getitem__( self, item: slice - ) -> collections.abc.Sequence[interfaces.T_id]: - ... + ) -> collections.abc.Sequence[interfaces.T_id]: ... @typing.overload - def __getitem__(self, item: interfaces.T_int) -> interfaces.T_id: - ... + def __getitem__(self, item: interfaces.T_int) -> interfaces.T_id: ... def __getitem__(self, item: typing.Union[slice, interfaces.T_int]): if isinstance(item, slice): @@ -187,8 +181,7 @@ def meta( keys: typing.Optional[ collections.abc.Iterable[collections.abc.Hashable] ] = None, - ) -> collections.abc.Mapping[collections.abc.Hashable, typing.Any]: - ... + ) -> collections.abc.Mapping[collections.abc.Hashable, typing.Any]: ... @typing.overload def meta( @@ -201,8 +194,7 @@ def meta( ] = None, ) -> collections.abc.Iterable[ collections.abc.Mapping[collections.abc.Hashable, typing.Any] - ]: - ... + ]: ... def meta( self, diff --git a/doranet/strategies.py b/doranet/strategies.py index a138830..f84142c 100644 --- a/doranet/strategies.py +++ b/doranet/strategies.py @@ -980,12 +980,10 @@ def popvals( ) @typing.overload - def __getitem__(self, item: slice) -> list[RecipePriorityItem]: - ... + def __getitem__(self, item: slice) -> list[RecipePriorityItem]: ... @typing.overload - def __getitem__(self, item: int) -> RecipePriorityItem: - ... + def __getitem__(self, item: int) -> RecipePriorityItem: ... def __getitem__(self, item: typing.Union[int, slice]): if self._ordered is None: