Commit 3e60f6d4 authored by Michael J. Sullivan's avatar Michael J. Sullivan Committed by Jelle Zijlstra
Browse files

Support compilation with mypyc (#1009)

* Make most of blib2to3 directly typed and mypyc-compatible

This used a combination of retype and pytype's merge-pyi to do the
initial merges of the stubs, which then required manual tweaking to
make actually typecheck and work with mypyc.

Co-authored-by: default avatarSanjit Kalapatapu <sanjitkal@gmail.com>
Co-authored-by: default avatarMichael J. Sullivan <sully@msully.net>

* Make black able to compile and run with mypyc

The changes made fall into a couple categories:
 * Fixing actual type mistakes that slip through the cracks
 * Working around a couple mypy bugs (the most annoying of which being
   that we need to add type annotations in a number of places where
   variables are initialized to None)

Co-authored-by: default avatarSanjit Kalapatapu <sanjitkal@gmail.com>
Co-authored-by: default avatarMichael J. Sullivan <sully@msully.net>
parent 12826f3c
Loading
Loading
Loading
Loading
+1 −1
Changes for .appveyor.yml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ build: off

test_script:
  - C:\Python36\python.exe tests/test_black.py
  - C:\Python36\python.exe -m mypy black.py blackd.py tests/test_black.py
  - C:\Python36\python.exe -m mypy black.py blackd.py tests/test_black.py blib2to3

after_test:
  - C:\Python36\python.exe -m pip install pyinstaller
+4 −0
Changes for .flake8: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,3 +3,7 @@ ignore = E203, E266, E501, W503
max-line-length = 80
max-complexity = 18
select = B,C,E,F,W,T4,B9
# We need to configure the mypy.ini because the flake8-mypy's default
# options don't properly override it, so if we don't specify it we get
# half of the config from mypy.ini and half from flake8-mypy.
mypy_config = mypy.ini
+1 −0
Changes for .gitignore: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,3 +12,4 @@ pip-wheel-metadata/
_black_version.py
.idea
.eggs
.dmypy.json
+2 −0
Changes for Pipfile: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ toml = ">=0.9.4"
black = {path = ".",extras = ["d"],editable = true}
aiohttp-cors = "*"
typed-ast = "==1.4.0"
typing_extensions = ">=3.7.4"
mypy_extensions = ">=0.4.3"
regex = ">=2019.8"
pathspec = ">=0.6"
dataclasses = {version = ">=0.6", python_version = "< 3.7"}
+23 −5
Changes for Pipfile.lock: 23 added lines, 5 removed lines.
Original line number Diff line number Diff line
{
    "_meta": {
        "hash": {
            "sha256": "ad54dbd29085bc14caf655456b93d9f09e8556406ef956a5a05c20e30363ffa1"
            "sha256": "9df9582de1e290f76bd43bbe8dc291bc71e4031517c7e824eb67c65d8e01f78f"
        },
        "pipfile-spec": 6,
        "requires": {},
@@ -134,6 +134,14 @@
            ],
            "version": "==4.5.2"
        },
        "mypy-extensions": {
            "hashes": [
                "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d",
                "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"
            ],
            "index": "pypi",
            "version": "==0.4.3"
        },
        "pathspec": {
            "hashes": [
                "sha256:e285ccc8b0785beadd4c18e5708b12bb8fcf529a1e61215b3feff1d1e559ea5c"
@@ -194,6 +202,15 @@
            "index": "pypi",
            "version": "==1.4.0"
        },
        "typing-extensions": {
            "hashes": [
                "sha256:091ecc894d5e908ac75209f10d5b4f118fbdb2eb1ede6a63544054bb1edb41f2",
                "sha256:910f4656f54de5993ad9304959ce9bb903f90aadc7c67a0bef07e678014e892d",
                "sha256:cf8b63fedea4d89bab840ecbb93e75578af28f76f66c35889bd7065f5af88575"
            ],
            "index": "pypi",
            "version": "==3.7.4.1"
        },
        "yarl": {
            "hashes": [
                "sha256:024ecdc12bc02b321bc66b41327f930d1c2c543fa9a561b39861da9388ba7aa9",
@@ -697,11 +714,12 @@
        },
        "typing-extensions": {
            "hashes": [
                "sha256:2ed632b30bb54fc3941c382decfd0ee4148f5c591651c9272473fea2c6397d95",
                "sha256:b1edbbf0652660e32ae780ac9433f4231e7339c7f9a8057d0f042fcbcea49b87",
                "sha256:d8179012ec2c620d3791ca6fe2bf7979d979acdbef1fca0bc56b37411db682ed"
                "sha256:091ecc894d5e908ac75209f10d5b4f118fbdb2eb1ede6a63544054bb1edb41f2",
                "sha256:910f4656f54de5993ad9304959ce9bb903f90aadc7c67a0bef07e678014e892d",
                "sha256:cf8b63fedea4d89bab840ecbb93e75578af28f76f66c35889bd7065f5af88575"
            ],
            "version": "==3.7.4"
            "index": "pypi",
            "version": "==3.7.4.1"
        },
        "urllib3": {
            "hashes": [
Loading