-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add ability to report on linecounts of specific flags #3794
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.
Wow, this is really awesome!
Do you think you can add tests for it in reports.test
?
mypy/report.py
Outdated
@@ -127,15 +139,25 @@ def on_file(self, | |||
|
|||
self.counts[tree._fullname] = (imputed_annotated_lines, physical_lines, | |||
annotated_funcs, total_funcs) | |||
for option in self.breakdowns: | |||
if getattr(options, option): | |||
self.breakdown_counts[option][tree._fullname] = ( |
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.
It's probably better to use tree.fullname()
instead of tree._fullname
@ddfisher are you still planning to work on this? This branch is stale and its 2 month anniversary is coming up soon. |
I can take this over if needed. This PR is mostly ready in my opinion -- just needs a couple of tests. |
Go for it! (Though fair warning: this isn't going to end up in the 0.530
release.)
|
# Conflicts: # mypy/report.py
Okay, so after looking into this some more I realized that the way linecount-breakdowns report is presented does not make sense. So, let's say I run linecounts$ diff linecount.txt strict_optional-linecount.txt
1,2c1
< 42064 42216 2996 3006 total
< 4940 4940 264 264 mypy.semanal
---
> 37124 37276 2732 2742 total Essentially, Here is what I think it should be like: whenever you run mypy with
I haven't started implementing it yet. Does this seem like a good idea? |
What do the numbers mean? Are 400 and 324 the number of lines where the flag made a difference and 2400/3124 the number of lines where the flag was set that way? (I.e. the total line count for the files covered by that flag setting.) I wonder if there's a way to combine this with my idea from #4018. |
I was thinking 400 would be the number of lines checked with I like your idea but I think it would be too complicated to implement for all flags. if options.flag_name:
self.fail(...) Essentially, you would just add a statement before the if statement to mark current module as needing the flag disabled. Implementing the breakdowns the way I suggest would be fairly simple: |
Yeah, #4018 doesn't work for A flag that just counts per flag which files have it on and which files have it off doesn't feel very useful, and reporting it in terms of line counts seems even less appropriate (since it's quite possible that a flag only affects a small fraction of the lines in a file). Maybe it would make some sense to have a report that printed some numbers for each flag that is on in some files and off in others, e.g.
I like having this as a sentence rather than a table, because this way it is self-explanatory, and I don't think that we'll have a lot of other tools that would need to parse such a report. |
Is this PR dead now? (I noticed the stale branch just now.) |
I think my original intention behind this PR was to make it available for our linecount report. Is there a form of this PR that we're still interested in? |
I don't have time to look into it myself -- I am offering two choices: close it, or keep it open, and in the latter case you and Stas can finish it at your leisure. Mypy development at Dropbox has taken a different turn so I don't think we're holding our breath for this. |
As far as I know, no one particularly cared about this except for (previously) mypy at Dropbox, so I think closing this is the right call. Thanks! |
For example:
mypy --config-file mypy_self_check.ini --linecount-report linecounts --linecount-breakdown strict_optional mypy
tells me that mypy has 24,054 lines of checked strict Optional code.