• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 35299
0%
main: 93%

Build:
Build:
LAST BUILD BRANCH: fix/immutable-inputs-revalidation
DEFAULT BRANCH: main
Ran 09 Sep 2020 06:30PM UTC
Jobs 1
Files 433
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
35299

push

travis-ci-com

web-flow
Fix MyPy to work by default with Python 3.6+ code and Black with 3.8+ code (#10750)

### Problem

MyPy and Black both use typed-ast for parsing, just like we use it for dependency inference. Typed-ast understands Py27 and 34-37, but not Py38. For Py38, you instead must run with a Python 3.8 interpreter (which also understands 27 and 34-37).

This meant that our default Black and MyPy installations would break if encountering Py38 syntax like the walrus operator. You had to explicitly set `--black-interpreter-constrains` and `--mypy-interpreter-constraints`, which is not at all obvious.

### Solution

Detect if the user has constraints for 3.8+. If so, use the constraints `>=3.8` for the tools. Otherwise, use the tool's default constraints.

We check that the constraints do not include anything less than 3.8, such as 3.7. Why? If they need to support 3.7, then a user won't be using 3.8 syntax. We don't want to constraint to `>=3.8` because this would mean that they must have 3.8 on their machine, even though 3.7 would do just fine.

To facilitate this, we change `PexInterpreterConstraints` to store parsed `Requirement` objects.

#### Also fixes MyPy handing of Python 3.6 and Python 3.7

If the user leaves off `python_version`, MyPy defaults to the version of the interpreter used to run. MyPy also tells the AST parser to target this specific `python_version`. So, if you're running with our minimum requirement of Python 3.5, it will fail to parse any Python 3.6+ code like f-strings, unless you specifically set `python_version` in `mypy.ini`.

We apply the same fix as above so that MyPy now also works "out of the box" with Python 3.6-only and 3.7-only codebases. If users set `python_version` in `mypy.ini`, MyPy will respect this - we only influence the default behavior.

### Result

Toolchain's Python 3.8 codebase now works "out of the box" with Pants, i.e. without extra settings. Pants's codebase, which uses Py36, also works out of ... (continued)

136 of 136 new or added lines in 9 files covered. (100.0%)

0 of 29258 relevant lines covered (0.0%)

0.0 hits per line

Jobs
ID Job ID Ran Files Coverage
4 35299.4 (PANTS_CONFIG_FILES="${TRAVIS_BUILD_DIR}/pants.travis-ci.toml" PANTS_DYNAMIC_UI=false LC_ALL="en_US.UTF-8" AWS_BUCKET=ci-public.pantsbuild.org BOOTSTRAPPED_PEX_KEY_PREFIX=daily/${TRAVIS_BUILD_NUMBER}/${TRAVIS_BUILD_ID}/pants.pex NATIVE_ENGINE_SO_KEY_PREFIX=monthly/native_engine_so PYENV_PY27_VERSION=2.7.18 PYENV_PY36_VERSION=3.6.10 PYENV_PY37_VERSION=3.7.7 PYENV_PY38_VERSION=3.8.3 PYENV_ROOT_OSX=${HOME}/.pants_pyenv PYENV_ROOT="${PYENV_ROOT:-${PYENV_ROOT_OSX}}" PATH="${PYENV_ROOT}/shims:${PATH}" AWS_CLI_ROOT="${HOME}/.aws_cli" AWS_ACCESS_KEY_ID__TO_BE_REEXPORTED_ON_DEPLOYS=AKIAV6A6G7RQ2HFZ5KP7 AWS_SECRET_ACCESS_KEY=[secure] RUST_BACKTRACE="all" BOOTSTRAPPED_PEX_KEY_SUFFIX=py36.linux PANTS_REMOTE_CA_CERTS_PATH=/usr/lib/google-cloud-sdk/lib/third_party/grpc/_cython/_credentials/roots.pem CACHE_NAME=python_tests.py36) 09 Sep 2020 06:30PM UTC 0
0.0
Travis Job 35299.4
Source Files on build 35299
Detailed source file information is not available for this build.
  • Back to Repo
  • Build #35299
  • 54b9a798 on github
  • Prev Build on master (#35298)
  • Next Build on master (#35301)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc