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 Any Expressions report #3492

Merged
merged 3 commits into from Jun 7, 2017

Conversation

Projects
None yet
3 participants
@ilinum
Collaborator

ilinum commented Jun 1, 2017

This report measures the number of expressions in a file that have type Any.

This is what the report looks like:

mypy$ mypy --any-exprs-report any-exprs-report mypy
mypy$ cat any-exprs-report/any-exprs.txt
Name                         Anys    Exprs    Coverage
------------------------------------------------------
mypy.__main__                   0        9     100.00%
mypy.api                        0       41     100.00%
mypy.applytype                  0      152     100.00%
mypy.binder                     2      682      99.71%
mypy.build                     18     4331      99.58%
mypy.checker                    6     7154      99.92%
mypy.checkexpr                  0     6689     100.00%
mypy.checkmember                0     1541     100.00%
mypy.checkstrformat            14      812      98.28%
mypy.constraints                0      975     100.00%
mypy.defaults                   0        8     100.00%
mypy.erasetype                  0      179     100.00%
mypy.errors                     0     1157     100.00%
mypy.expandtype                 0      296     100.00%
mypy.experiments                0        6     100.00%
mypy.exprtotype                 0      281     100.00%
mypy.fastparse                 98     3135      96.87%
mypy.fastparse2                72     2512      97.13%
mypy.fixup                      7      761      99.08%
mypy.funcplugins                0       91     100.00%
mypy.git                       46      257      82.10%
mypy.indirection                0      248     100.00%
mypy.infer                      0       41     100.00%
mypy.join                       0      988     100.00%
mypy.main                     105     1484      92.92%
mypy.maptype                    0      157     100.00%
mypy.meet                       0      863     100.00%
mypy.messages                   6     2660      99.77%
mypy.moduleinfo                 0       54     100.00%
mypy.myunit                    45      897      94.98%
mypy.myunit.__main__            5       10      50.00%
mypy.nodes                    124     4226      97.07%
mypy.options                    1      276      99.64%
mypy.parse                      0       32     100.00%
mypy.report                    14     1657      99.16%
mypy.sametypes                  0      328     100.00%
mypy.semanal                  108    12061      99.10%
mypy.server.astdiff             0      535     100.00%
mypy.server.astmerge            0      502     100.00%
mypy.server.aststrip            0      185     100.00%
mypy.server.deps                0      594     100.00%
mypy.server.subexpr             0      302     100.00%
mypy.server.target              0       42     100.00%
mypy.server.trigger             0        4     100.00%
mypy.server.update              0      819     100.00%
mypy.sharedparse                0       24     100.00%
mypy.solve                      0      107     100.00%
mypy.stats                      0      855     100.00%
mypy.strconv                   40     1706      97.66%
mypy.stubgen                   74     1843      95.98%
mypy.stubgenc                  18      547      96.71%
mypy.stubutil                   3      302      99.01%
mypy.subtypes                   0     1745     100.00%
mypy.test.config                0       27     100.00%
mypy.test.data                 54     1366      96.05%
mypy.test.helpers               1      771      99.87%
mypy.test.testargs              0       17     100.00%
mypy.test.testcheck             1      718      99.86%
mypy.test.testcmdline           6      217      97.24%
mypy.test.testdeps              0      123     100.00%
mypy.test.testdiff              0      135     100.00%
mypy.test.testextensions      248      360      31.11%
mypy.test.testfinegrained       1      238      99.58%
mypy.test.testgraph             0      169     100.00%
mypy.test.testinfer             0      357     100.00%
mypy.test.testmerge             1      503      99.80%
mypy.test.testmoduleinfo        0       26     100.00%
mypy.test.testparse             0      107     100.00%
mypy.test.testpythoneval       10      205      95.12%
mypy.test.testreports           1       50      98.00%
mypy.test.testsemanal           0      434     100.00%
mypy.test.testsolve             0      580     100.00%
mypy.test.teststubgen           0      382     100.00%
mypy.test.testsubtypes          0     1065     100.00%
mypy.test.testtransform         0      140     100.00%
mypy.test.testtypegen           0      311     100.00%
mypy.test.testtypes             0     4044     100.00%
mypy.traverser                  0      734     100.00%
mypy.treetransform              0     1720     100.00%
mypy.tvar_scope                 0      200     100.00%
mypy.typeanal                   0     1988     100.00%
mypy.typefixture                0      932     100.00%
mypy.types                    120     3723      96.78%
mypy.typevars                   0       44     100.00%
mypy.util                       8      201      96.02%
mypy.version                    0       31     100.00%
mypy.visitor                    0      424     100.00%
mypy.waiter                    61     1074      94.32%
------------------------------------------------------
Total                        1318    90579      98.54%
Add Any Expressions report
This report measures the number of expressions in a file that have type Any.
@gvanrossum

This comment has been minimized.

Show comment
Hide comment
@gvanrossum

gvanrossum Jun 2, 2017

