-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add type hinting #143
Add type hinting #143
Conversation
1674fec
to
14f19e0
Compare
FIXES pycontribs#140 Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
14f19e0
to
35b5852
Compare
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.
Please also add mypy to pre-commit config, without it there is no proof that mypy would pass your changes. You can inspire from https://github.com/ansible-community/ansible-lint/blob/main/.pre-commit-config.yaml#L93-L118 -- obviously depenendencies would be totally different.
Btw, thanks for taking care of this.
|
Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
If you want those dependency updates in their own PR, I can move them. |
For the remaining type hint errors, I probably need help. I'm not as familiar with the code...
|
And if you get #126 in first, I will happily rebase |
@ziegenberg I am ok with dependency version bumping but it should be done a separated pull-request. The one that adds typing (this one) should only contain changes related to typing and nothing that could affect the code at runtime. Probably you can first do the deps bumping and after we merge it you rebase this, making it clean. That is important for traceability. |
@ziegenberg First accept invitation from https://github.com/pycontribs/ansi2html/invitations and after that review #126 so we can merge it. I looks at it briefly and it looks ok, but I need another pair of eyes before merging that one. |
70ed9c2
to
e38e371
Compare
So I cleaned up the branch and force pushed. Mypy still fails with wit 15 errors. I brought this number down from originally 80 but I need help with the last tricky bits. Mypy details
|
Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
Ok, I got it down to 4 errors in only one file.
|
@ziegenberg Feel free to add |
They need to be fixed later. Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
13f1df7
to
163b4ac
Compare
While adding typehinting the option to specify an input encoding got ignored. This commit fixes this regression. This commit also fixes the tests with calling ansi2html as command. As the pytest documentation states, during test execution `stdin` is set to a “null” object which will fail on attempts to read from it because it is rarely desired to wait for interactive input when running automated tests. So we also patch now `sys.stdin` using a `io.TextIOWrapper` and wrapping any actual input in a `io.BytesIO`. Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
While adding type-hinting the option to specify an input encoding got ignored. This commit fixes this regression. This commit also fixes the tests which call ansi2html as a command. As the pytest documentation states, during test execution `stdin` is set to a “null” object which will fail on attempts to read from it because it is rarely desired to wait for interactive input when running automated tests. So we also patch now `sys.stdin` using a `io.TextIOWrapper` and wrapping any actual input in an `io.BytesIO`. Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
Adds some basic type hinting.
mypy ansi2html/style.py
is happy andmypy ansi2html/converter.py
spits out a few errors I don't know how to fix.Fixes: #140