This doc contains instructions for how to upgrade pytype to support a new Python version, using the Python 3.6->3.7 upgrade as an example.
The process is as follows:
The pytype.utils.validate_version method should be updated to accept the new version.
The documentation for the dis
library is a good reference for bytecode changes. dis is also handy for
disassembling a piece of code and comparing the bytecode between two versions.
For example, to disassemble a function
import dis import foo dis.dis(foo.f) # pretty-prints the bytecode to stdout
Finally, if all else fails, you can consult the CPython source code.
For the open-source project, navigate to the root of your cloned pytype repository and run using the new Python version:
The new version should also be added to the Travis test matrix. Even if the tests do not pass yet, it is helpful to see the failures, and you can configure them to not fail the build by adding to the matrix:
allow_failures: - python: "3.x" # replace x with the appropriate minor version
install_requires fields in
setup.cfg to include
the new version.
Changes may be needed to pytype to support new features that affect typing. For 3.7, such features included postponed evaluation of type annotations, dataclasses, and typing.OrderedDict. New features can be found on the “What’s New in Python 3.x” page and by searching for “New in version 3.x” in the typing module documentation.