mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-04-24 10:03:36 +02:00
Cmd / Cmds: Update legacy type annotation
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
3e979d21ae
commit
9b5cd1b857
2 changed files with 4 additions and 6 deletions
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Optional, List, Type, Union, TypeVar
|
||||
import inspect, sys, re, abc, argparse
|
||||
from argparse import ArgumentParser, _SubParsersAction
|
||||
|
||||
|
|
@ -21,9 +20,9 @@ class Cmd(abc.ABC): # export
|
|||
self.name = name
|
||||
self.help = help
|
||||
self.parent = None
|
||||
self.children: List[Cmd] = []
|
||||
self.child_classes: List[Type[Cmd]] = []
|
||||
self.app: Optional[Cmds] = None
|
||||
self.children: list[Cmd] = []
|
||||
self.child_classes: list[type[Cmd]] = []
|
||||
self.app: Cmds|None = None
|
||||
|
||||
async def _run(self, args):
|
||||
pass
|
||||
|
|
@ -34,7 +33,7 @@ class Cmd(abc.ABC): # export
|
|||
r.set_defaults(func=self.run)
|
||||
return r
|
||||
|
||||
def add_subcommands(self, cmd: Union[str, Type[Cmd], List[Type[Cmd]]]) -> None:
|
||||
def add_subcommands(self, cmd: str|type[Cmd]|list[type[Cmd]]) -> None:
|
||||
if isinstance(cmd, str):
|
||||
sc = []
|
||||
for name, obj in inspect.getmembers(sys.modules[self.__class__.__module__]):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Optional
|
||||
import os, sys, argcomplete, argparse, importlib, inspect, re, pickle, asyncio, cProfile
|
||||
from argparse import ArgumentParser
|
||||
from pathlib import Path, PurePath
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue