(
self,
body: Callable,
name: Optional[str] = None,
aliases: Iterable[str] = (),
positional: Optional[Iterable[str]] = None,
optional: Iterable[str] = (),
default: bool = False,
auto_shortflags: bool = True,
help: Optional[Dict[str, Any]] = None,
pre: Optional[Union[List[str], str]] = None,
post: Optional[Union[List[str], str]] = None,
autoprint: bool = False,
iterable: Optional[Iterable[str]] = None,
incrementable: Optional[Iterable[str]] = None,
)
| 58 | # it feels bad, given the builtin will never actually be in play anywhere |
| 59 | # except a debug shell whose frame is exactly inside this class. |
| 60 | def __init__( |
| 61 | self, |
| 62 | body: Callable, |
| 63 | name: Optional[str] = None, |
| 64 | aliases: Iterable[str] = (), |
| 65 | positional: Optional[Iterable[str]] = None, |
| 66 | optional: Iterable[str] = (), |
| 67 | default: bool = False, |
| 68 | auto_shortflags: bool = True, |
| 69 | help: Optional[Dict[str, Any]] = None, |
| 70 | pre: Optional[Union[List[str], str]] = None, |
| 71 | post: Optional[Union[List[str], str]] = None, |
| 72 | autoprint: bool = False, |
| 73 | iterable: Optional[Iterable[str]] = None, |
| 74 | incrementable: Optional[Iterable[str]] = None, |
| 75 | ) -> None: |
| 76 | # Real callable |
| 77 | self.body = body |
| 78 | update_wrapper(self, self.body) |
| 79 | # Copy a bunch of special properties from the body for the benefit of |
| 80 | # Sphinx autodoc or other introspectors. |
| 81 | self.__doc__ = getattr(body, "__doc__", "") |
| 82 | self.__name__ = getattr(body, "__name__", "") |
| 83 | self.__module__ = getattr(body, "__module__", "") |
| 84 | # Default name, alternate names, and whether it should act as the |
| 85 | # default for its parent collection |
| 86 | self._name = name |
| 87 | self.aliases = aliases |
| 88 | self.is_default = default |
| 89 | # Arg/flag/parser hints |
| 90 | self.positional = self.fill_implicit_positionals(positional) |
| 91 | self.optional = tuple(optional) |
| 92 | self.iterable = iterable or [] |
| 93 | self.incrementable = incrementable or [] |
| 94 | self.auto_shortflags = auto_shortflags |
| 95 | self.help = (help or {}).copy() |
| 96 | # Call chain bidness |
| 97 | self.pre = pre or [] |
| 98 | self.post = post or [] |
| 99 | self.times_called = 0 |
| 100 | # Whether to print return value post-execution |
| 101 | self.autoprint = autoprint |
| 102 | |
| 103 | @property |
| 104 | def name(self) -> str: |
nothing calls this directly
no test coverage detected