-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[html-report] Display unreachable code as Any #3616
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
Conversation
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.
Looks fine! Amazing what such a simple change found. :-)
However you need to figure out why the Windows tests are failing. Probably something with path separators (it always is, except when it's LF vs. CRLF :-). |
As it turns out, path to css on Windows was broken, which means --html-report was not useful on Windows at all
This reverts commit d65252b.
As it turns out, the path to the CSS file on windows was wrong. It was trying to use the native filepath. However, on Windows the What this means is that css was not working on windows and lines in html report did not have colors. This is fixed now in this PR. So you're right, it was with directory separators :) |
I realized that this PR does not address reporting of dead code in |
In html-report it is colored same as lines with expressions of type "Any" on them
This PR is ready for review! Now |
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.
Feel free to merge after fixing nits if you're confident that the updated comments are excellent.
mypy/stats.py
Outdated
TYPE_PRECISE = 1 | ||
TYPE_IMPRECISE = 2 | ||
TYPE_ANY = 3 | ||
TYPE_UNANALYZED = 1 # type of unchecked code (different from any) |
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.
This comment isn't fully clear.
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.
Updated.
mypy/stats.py
Outdated
|
||
def visit_class_def(self, o: ClassDef) -> None: | ||
# this method is overridden because we don't want to visit base_type_exprs | ||
# base_type_exprs are expressions without a type, which causes them to appear as Any |
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.
Could you reword this comment? I don't understand what's going on 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.
Yep, hopefully, should be better now.
mypy/stats.py
Outdated
if not t: | ||
# if an expression does not have a type, it is often due to dead code | ||
# we should not keep track of the number of these we encounter because there can be | ||
# an unanalyzed value on a line with other analyzed expressions |
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 use standard sentence capitalization/punctuation.
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.
ok!
# we should not keep track of the number of these we encounter because there can be | ||
# an unanalyzed value on a line with other analyzed expressions | ||
self.record_line(self.line, TYPE_UNANALYZED) | ||
return |
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.
Nit: probably better to change the if isinstance(t, Instance)
to an elif
below instead of this early return.
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 don't think that would work - there are two separate if-statements and I think it's easier to just address t possibly being None in the beginning and do an early return.
No description provided.