Skip to content

Commit 5cf439d

Browse files
authored
sorted imports statements and apply "black" formatting (bazel-contrib#583)
1 parent 37e7e68 commit 5cf439d

File tree

45 files changed

+942
-662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+942
-662
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ repos:
66
rev: 4.0.1.1
77
hooks:
88
- id: buildifier
9-
args: &args
9+
args: &args
1010
# Keep this argument in sync with .bazelci/presubmit.yaml
1111
- --warnings=all
1212
- id: buildifier-lint
1313
args: *args
14+
- repo: https://github.com/pycqa/isort
15+
rev: 5.10.1
16+
hooks:
17+
- id: isort
18+
name: isort (python)
19+
- repo: https://github.com/psf/black
20+
rev: 21.12b0
21+
hooks:
22+
- id: black
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
print("hello")
1+
print("hello")

examples/pip_install/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import boto3
22

3+
34
def the_dir():
45
return dir(boto3)
56

7+
68
if __name__ == "__main__":
79
print(the_dir())

examples/pip_install/pip_install_test.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python3
22

3-
from pathlib import Path
43
import os
54
import subprocess
65
import unittest
6+
from pathlib import Path
77

88

99
class PipInstallTest(unittest.TestCase):
@@ -16,13 +16,23 @@ def test_entry_point_void_return(self):
1616
entry_point = Path(env)
1717
self.assertTrue(entry_point.exists())
1818

19-
proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
19+
proc = subprocess.run(
20+
[entry_point, "--version"],
21+
check=True,
22+
stdout=subprocess.PIPE,
23+
stderr=subprocess.PIPE,
24+
)
2025
self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")
2126

2227
# yamllint entry_point is of the form `def run(argv=None):`
2328
with self.assertRaises(subprocess.CalledProcessError) as context:
24-
subprocess.run([entry_point, "--option-does-not-exist"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
25-
self.assertIn('returned non-zero exit status 2', str(context.exception))
29+
subprocess.run(
30+
[entry_point, "--option-does-not-exist"],
31+
check=True,
32+
stdout=subprocess.PIPE,
33+
stderr=subprocess.PIPE,
34+
)
35+
self.assertIn("returned non-zero exit status 2", str(context.exception))
2636

2737
def test_entry_point_int_return(self):
2838
env = os.environ.get("SPHINX_BUILD_ENTRY_POINT")
@@ -31,14 +41,24 @@ def test_entry_point_int_return(self):
3141
entry_point = Path(env)
3242
self.assertTrue(entry_point.exists())
3343

34-
proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
44+
proc = subprocess.run(
45+
[entry_point, "--version"],
46+
check=True,
47+
stdout=subprocess.PIPE,
48+
stderr=subprocess.PIPE,
49+
)
3550
# sphinx-build uses args[0] for its name, only assert the version here
36-
self.assertTrue(proc.stdout.decode("utf-8").strip().endswith('4.2.0'))
51+
self.assertTrue(proc.stdout.decode("utf-8").strip().endswith("4.2.0"))
3752

3853
# sphinx-build entry_point is of the form `def main(argv: List[str] = sys.argv[1:]) -> int:`
3954
with self.assertRaises(subprocess.CalledProcessError) as context:
40-
subprocess.run([entry_point, "--option-does-not-exist"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
41-
self.assertIn('returned non-zero exit status 2', str(context.exception))
55+
subprocess.run(
56+
[entry_point, "--option-does-not-exist"],
57+
check=True,
58+
stdout=subprocess.PIPE,
59+
stderr=subprocess.PIPE,
60+
)
61+
self.assertIn("returned non-zero exit status 2", str(context.exception))
4262

4363
def test_data(self):
4464
env = os.environ.get("WHEEL_DATA_CONTENTS")

examples/pip_install/test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import unittest
2+
23
import main
34

5+
46
class ExampleTest(unittest.TestCase):
57
def test_main(self):
68
self.assertIn("set_stream_logger", main.the_dir())
79

8-
if __name__ == '__main__':
9-
unittest.main()
10+
11+
if __name__ == "__main__":
12+
unittest.main()

examples/pip_parse/pip_parse_test.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python3
22

3-
from pathlib import Path
43
import os
54
import subprocess
65
import unittest
6+
from pathlib import Path
77

88

99
class PipInstallTest(unittest.TestCase):
@@ -16,13 +16,23 @@ def test_entry_point_void_return(self):
1616
entry_point = Path(env)
1717
self.assertTrue(entry_point.exists())
1818

19-
proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
19+
proc = subprocess.run(
20+
[entry_point, "--version"],
21+
check=True,
22+
stdout=subprocess.PIPE,
23+
stderr=subprocess.PIPE,
24+
)
2025
self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")
2126

2227
# yamllint entry_point is of the form `def run(argv=None):`
2328
with self.assertRaises(subprocess.CalledProcessError) as context:
24-
subprocess.run([entry_point, "--option-does-not-exist"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
25-
self.assertIn('returned non-zero exit status 2', str(context.exception))
29+
subprocess.run(
30+
[entry_point, "--option-does-not-exist"],
31+
check=True,
32+
stdout=subprocess.PIPE,
33+
stderr=subprocess.PIPE,
34+
)
35+
self.assertIn("returned non-zero exit status 2", str(context.exception))
2636

2737
def test_entry_point_int_return(self):
2838
env = os.environ.get("SPHINX_BUILD_ENTRY_POINT")
@@ -31,14 +41,24 @@ def test_entry_point_int_return(self):
3141
entry_point = Path(env)
3242
self.assertTrue(entry_point.exists())
3343

34-
proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
44+
proc = subprocess.run(
45+
[entry_point, "--version"],
46+
check=True,
47+
stdout=subprocess.PIPE,
48+
stderr=subprocess.PIPE,
49+
)
3550
# sphinx-build uses args[0] for its name, only assert the version here
36-
self.assertTrue(proc.stdout.decode("utf-8").strip().endswith('4.2.0'))
51+
self.assertTrue(proc.stdout.decode("utf-8").strip().endswith("4.2.0"))
3752

3853
# sphinx-build entry_point is of the form `def main(argv: List[str] = sys.argv[1:]) -> int:`
3954
with self.assertRaises(subprocess.CalledProcessError) as context:
40-
subprocess.run([entry_point, "--option-does-not-exist"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
41-
self.assertIn('returned non-zero exit status 2', str(context.exception))
55+
subprocess.run(
56+
[entry_point, "--option-does-not-exist"],
57+
check=True,
58+
stdout=subprocess.PIPE,
59+
stderr=subprocess.PIPE,
60+
)
61+
self.assertIn("returned non-zero exit status 2", str(context.exception))
4262

4363
def test_data(self):
4464
env = os.environ.get("WHEEL_DATA_CONTENTS")

examples/pip_parse/test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
23
import main
34

45

@@ -7,5 +8,5 @@ def test_main(self):
78
self.assertEqual("2.25.1", main.version())
89

910

10-
if __name__ == '__main__':
11+
if __name__ == "__main__":
1112
unittest.main()

examples/py_import/py_import_test.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@
1818

1919

2020
class HelloWorldTest(unittest.TestCase):
21-
22-
def test_helloworld(self):
23-
hw = helloworld.HelloWorld()
24-
hw.SayHello()
25-
26-
def test_helloworld_async(self):
27-
hw = helloworld.HelloWorld()
28-
hw.SayHelloAsync()
29-
hw.Stop()
30-
31-
def test_helloworld_multiple(self):
32-
hw = helloworld.HelloWorld()
33-
hw.SayHelloAsync()
34-
hw.SayHelloAsync()
35-
hw.SayHelloAsync()
36-
hw.SayHelloAsync()
37-
hw.Stop()
38-
39-
40-
if __name__ == '__main__':
41-
unittest.main()
21+
def test_helloworld(self):
22+
hw = helloworld.HelloWorld()
23+
hw.SayHello()
24+
25+
def test_helloworld_async(self):
26+
hw = helloworld.HelloWorld()
27+
hw.SayHelloAsync()
28+
hw.Stop()
29+
30+
def test_helloworld_multiple(self):
31+
hw = helloworld.HelloWorld()
32+
hw.SayHelloAsync()
33+
hw.SayHelloAsync()
34+
hw.SayHelloAsync()
35+
hw.SayHelloAsync()
36+
hw.Stop()
37+
38+
39+
if __name__ == "__main__":
40+
unittest.main()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup
22

33
setup(
4-
name='relative_package_name',
5-
version='1.0.0',
6-
packages=['relative_package_name'],
4+
name="relative_package_name",
5+
version="1.0.0",
6+
packages=["relative_package_name"],
77
)

examples/wheel/lib/module_with_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
1516
def function():
1617
return "foo"

examples/wheel/lib/simple_module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
1516
def function():
1617
return "bar"

examples/wheel/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ def main():
2626
print(simple_module.function())
2727

2828

29-
if __name__ == '__main__':
29+
if __name__ == "__main__":
3030
main()

0 commit comments

Comments
 (0)