Member
Member

gvanrossum commented Jun 2, 2017

StatisticsVisitor: Report filename and line number when there's an error
If there's a cycle in function expansion, report filename and line number
@ilinum

This comment has been minimized.

Show comment
Hide comment
@ilinum

ilinum Jun 2, 2017

Collaborator

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

mypy.nodes:224: ERROR: cycle in function expansion; skipping
mypy.types:25: ERROR: cycle in function expansion; skipping
mypy.fastparse:758: ERROR: cycle in function expansion; skipping
mypy.fastparse:763: ERROR: cycle in function expansion; skipping
mypy.fastparse2:753: ERROR: cycle in function expansion; skipping
mypy.fastparse2:758: ERROR: cycle in function expansion; skipping
mypy.server.aststrip:44: ERROR: cycle in function expansion; skipping
mypy.typeanal:335: ERROR: cycle in function expansion; skipping
mypy.semanal:293: ERROR: cycle in function expansion; skipping
mypy.semanal:429: ERROR: cycle in function expansion; skipping
mypy.semanal:556: ERROR: cycle in function expansion; skipping
mypy.semanal:630: ERROR: cycle in function expansion; skipping
mypy.semanal:637: ERROR: cycle in function expansion; skipping
mypy.checker:163: ERROR: cycle in function expansion; skipping
mypy.checker:195: ERROR: cycle in function expansion; skipping
mypy.checker:230: ERROR: cycle in function expansion; skipping
mypy.checker:548: ERROR: cycle in function expansion; skipping
mypy.checker:576: ERROR: cycle in function expansion; skipping
mypy.checker:1082: ERROR: cycle in function expansion; skipping
mypy.build:68: ERROR: cycle in function expansion; skipping
mypy.build:111: ERROR: cycle in function expansion; skipping
Collaborator

ilinum commented Jun 2, 2017

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

mypy.nodes:224: ERROR: cycle in function expansion; skipping
mypy.types:25: ERROR: cycle in function expansion; skipping
mypy.fastparse:758: ERROR: cycle in function expansion; skipping
mypy.fastparse:763: ERROR: cycle in function expansion; skipping
mypy.fastparse2:753: ERROR: cycle in function expansion; skipping
mypy.fastparse2:758: ERROR: cycle in function expansion; skipping
mypy.server.aststrip:44: ERROR: cycle in function expansion; skipping
mypy.typeanal:335: ERROR: cycle in function expansion; skipping
mypy.semanal:293: ERROR: cycle in function expansion; skipping
mypy.semanal:429: ERROR: cycle in function expansion; skipping
mypy.semanal:556: ERROR: cycle in function expansion; skipping
mypy.semanal:630: ERROR: cycle in function expansion; skipping
mypy.semanal:637: ERROR: cycle in function expansion; skipping
mypy.checker:163: ERROR: cycle in function expansion; skipping
mypy.checker:195: ERROR: cycle in function expansion; skipping
mypy.checker:230: ERROR: cycle in function expansion; skipping
mypy.checker:548: ERROR: cycle in function expansion; skipping
mypy.checker:576: ERROR: cycle in function expansion; skipping
mypy.checker:1082: ERROR: cycle in function expansion; skipping
mypy.build:68: ERROR: cycle in function expansion; skipping
mypy.build:111: ERROR: cycle in function expansion; skipping
@gvanrossum

This comment has been minimized.

Show comment
Hide comment
@gvanrossum

gvanrossum Jun 2, 2017

Member

So much better!

Member

gvanrossum commented Jun 2, 2017

So much better!

@ddfisher ddfisher self-requested a review Jun 2, 2017

@ddfisher

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.

Show outdated Hide outdated mypy/report.py
Show outdated Hide outdated mypy/report.py
@ilinum

This comment has been minimized.

Show comment
Hide comment
@ilinum

ilinum Jun 6, 2017

Collaborator

@ddfisher Thanks for the review!

The new reporter reports types, not lines. It uses StatisticsVisitor, which visits every type recursively (for every expression, it calls, process node, which itself calls type, which records the number of any types)

As for cycle in function expansion, I opened: #3503.

Collaborator

ilinum commented Jun 6, 2017

@ddfisher Thanks for the review!

The new reporter reports types, not lines. It uses StatisticsVisitor, which visits every type recursively (for every expression, it calls, process node, which itself calls type, which records the number of any types)

As for cycle in function expansion, I opened: #3503.

@ddfisher

Ah, yep! You're right -- it does check exprs. Great!

This looks good to me! Thanks for fixing the nits I pointed out.

@ilinum ilinum merged commit e86c0dc into python:master Jun 7, 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:any-expr-report branch Jun 7, 2017

@ddfisher

This comment has been minimized.

Show comment
Hide comment
@ddfisher

ddfisher Jun 7, 2017

Collaborator

🎉

Collaborator

ddfisher commented Jun 7, 2017

🎉

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