-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 typing to BaseReporter.out
#5023
Add typing to BaseReporter.out
#5023
Conversation
tests/test_self.py
Outdated
@@ -122,11 +121,11 @@ def _display(self, layout: "Section") -> None: | |||
pass | |||
|
|||
@property | |||
def out(self) -> StringIO: | |||
def out(self) -> TextIO: # type: ignore # Property is not the same as BaseLinter's attr |
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.
@cdce8p You also commented on this in #4954, see #4954 (comment) and #4954 (comment)
However, this still is an issue. mypy
maintainers seem to suggest not doing this kind of stuff (see python/mypy#8185). Do we want to refactor (can we?) or is adding the type: ignore
enough. For some reason for the one below I needed two comments.
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.
I've come across python/mypy#8185 in another project already. Was doing something similar 😅 type: ignore
would be fine IMO. See also python/mypy#7994 which suggest to use type: ignore
to silence the error.
def out(self) -> TextIO: # type: ignore # Property is not the same as BaseLinter's attr | |
def out(self) -> TextIO: # type: ignore[override] |
Pull Request Test Coverage Report for Build 1244657760
💛 - Coveralls |
tests/test_self.py
Outdated
@property # type: ignore # Property is not the same as BaseLinter's attr | ||
def linter(self) -> PyLinter: # type: ignore |
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.
type: ignore[override]
should only be necessary on the second line.
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.
I agree, but mypy
doesn't. Note that we also don't get a "useless suppression" warning. Might want to report this as a bug to mypy
, but both comments are necessary for mypy
to pass.
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Turns out some reporters are initialised while specifically supplying |
Type of Changes
Description
Small changes which are needed for further typing of
pylint/reporters
.I ran the test suite and printed out all types of
BaseReporter.out
. It was only everio.TextIO
which also seems fair given what it is doing. However, perhaps somebody with more knowledge of the code base wants to take a look at this.