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

Modernize `` script to Python 3 #7631

merged 2 commits into from Apr 27, 2019


None yet
2 participants
Copy link

commented Apr 27, 2019

Because we're guaranteed to have Py3 on all wheel building shards, we can refactor this script to use modern Python 3 for improved code and to prepare for removing Python 2 from CI.

Makes these refactors:

  • Use type hints to allow scanning function signatures more easily.
  • Use f-strings, but only where more readable.
  • Remove unnecessary __future__ import.
  • Remove unnecessary file encoding header, since Python 3 assumes source files are UTF-8.
  • Use modern pathlib library for object oriented interface (see PEP 428)

@Eric-Arellano Eric-Arellano requested review from jsirois and cosmicexplorer Apr 27, 2019

@@ -39,28 +36,28 @@ def main():
.format(', '.join(sorted(parsed_abis))))

This comment has been minimized.

Copy link

Eric-Arellano Apr 27, 2019

Author Contributor

I did not use f strings here, nor two lines above, because I found it less readable to inline the ', '.join(sorted(parsed_abis)).

Alternative approach is to introduce intermediate variables.

expeccted_abis = ', '.join(sorted(parsed_abis))
success(f"Success. The pants.pex was built with wheels carrying the expected ABIs: {expected_abis}."
Fix decode
Rather than calling str(), call .decode(). Note we can leave off 'utf-8' because in Py3 decode() defaults to utf-8.

@Eric-Arellano Eric-Arellano merged commit e987845 into pantsbuild:master Apr 27, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:modernize-check-abi branch Apr 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.