-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add Any Expressions report #3492
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
This report measures the number of expressions in a file that have type Any.
Any chance of adding file and line to the ERROR messages?
(UPDATE: I merged a tiny PR that avoids the ERROR messages altogether!)
|
If there's a cycle in function expansion, report filename and line number
@gvanrossum yes, done! That was code that was already there, so I didn't touch it. But it would be useful to have that, I agree. Here is what the output looks like now:
|
So much better! |
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.
Code-wise this looks good (with just a couple small questions around some magic formatting numbers), but I'm not sure it does what it says on the tin: it looks to me like this gives the percentage of lines that contain Any
. This may be reasonable behavior, but the name would need to be changed.
Also, it doesn't have to happen in this PR, but further investigation is needed into the cycle in function expansion
errors. Optimally, we'd understand the root cause and fix it.
mypy/report.py
Outdated
# find the longest filename all files | ||
name_width = max([len(file) for file in self.counts] + [len(file_column_name)]) | ||
# totals are the largest numbers in their column - no need to look at others | ||
any_width = max(len(str(total_any)) + 3, len(any_column_name)) |
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.
What's the + 3
from 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.
This is the minimum distance between numbers in two columns.
Hopefully, this is more clear after the new commit.
mypy/report.py
Outdated
# totals are the largest numbers in their column - no need to look at others | ||
any_width = max(len(str(total_any)) + 3, len(any_column_name)) | ||
exprs_width = max(len(str(total_expr)) + 3, len(total_column_name)) | ||
header = '{:{name_width}} {:>{any_width}} {:>{total_width}} {:>11}'.format( |
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 11
and the 10
s below feel a little magical.
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.
Yeah, this is some real magic numbers. Should be better now!
@ddfisher Thanks for the review! The new reporter reports types, not lines. It uses As for |
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.
Ah, yep! You're right -- it does check exprs. Great!
This looks good to me! Thanks for fixing the nits I pointed out.
🎉 |
This report measures the number of expressions in a file that have type Any.
This is what the report looks like: