-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix and expand datalad.runner type annotations #6893
Fix and expand datalad.runner type annotations #6893
Conversation
This commit simplifies the type of `WitlessProtocol.proc_out` and `WitlessProtocol.proc_err` to `bool`. The code treated it earlier as `Optional[bool]`.
This commit fixes the type annotations in `datalad.runner.exceptions`, and adds runtime type-checks that are required by `mypy` for a successful validation.
This commit fixes type annotation problems in `datalad.runner.runnerthreads`. It also replaces `Union[x, None]` with `Optional[x]`.
This commit fixes a faulty type annotation by adding the missing `Optional[...]` clause.
This commit adds logging of the protocol that was provided to the runner in order to improve the possibility to diagnose an error based on debug log-entries.
This commit fixes existing type annotations in `datalad.runner.nonasyncrunner`. A few `isinstance()` and `assert` clauses had to be added. A number of `ThreadedRunner` attributes are only declared in the constructor. This silences some other tools that check for declarations of used attributes in the constructor of a class.
Codecov Report
@@ Coverage Diff @@
## maint #6893 +/- ##
==========================================
+ Coverage 90.16% 91.15% +0.99%
==========================================
Files 354 354
Lines 46197 46215 +18
==========================================
+ Hits 41652 42127 +475
+ Misses 4545 4088 -457
Continue to review full report at Codecov.
|
@christian-monch DataLad requires Python 3.7+, correct? If so, the recommended approach is to use "modern" type annotations by adding |
This commit adds a missing return type to `_format_json_error_messages`. Co-authored-by: John T. Wodder II <jwodder@users.noreply.github.com>
Good point, thanks. The annotations stem from the earlier versions. Will verify the requirements and use the "modern" style, which I prefer anyway :-) |
woohoo, thanks @christian-monch . I pushed little commit to add entire runner into typechecking CI of tox |
for your convenience, here is what errors CI reports
so only something funny left in the runner tests. |
Overcomes error: Cannot find implementation or library stub for module named "pytest" and I do not think there is types-pytest
For
added |
tox.ini
Outdated
@@ -29,6 +29,7 @@ commands = flake8 {posargs} | |||
[testenv:typing] | |||
deps = | |||
mypy~=0.900 | |||
pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than manually specifying test dependencies, it would be better to tell tox to install all of them via the tests
extra:
[testenv:typing]
extras = tests
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone please address this.
Thx, forgot to check the |
This commit includes some minor reformattings without semantic changes.
@@ -32,7 +33,7 @@ def pipe_data_received(self, fd, data): | |||
self.send_result((fd, line)) | |||
|
|||
|
|||
def _runner_with_protocol(protocol) -> ThreadedRunner: | |||
def _runner_with_protocol(protocol: Type[WitlessProtocol]) -> ThreadedRunner: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from __future__ import annotations
lets you use the builtin type
instead of typing.Type
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx. Changed it to type[...]
This commit modernizes class-type annotations in the runner code and runner tests
tox.ini
Outdated
@@ -29,6 +29,7 @@ commands = flake8 {posargs} | |||
[testenv:typing] | |||
deps = | |||
mypy~=0.900 | |||
pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone please address this.
This commit moves test dependencies from `tox.ini` into `setup.py` and just references them in `tox.ini`.
Moved the type-test dependency definitions to |
This PR fixes #6889
The runner-code passes validation tests of
mypy
version0.971
, i.e. with strict optional checking.Changelog
🏠 Internal
datalad.runner
this resolves issuedatalad/runner
already has lots of annotations but ATM failsmypy
(@christian-monch interested? ;)) #6889