Skip to content

Commit

Permalink
sorted imports statements and apply "black" formatting (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre authored Dec 29, 2021
1 parent 37e7e68 commit 5cf439d
Show file tree
Hide file tree
Showing 45 changed files with 942 additions and 662 deletions.
11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ repos:
rev: 4.0.1.1
hooks:
- id: buildifier
args: &args
args: &args
# Keep this argument in sync with .bazelci/presubmit.yaml
- --warnings=all
- id: buildifier-lint
args: *args
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
2 changes: 1 addition & 1 deletion examples/build_file_generation/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
print("hello")
print("hello")
2 changes: 2 additions & 0 deletions examples/pip_install/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import boto3


def the_dir():
return dir(boto3)


if __name__ == "__main__":
print(the_dir())
36 changes: 28 additions & 8 deletions examples/pip_install/pip_install_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3

from pathlib import Path
import os
import subprocess
import unittest
from pathlib import Path


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

proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc = subprocess.run(
[entry_point, "--version"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")

# yamllint entry_point is of the form `def run(argv=None):`
with self.assertRaises(subprocess.CalledProcessError) as context:
subprocess.run([entry_point, "--option-does-not-exist"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.assertIn('returned non-zero exit status 2', str(context.exception))
subprocess.run(
[entry_point, "--option-does-not-exist"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
self.assertIn("returned non-zero exit status 2", str(context.exception))

def test_entry_point_int_return(self):
env = os.environ.get("SPHINX_BUILD_ENTRY_POINT")
Expand All @@ -31,14 +41,24 @@ def test_entry_point_int_return(self):
entry_point = Path(env)
self.assertTrue(entry_point.exists())

proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc = subprocess.run(
[entry_point, "--version"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
# sphinx-build uses args[0] for its name, only assert the version here
self.assertTrue(proc.stdout.decode("utf-8").strip().endswith('4.2.0'))
self.assertTrue(proc.stdout.decode("utf-8").strip().endswith("4.2.0"))

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

def test_data(self):
env = os.environ.get("WHEEL_DATA_CONTENTS")
Expand Down
7 changes: 5 additions & 2 deletions examples/pip_install/test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import unittest

import main


class ExampleTest(unittest.TestCase):
def test_main(self):
self.assertIn("set_stream_logger", main.the_dir())

if __name__ == '__main__':
unittest.main()

if __name__ == "__main__":
unittest.main()
36 changes: 28 additions & 8 deletions examples/pip_parse/pip_parse_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3

from pathlib import Path
import os
import subprocess
import unittest
from pathlib import Path


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

proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc = subprocess.run(
[entry_point, "--version"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")

# yamllint entry_point is of the form `def run(argv=None):`
with self.assertRaises(subprocess.CalledProcessError) as context:
subprocess.run([entry_point, "--option-does-not-exist"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.assertIn('returned non-zero exit status 2', str(context.exception))
subprocess.run(
[entry_point, "--option-does-not-exist"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
self.assertIn("returned non-zero exit status 2", str(context.exception))

def test_entry_point_int_return(self):
env = os.environ.get("SPHINX_BUILD_ENTRY_POINT")
Expand All @@ -31,14 +41,24 @@ def test_entry_point_int_return(self):
entry_point = Path(env)
self.assertTrue(entry_point.exists())

proc = subprocess.run([entry_point, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc = subprocess.run(
[entry_point, "--version"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
# sphinx-build uses args[0] for its name, only assert the version here
self.assertTrue(proc.stdout.decode("utf-8").strip().endswith('4.2.0'))
self.assertTrue(proc.stdout.decode("utf-8").strip().endswith("4.2.0"))

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

def test_data(self):
env = os.environ.get("WHEEL_DATA_CONTENTS")
Expand Down
3 changes: 2 additions & 1 deletion examples/pip_parse/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import main


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


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
41 changes: 20 additions & 21 deletions examples/py_import/py_import_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,23 @@


class HelloWorldTest(unittest.TestCase):

def test_helloworld(self):
hw = helloworld.HelloWorld()
hw.SayHello()

def test_helloworld_async(self):
hw = helloworld.HelloWorld()
hw.SayHelloAsync()
hw.Stop()

def test_helloworld_multiple(self):
hw = helloworld.HelloWorld()
hw.SayHelloAsync()
hw.SayHelloAsync()
hw.SayHelloAsync()
hw.SayHelloAsync()
hw.Stop()


if __name__ == '__main__':
unittest.main()
def test_helloworld(self):
hw = helloworld.HelloWorld()
hw.SayHello()

def test_helloworld_async(self):
hw = helloworld.HelloWorld()
hw.SayHelloAsync()
hw.Stop()

def test_helloworld_multiple(self):
hw = helloworld.HelloWorld()
hw.SayHelloAsync()
hw.SayHelloAsync()
hw.SayHelloAsync()
hw.SayHelloAsync()
hw.Stop()


if __name__ == "__main__":
unittest.main()
6 changes: 3 additions & 3 deletions examples/relative_requirements/relative_package/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup

setup(
name='relative_package_name',
version='1.0.0',
packages=['relative_package_name'],
name="relative_package_name",
version="1.0.0",
packages=["relative_package_name"],
)
1 change: 1 addition & 0 deletions examples/wheel/lib/module_with_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


def function():
return "foo"
1 change: 1 addition & 0 deletions examples/wheel/lib/simple_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


def function():
return "bar"
2 changes: 1 addition & 1 deletion examples/wheel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ def main():
print(simple_module.function())


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading

0 comments on commit 5cf439d

Please sign in to comment.