-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify script to check
__init__.py
files (#10488)
Now that we only have empty `__init__.py`, we can simplify our script to simply check that all files are empty. This also simplifies the test for `reversion_test.py` to no longer run Pants, which allows us to move the script to its proper home in `build-support/bin`. [ci skip-rust] [ci skip-build-wheels]
- Loading branch information
1 parent
6f48083
commit 659780e
Showing
20 changed files
with
100 additions
and
416 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
import itertools | ||
from pathlib import Path | ||
|
||
from common import die | ||
|
||
DIRS_TO_CHECK = ( | ||
"src", | ||
"tests", | ||
"pants-plugins", | ||
"examples", | ||
"build-support/bin", | ||
"build-support/migration-support", | ||
) | ||
|
||
|
||
def main() -> None: | ||
files = itertools.chain.from_iterable( | ||
[Path().glob(f"{d}/**/__init__.py") for d in DIRS_TO_CHECK] | ||
) | ||
bad_inits = [f for f in files if bool(f.read_text())] | ||
if bad_inits: | ||
die( | ||
"All `__init__.py` file should be empty, but the following had content: " | ||
f"{', '.join(str(f) for f in bad_inits)}" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
import os | ||
import shutil | ||
|
||
import requests | ||
from pex.bin import pex as pex_main | ||
from reversion import create_parser, reversion | ||
|
||
from pants.util.contextutil import temporary_dir | ||
|
||
|
||
def test_reversion() -> None: | ||
with temporary_dir() as dest_dir: | ||
# Download an input whl. | ||
name_template = "virtualenv-{}-py2.py3-none-any.whl" | ||
input_name = name_template.format("15.1.0") | ||
url = ( | ||
"https://files.pythonhosted.org/packages/6f/86/" | ||
"3dc328ee7b1a6419ebfac7896d882fba83c48e3561d22ddddf38294d3e83/{}".format(input_name) | ||
) | ||
input_whl_file = os.path.join(dest_dir, input_name) | ||
with open(input_whl_file, "wb") as f: | ||
shutil.copyfileobj(requests.get(url, stream=True).raw, f) | ||
|
||
# Rewrite it. | ||
output_version = "9.1.9" | ||
output_name = name_template.format(output_version) | ||
output_whl_file = os.path.join(dest_dir, output_name) | ||
|
||
args = create_parser().parse_args([input_whl_file, dest_dir, output_version]) | ||
reversion(args) | ||
|
||
assert os.path.isfile(output_whl_file) is True | ||
|
||
# Confirm that it can be consumed. | ||
output_pex_file = os.path.join(dest_dir, "out.pex") | ||
pex_main.main(["--disable-cache", "-o", output_pex_file, output_whl_file]) | ||
assert os.path.isfile(output_pex_file) is True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.