devctrl.task.preset.TaskPreset#

class TaskPreset(task: T, task_type: type[T], name: str, key: str, last_edited: int, filename: str)[source]#

Bases: SettingsClass, Generic[T]

Methods

as_dict

Convenience wrapper for dataclasses.asdict(self)

from_dict

Recursively construct a SettingsClass from a dictionary.

load_yaml

save_yaml

Attributes

task

task_type

name

key

last_edited

Unix timestamp

filename

Filename only used to be able to delete the correct file when the preset is deleted.

__annotations__ = {'filename': <class 'str'>, 'key': <class 'str'>, 'last_edited': <class 'int'>, 'name': <class 'str'>, 'task': ~T, 'task_type': type[~T]}#
classmethod __class_getitem__()#

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ....

__dataclass_fields__ = {'filename': Field(name='filename',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'key': Field(name='key',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'last_edited': Field(name='last_edited',type=<class 'int'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'name': Field(name='name',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'task': Field(name='task',type=~T,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'task_type': Field(name='task_type',type=type[~T],default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}#
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)#
__dict__ = mappingproxy({'__module__': 'devctrl.task.preset', '__firstlineno__': 21, '__annotations__': {'task': ~T, 'task_type': type[~T], 'name': <class 'str'>, 'key': <class 'str'>, 'last_edited': <class 'int'>, 'filename': <class 'str'>}, '__static_attributes__': (), '__orig_bases__': (<class 'devctrl.utility.settings.SettingsClass'>, typing.Generic[~T]), '__doc__': 'TaskPreset(task: ~T, task_type: type[~T], name: str, key: str, last_edited: int, filename: str)', '__parameters__': (~T,), '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False), '__dataclass_fields__': {'task': Field(name='task',type=~T,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'task_type': Field(name='task_type',type=type[~T],default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'name': Field(name='name',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'key': Field(name='key',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'last_edited': Field(name='last_edited',type=<class 'int'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'filename': Field(name='filename',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function TaskPreset.__init__>, '__repr__': <function TaskPreset.__repr__>, '__eq__': <function TaskPreset.__eq__>, '__match_args__': ('task', 'task_type', 'name', 'key', 'last_edited', 'filename')})#
__eq__(other)#

Return self==value.

__firstlineno__ = 21#
__hash__ = None#
__init__(task: T, task_type: type[T], name: str, key: str, last_edited: int, filename: str) None#
classmethod __init_subclass__()#

Function to initialize subclasses.

__match_args__ = ('task', 'task_type', 'name', 'key', 'last_edited', 'filename')#
__module__ = 'devctrl.task.preset'#
__or__(other)#

Merge with another settings class or a dictionary.

__orig_bases__ = (<class 'devctrl.utility.settings.SettingsClass'>, typing.Generic[~T])#
__parameters__ = (~T,)#
__replace__(**changes)#
__repr__()#

Return repr(self).

__static_attributes__ = ()#
__weakref__#

list of weak references to the object

as_dict() dict#

Convenience wrapper for dataclasses.asdict(self)

filename: str#

Filename only used to be able to delete the correct file when the preset is deleted.

classmethod from_dict(data: dict)#

Recursively construct a SettingsClass from a dictionary.

If the value of a field is another SettingsClass, from_dict() will be called for that field as well. Handled are:

  • SettingsClass

  • list[SettingsClass]

  • dict[<any>, SettingsClass]

  • all of the above as Optional (Union with None)

  • a Union with any handled types

Raises:
  • ValueError – If data contains a value that has the wrong type for the field of cls (ONLY if the type is a subclass of SettingsClass! Other types are not enforced)

  • KeyError – If data contains a key that is not a field name of cls

key: str#
last_edited: int#

Unix timestamp

classmethod load_yaml(yaml_path: str, loader=<class 'yaml.loader.Loader'>)#
name: str#
save_yaml(yaml_path: str)#
task: T#
task_type: type[T]#