Skip to content
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

The mother of all pull requests: add --incremental #1292

Merged
merged 125 commits into from
Apr 8, 2016
Merged

The mother of all pull requests: add --incremental #1292

merged 125 commits into from
Apr 8, 2016

Conversation

gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Mar 14, 2016

tl;dr: Please review in this order: semanal.py+tests; nodes.py+types.py; fixup.py; build.py; main.py.

See this Google Doc for some technical debt (read the paper from the top for a more complete overview).

Despite that technical debt I'd like to merge this into master in the current state, because at this point it works well enough and in particular I've tested it with typeshed's runtests.py script as well as with the selection of files in the internal Dropbox server repo. Some considerations:

  • The new (SCC + topsort) algorithm for determining dependencies is always used
  • The incremental (cache) feature is only used when -i/--incremental is used
  • After merging this would require additional real-world testing before we can do a release
  • My own biggest concern is the hack for the sqlalchemy cycle: gvanrossum@ede8184

Don't be fooled by the large number of commits! There are a lot of dead ends and U-turns that you can ignore. Most of the changes are limited to a small number of files:

  • build.py: the new dependency manager (I ripped out the old one)
  • nodes.py, types.py: added [de]serialize() methods to many classes
  • fixup.py: new module to fix up symbol tables after deserialization
  • main.py: added the -i/--incremental option
  • semanal.py: a fix for anonymous namedtuples needed by serialization
  • some tests added/changed for the namedtuple fix
  • .gitignore the .mypy_cache directory (though not even sure I want this)

Somehow GitHub refuses to show the diffs for build.py. Sorry about this; I guess you have to view them locally. You could also try to view the incremental diffs to this file starting with 0b4ef76. (Also note that the dates GitHub lists for the diffs are bogus -- they represent the most recent rebase. The actual work started over a month ago.)

Some questions about how to merge this monster into master. I've got a feeling that the detailed commits from my branch are not that useful. I propose the following order, as separate commits to master:

  1. the semanal.py changes and related tests
  2. (de)serialization methods in nodes.py, types.py
  3. the rest: fixup.py, build.py, main.py, .gitignore

This may also represent a reasonable review order.

Guido van Rossum added 30 commits March 12, 2016 21:07
…ion of OverloadedFuncDef (type was missing).
@gvanrossum
Copy link
Member Author

gvanrossum commented Mar 31, 2016 via email

Guido van Rossum added 6 commits April 5, 2016 16:55
Serialize some additional fields, clarify a few places, add some
comments, replace a print() with an assert.
Made a few things non-optional, removed some duplicate defs, added a TODO comment.
- Add/update many docstrings and comments.
- Remove dead code at end of write_cache().
- Turn cache inconsistency into assert False.
- Use keyword args for State() constructor calls.
@gvanrossum
Copy link
Member Author

Hi @JukkaL, I've pushed a new version that incorporates my responses to all your feedback except for the long last one (starting with "Also L1089 in build.py"). I decided not to write individual "done / no, here's why" responses but instead just do everything or explain what's going on in comments.

Next I'm going to work on testing.

Guido van Rossum added 4 commits April 6, 2016 15:15
…ockers.

Also move normalize_error_messages() to helpers, where it belongs.

This is in preparation of introducing tests for incremental mode.

CompileError is still raised for blockers.
@gvanrossum
Copy link
Member Author

Jukka, I now have a decent start on the unittest infrastructure.

  • There's a new programmatic test module, testgraph.py, that has some tests for topsort() and friends -- it's easy to add more as long as the tests don't require too much setup.
  • There's also a new mechanism for data-driven tests of incremental mode. This is implemented in testcheck.py; the new behavior (roughly what you suggested) is triggered either by a test filename containing 'incremental' or by a test name containing 'Incremental'. (We can change the exact conditions easily.) The mechanism runs each such test once with a cold cache expecting no errors, then again with a warn cache after updating files for which a ".next" version is found, expecting the errors from the test's [out] section. The code also checks that valid cache files exist exactly for those modules that don't have any errors (after each run).
  • I've only written three very basic data-driven tests for now, but it should be easy to add more.

@gvanrossum
Copy link
Member Author

So I think I have addressed everything in your review now except

  • Serializing line numbers (I haven't found the need so far)
  • Your "Bonus" bullet for the test architecture (expecting specific files to be rechecked)
  • The answer on BFS vs. DFS -- I added a reminder comment, but I'm not even sure the old code did DFS
  • Adding more extensive tests (but you didn't really ask for that -- you said "a few" and I've got that :-)

I think I'd like to leave all those unaddressed.

@@ -630,7 +653,7 @@ def is_generic(self) -> bool:
return self.info.is_generic()

def serialize(self) -> JsonDict:
# Not serialized: defs, base_type_exprs
# Not serialized: defs, base_type_exprs,d ecorators
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: d ecorators

@JukkaL
Copy link
Collaborator

JukkaL commented Apr 8, 2016

OK, looks good now! Feel free to merge whenever you like. After merging I suggest filing some new issues (for 0.3.2, I assume):

  • Add extensive tests for incremental type checking. I'd like more tests before turning incremental mode on by default (+ more manual testing).
  • Check which files were rechecked in incremental mode test cases (and which weren't).

I'm not sure either sure whether the old code used DFS, but I have a vague feeling that it might.

@gvanrossum gvanrossum merged commit 288f319 into python:master Apr 8, 2016
@gvanrossum
Copy link
Member Author

Filed: #1349 (add tests), #1350 (check which files we rechecked).

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

Successfully merging this pull request may close these issues.

3 participants