[behave] Added anottations for four classes#15953
Conversation
This comment has been minimized.
This comment has been minimized.
|
I have added remaining annotation as much as can. |
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
| def abort(self, reason: str | None = None) -> None: ... | ||
| def use_or_assign_param(self, name: str, value): ... | ||
| def use_or_assign_param(self, name: str, value: _T) -> _T | None: ... | ||
| def use_or_create_param(self, name: str, factory_func: Callable[_P, Incomplete], *args: _P.args, **kwargs: _P.kwargs): ... |
There was a problem hiding this comment.
return type here is missing, let's add it :)
| def execute_steps(self, steps_text: str) -> bool: ... | ||
| def add_cleanup(self, cleanup_func: Callable[_P, Incomplete], *args: _P.args, **kwargs: _P.kwargs) -> None: ... | ||
| @property | ||
| def captured(self): ... |
| @staticmethod | ||
| def ignore_cleanup_error(context, cleanup_func, exception: BaseException) -> None: ... | ||
| def use_with_user_mode(self) -> AbstractContextManager[None]: ... | ||
| def user_mode(self) -> Generator[Incomplete]: ... |
There was a problem hiding this comment.
If we are refactoring this module, let's remove all Incomplete types as well. Or add a comment on why it is hard to do / impossible (if this is the case).
There was a problem hiding this comment.
@sobolevn I have already mentioned that this library missing most of classes stubs. When I create it I will update this file too.
| def attach(self, mime_type: str, data: bytes) -> None: ... | ||
|
|
||
| @contextlib.contextmanager | ||
| def use_context_with_mode(context, mode) -> Generator[None]: ... |
There was a problem hiding this comment.
When adding new annotations, it would be preferable to add types to them :)
|
Thanks for the feedback! I have a question about the scope of this PR. Some of the requested changes involve classes that are not yet annotated (e.g. Config, Feature, StepRegistry). Should I add their annotations within this PR? That would make it significantly larger, since they're part of a chain of dependencies. In this case i will convert this PR to draft and continue works on annotations. |
I'm working on fully annotating behave/behave/runner.pyi.
This first commit adds annotations for four classes (ModelRunner, Runner, ContextMaskWarning, ContextMode).
In the next commit I'll add the remaining annotations (standalone functions and the Context class, which was partially annotated before).