Mypy: Semantic analyzer redesign

Created on 16 Jan 2019  路  2Comments  路  Source: python/mypy

We are planning to do a major update to how the semantic analyzer works. The main idea is to use "deferred nodes" to allow each AST node to be processed an arbitrary number of times until all dependencies are ready. This may be needed to bind names within import cycles, for example. This should allow us to fix various issues with forward references and import cycles. We also hope that it will make it relatively easy to support general recursive types.

While the new design is in development, we'll have two semantic analyzer implementations available. We'll replace the existing semantic analyzer with the new one once the latter works well enough. Before that the new semantic analyzer must be explicitly enabled with a command-line option.

The new design should be strictly better than the current one, but there will likely some backward compatibility issues with existing plugins.

feature new-semantic-analyzer priority-0-high topic-import-cycles

Most helpful comment

We've now officially released the new semantic analyzer as an experimental feature, enabled through --new-semantic-analyzer. There are still a few regressions, some of which may take a while to fix, but we can track those as separate issues.

All 2 comments

Another thing (reminded by #3459) that we should do soon is write more docs about the deferral/completeness logic. Some details are missing in the docstrings, it is better not to postpone this until after we make new analyzer default.

We've now officially released the new semantic analyzer as an experimental feature, enabled through --new-semantic-analyzer. There are still a few regressions, some of which may take a while to fix, but we can track those as separate issues.

Was this page helpful?
0 / 5 - 0 ratings