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

[html-report] Display unreachable code as Any #3616

Merged
merged 13 commits into from Jul 5, 2017

Conversation

Projects
None yet
3 participants
@ilinum
Collaborator

ilinum commented Jun 26, 2017

No description provided.

@gvanrossum

Looks fine! Amazing what such a simple change found. :-)

@gvanrossum

This comment has been minimized.

Show comment
Hide comment
@gvanrossum

gvanrossum Jun 27, 2017

Member

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 :-).

Member

gvanrossum commented Jun 27, 2017

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 :-).

ilinum added some commits Jun 27, 2017

Convert relative path of css file to url correctly
As it turns out, path to css on Windows was broken, which means
--html-report was not useful on Windows at all
@ilinum

This comment has been minimized.

Show comment
Hide comment
@ilinum

ilinum Jun 27, 2017

Collaborator

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 \ would get converted to %5C, so path to CSS file would look like ..%5Cmypy-html.css, which is wrong.

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 :)

Collaborator

ilinum commented Jun 27, 2017

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 \ would get converted to %5C, so path to CSS file would look like ..%5Cmypy-html.css, which is wrong.

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 :)

@ilinum

This comment has been minimized.

Show comment
Hide comment
@ilinum

ilinum Jun 28, 2017

Collaborator

I realized that this PR does not address reporting of dead code in --any-expr-report.
I don't think it's ready to be merged until this is done.

Collaborator

ilinum commented Jun 28, 2017

I realized that this PR does not address reporting of dead code in --any-expr-report.
I don't think it's ready to be merged until this is done.

ilinum added some commits Jun 28, 2017

@ilinum

This comment has been minimized.

Show comment
Hide comment
@ilinum

ilinum Jun 29, 2017

Collaborator

This PR is ready for review!

Now --any-expr-report counts each line of dead code as one Any.

Collaborator

ilinum commented Jun 29, 2017

This PR is ready for review!

Now --any-expr-report counts each line of dead code as one Any.

@ddfisher

Feel free to merge after fixing nits if you're confident that the updated comments are excellent.

Show outdated Hide outdated mypy/stats.py
TYPE_PRECISE = 1
TYPE_IMPRECISE = 2
TYPE_ANY = 3
TYPE_UNANALYZED = 1 # type of unchecked code (different from any)

This comment has been minimized.

@ddfisher

ddfisher Jul 1, 2017

Collaborator

This comment isn't fully clear.

@ddfisher

ddfisher Jul 1, 2017

Collaborator

This comment isn't fully clear.

This comment has been minimized.

@ilinum

ilinum Jul 5, 2017

Collaborator

Updated.

@ilinum

ilinum Jul 5, 2017

Collaborator

Updated.

Show outdated Hide outdated mypy/stats.py
@@ -79,6 +81,13 @@ def visit_func_def(self, o: FuncDef) -> None:
self.record_line(self.line, TYPE_ANY)
super().visit_func_def(o)
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

This comment has been minimized.

@ddfisher

ddfisher Jul 1, 2017

Collaborator

Could you reword this comment? I don't understand what's going on here.

@ddfisher

ddfisher Jul 1, 2017

Collaborator

Could you reword this comment? I don't understand what's going on here.

This comment has been minimized.

@ilinum

ilinum Jul 5, 2017

Collaborator

Yep, hopefully, should be better now.

@ilinum

ilinum Jul 5, 2017

Collaborator

Yep, hopefully, should be better now.

Show outdated Hide outdated mypy/stats.py
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

This comment has been minimized.

@ddfisher

ddfisher Jul 1, 2017

Collaborator

Please use standard sentence capitalization/punctuation.

@ddfisher

ddfisher Jul 1, 2017

Collaborator

Please use standard sentence capitalization/punctuation.

This comment has been minimized.

@ilinum

ilinum Jul 5, 2017

Collaborator

ok!

@ilinum

ilinum Jul 5, 2017

Collaborator

ok!

Show outdated Hide outdated mypy/stats.py
# 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

This comment has been minimized.

@ddfisher

ddfisher Jul 1, 2017

Collaborator

Nit: probably better to change the if isinstance(t, Instance) to an elif below instead of this early return.

@ddfisher

ddfisher Jul 1, 2017

Collaborator

Nit: probably better to change the if isinstance(t, Instance) to an elif below instead of this early return.

This comment has been minimized.

@ilinum

ilinum Jul 5, 2017

Collaborator

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.

@ilinum

ilinum Jul 5, 2017

Collaborator

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.

@ilinum ilinum merged commit 6c61c66 into python:master Jul 5, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ilinum ilinum deleted the ilinum:report-any-unreachable branch Jul 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment