Transfer
CpDef
dataclass
¶
CpDef(src: Path, dst: Path, mv: list[str], dry_run: bool = False, escalate: bool = False, cls_defs: bool = False, func_defs: bool = False, verbose: bool = False, _copy_mode: bool = True)
Bases: MvDef
Copy function definitions from one file to another, and any necessary associated import statements along with them.
Option Description Type Default —————————— —————————————————————————————————————————— ——————————— ——————— • src source file to copy definitions from Path - • dst destination file (may not exist) Path - • mv names to copy from the source file list[str] - • dry_run whether to only preview the change diffs bool False • escalate whether to raise an error upon failure bool False • cls_defs whether to use only class definitions bool False • func_defs whether to use only function definitions bool False • verbose whether to log anything bool False
diffs ¶
Calls Agenda.populate_agenda() explicitly for the src file, and implicitly for
the dst file by Agenda.unidiff(), and returns a single diff string for dst.
Source code in src/mvdef/transfer/copy.py
LsDef
dataclass
¶
LsDef(src: Path, match: list[str] = lambda: ['*'](), dry_run: bool = False, list: bool = False, escalate: bool = False, cls_defs: bool = False, func_defs: bool = False, verbose: bool = False)
Bases: MvDefBase
List function definitions in a given file.
Option Description Type Default —————————— —————————————————————————————————————————— ——————————— ——————— • src source file to list definitions from Path - • match name regex to list from the source file list[str] ['*'] • dry_run whether to print the all diff bool False • list whether to print the list of names bool False • escalate whether to raise an error upon failure bool False • cls_defs whether to use only class definitions bool False • func_defs whether to use only function definitions bool False • verbose whether to log anything bool False
manif ¶
Calls Agenda.populate_agenda() explicitly if not yet created,
and returns a single diff string.
Source code in src/mvdef/transfer/list.py
MvDef
dataclass
¶
MvDef(src: Path, dst: Path, mv: list[str], dry_run: bool = False, escalate: bool = False, cls_defs: bool = False, func_defs: bool = False, verbose: bool = False, _copy_mode: bool = False)
Bases: MvDefBase
Move function definitions from one file to another, moving/copying any necessary associated import statements along with them.
Option Description Type Default —————————— —————————————————————————————————————————— ——————————— ——————— • src source file to take definitions from Path - • dst destination file (may not exist) Path - • mv names to move from the source file list[str] - • dry_run whether to only preview the change diffs bool False • escalate whether to raise an error upon failure bool False • cls_defs whether to use only class definitions bool False • func_defs whether to use only function definitions bool False • verbose whether to log anything bool False
diffs ¶
Calls Agenda.populate_agenda() implicitly by Agenda.unidiff() and returns 2
diff strings for src and dst respectively. If only copying (not editing src),
just populates the agenda and returns a single diff string.
Source code in src/mvdef/transfer/move.py
base ¶
MvDefBase
dataclass
¶
Bases: FailableMixIn
Common methods (allowing LsDef to have a different signature to MvDef/CpDef)
Implementation note: :attr:_check_kw and :attr:_diff_kw are stored as class
attributes (by virtue of being un-type annotated, due to how dataclasses work).
They are single-underscore prefixed to avoid name clash with the properties of the
same [but unprefixed] names.
all_defs
property
¶
If neither exclusively classdefs or exclusively funcdefs, use both.
clsvar_fetch
classmethod
¶
Fetch the sum list of the named classvar on all ancestors, by walking the MRO
down to MvDefBase, skipping any classes without the classvar explicitly set.
Source code in src/mvdef/transfer/base.py
check ¶
Returns None if check succeeds, or returns the CheckFailure for the first
blocker found upon checking that the file parses correctly (the function will
raise errors rather than returning them in 'escalate' mode, to help debugging).
Source code in src/mvdef/transfer/base.py
copy ¶
CpDef
dataclass
¶
CpDef(src: Path, dst: Path, mv: list[str], dry_run: bool = False, escalate: bool = False, cls_defs: bool = False, func_defs: bool = False, verbose: bool = False, _copy_mode: bool = True)
Bases: MvDef
Copy function definitions from one file to another, and any necessary associated import statements along with them.
Option Description Type Default —————————— —————————————————————————————————————————— ——————————— ——————— • src source file to copy definitions from Path - • dst destination file (may not exist) Path - • mv names to copy from the source file list[str] - • dry_run whether to only preview the change diffs bool False • escalate whether to raise an error upon failure bool False • cls_defs whether to use only class definitions bool False • func_defs whether to use only function definitions bool False • verbose whether to log anything bool False
diffs ¶
Calls Agenda.populate_agenda() explicitly for the src file, and implicitly for
the dst file by Agenda.unidiff(), and returns a single diff string for dst.
Source code in src/mvdef/transfer/copy.py
list ¶
LsDef
dataclass
¶
LsDef(src: Path, match: list[str] = lambda: ['*'](), dry_run: bool = False, list: bool = False, escalate: bool = False, cls_defs: bool = False, func_defs: bool = False, verbose: bool = False)
Bases: MvDefBase
List function definitions in a given file.
Option Description Type Default —————————— —————————————————————————————————————————— ——————————— ——————— • src source file to list definitions from Path - • match name regex to list from the source file list[str] ['*'] • dry_run whether to print the all diff bool False • list whether to print the list of names bool False • escalate whether to raise an error upon failure bool False • cls_defs whether to use only class definitions bool False • func_defs whether to use only function definitions bool False • verbose whether to log anything bool False
manif ¶
Calls Agenda.populate_agenda() explicitly if not yet created,
and returns a single diff string.
Source code in src/mvdef/transfer/list.py
move ¶
MvDef
dataclass
¶
MvDef(src: Path, dst: Path, mv: list[str], dry_run: bool = False, escalate: bool = False, cls_defs: bool = False, func_defs: bool = False, verbose: bool = False, _copy_mode: bool = False)
Bases: MvDefBase
Move function definitions from one file to another, moving/copying any necessary associated import statements along with them.
Option Description Type Default —————————— —————————————————————————————————————————— ——————————— ——————— • src source file to take definitions from Path - • dst destination file (may not exist) Path - • mv names to move from the source file list[str] - • dry_run whether to only preview the change diffs bool False • escalate whether to raise an error upon failure bool False • cls_defs whether to use only class definitions bool False • func_defs whether to use only function definitions bool False • verbose whether to log anything bool False
diffs ¶
Calls Agenda.populate_agenda() implicitly by Agenda.unidiff() and returns 2
diff strings for src and dst respectively. If only copying (not editing src),
just populates the agenda and returns a single diff string.