Skip to content

Commit 55af3eb

Browse files
authored
refactor: Run isort and black on all python files (#1859)
Run `isort` and `black` on all python files so that the pre-commit hooks do not fail anymore. It seems like most of the issues were quotation marks and vertical whitespace. Fixes #1674.
1 parent afae3f0 commit 55af3eb

File tree

54 files changed

+102
-66
lines changed

Some content is hidden

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

54 files changed

+102
-66
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions

examples/build_file_generation/__init__.py

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

15+
import sphinx # noqa
1516
from flask import Flask, jsonify
1617
from random_number_generator import generate_random_number
17-
import sphinx # noqa
1818

1919
app = Flask(__name__)
2020

21-
@app.route('/random-number', methods=['GET'])
21+
22+
@app.route("/random-number", methods=["GET"])
2223
def get_random_number():
23-
return jsonify({'number': generate_random_number.generate_random_number()})
24+
return jsonify({"number": generate_random_number.generate_random_number()})
25+
2426

25-
"""Start the python web server"""
2627
def main():
28+
"""Start the python web server"""
2729
app.run()

examples/build_file_generation/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414

1515
from __init__ import main
1616

17-
if __name__ == '__main__':
17+
if __name__ == "__main__":
1818
main()

examples/build_file_generation/__test__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@
1313
# limitations under the License.
1414

1515
import unittest
16+
1617
from __init__ import app
1718

19+
1820
class TestServer(unittest.TestCase):
1921
def setUp(self):
2022
self.app = app.test_client()
21-
23+
2224
def test_get_random_number(self):
23-
response = self.app.get('/random-number')
25+
response = self.app.get("/random-number")
2426
self.assertEqual(response.status_code, 200)
25-
self.assertIn('number', response.json)
26-
27-
if __name__ == '__main__':
27+
self.assertIn("number", response.json)
28+
29+
30+
if __name__ == "__main__":
2831
unittest.main()

examples/build_file_generation/random_number_generator/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-

examples/build_file_generation/random_number_generator/__test__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
# limitations under the License.
1414

1515
import unittest
16+
1617
import random_number_generator.generate_random_number as generate_random_number
1718

19+
1820
class TestRandomNumberGenerator(unittest.TestCase):
1921
def test_generate_random_number(self):
2022
number = generate_random_number.generate_random_number()
2123
self.assertGreaterEqual(number, 1)
2224
self.assertLessEqual(number, 10)
23-
24-
if __name__ == '__main__':
25+
26+
27+
if __name__ == "__main__":
2528
unittest.main()

examples/build_file_generation/random_number_generator/generate_random_number.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import random
1616

17-
"""Generate a random number"""
17+
1818
def generate_random_number():
19+
"""Generate a random number"""
1920
return random.randint(1, 10)

examples/bzlmod/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from lib import main
1615
import sys
1716

17+
from lib import main
18+
1819
if __name__ == "__main__":
1920
print(main([["A", 1], ["B", 2]]))
2021
print(sys.version)

examples/bzlmod/lib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from tabulate import tabulate
1615
import sphinx # noqa
16+
from tabulate import tabulate
17+
1718

1819
def main(table):
1920
return tabulate(table)

examples/bzlmod_build_file_generation/runfiles/runfiles_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def testCurrentRepository(self):
2626
self.assertEqual(runfiles.Create().CurrentRepository(), "")
2727

2828
def testRunfilesWithRepoMapping(self):
29-
data_path = runfiles.Create().Rlocation("example_bzlmod_build_file_generation/runfiles/data/data.txt")
29+
data_path = runfiles.Create().Rlocation(
30+
"example_bzlmod_build_file_generation/runfiles/data/data.txt"
31+
)
3032
with open(data_path) as f:
3133
self.assertEqual(f.read().strip(), "Hello, example_bzlmod!")
3234

examples/multi_python_versions/tests/my_lib_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
if not my_lib.websockets_is_for_python_version(
2424
workspace_version
2525
) and not my_lib.websockets_is_for_python_version(bzlmod_version):
26-
print("expected package for Python version is different than returned\n"
27-
f"expected either {workspace_version} or {bzlmod_version}\n"
28-
f"but got {my_lib.websockets.__file__}")
26+
print(
27+
"expected package for Python version is different than returned\n"
28+
f"expected either {workspace_version} or {bzlmod_version}\n"
29+
f"but got {my_lib.websockets.__file__}"
30+
)
2931
sys.exit(1)

examples/pip_parse/pip_parse_test.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ class PipInstallTest(unittest.TestCase):
2828
def _remove_leading_dirs(self, paths):
2929
# Removes the first two directories (external/<reponame>)
3030
# to normalize what workspace and bzlmod produce.
31-
return [
32-
'/'.join(v.split('/')[2:])
33-
for v in paths
34-
]
31+
return ["/".join(v.split("/")[2:]) for v in paths]
3532

3633
def test_entry_point(self):
3734
entry_point_path = os.environ.get("YAMLLINT_ENTRY_POINT")

examples/py_proto_library/message_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
from another_proto import message_pb2
55

6+
67
class TestCase(unittest.TestCase):
78
def test_message(self):
89
got = message_pb2.TestMessage(
9-
index = 5,
10+
index=5,
1011
)
1112
self.assertIsNotNone(got)
1213

1314

1415
if __name__ == "__main__":
15-
sys.exit(unittest.main())
16+
sys.exit(unittest.main())

examples/wheel/private/directory_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def main() -> None:
4848

4949
args.output.mkdir(parents=True, exist_ok=True)
5050

51-
for (path, content) in args.files:
51+
for path, content in args.files:
5252
new_file = args.output / path
5353
new_file.parent.mkdir(parents=True, exist_ok=True)
5454
new_file.write_text(content)

examples/wheel/wheel_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def assertAllEntriesHasReproducibleMetadata(self, zf):
6262
self.assertEqual(
6363
zinfo.external_attr,
6464
(stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO | stat.S_IFREG) << 16,
65-
msg=zinfo.filename
65+
msg=zinfo.filename,
6666
)
6767
self.assertEqual(
6868
zinfo.compress_type, zipfile.ZIP_DEFLATED, msg=zinfo.filename
@@ -486,7 +486,7 @@ def test_minimal_data_files(self):
486486
"minimal_data_files-0.0.1.data/data/target/path/README.md",
487487
"minimal_data_files-0.0.1.data/scripts/NOTICE",
488488
"minimal_data_files-0.0.1.dist-info/RECORD",
489-
]
489+
],
490490
)
491491

492492

gazelle/manifest/copy_to_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def copy_to_source(generated_relative_path: Path, target_relative_path: Path) ->
2626
target_absolute_path.parent.mkdir(parents=True, exist_ok=True)
2727
shutil.copy(generated_absolute_path, target_absolute_path)
2828

29-
target_absolute_path.chmod(0O664)
29+
target_absolute_path.chmod(0o664)
3030

3131

3232
if __name__ == "__main__":

gazelle/python/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def parse_main(content):
7373
if token_type != OP or token_val != "==":
7474
continue
7575
token_type, token_val, start, _, _ = next(g)
76-
if token_type != STRING or token_val.strip("\"'") != '__main__':
76+
if token_type != STRING or token_val.strip("\"'") != "__main__":
7777
continue
7878
token_type, token_val, start, _, _ = next(g)
7979
if token_type != OP or token_val != ":":

gazelle/python/parse_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import unittest
2+
23
import parse
34

5+
46
class TestParse(unittest.TestCase):
57
def test_not_has_main(self):
68
content = "a = 1\nb = 2"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import numpy
22

33
if __name__ == "__main__":
4-
run()
4+
run()

gazelle/python/testdata/binary_without_entrypoint/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
import pandas
33

44
if __name__ == "__main__":
5-
run()
5+
run()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import unittest
22

3+
34
class TestMain(unittest.unittest):
45
pass
56

7+
68
if __name__ == "__main__":
79
unittest.main()

gazelle/python/testdata/dont_rename_target/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-

gazelle/python/testdata/first_party_file_and_directory_modules/baz.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 baz():
1617
return "baz from baz.py"

gazelle/python/testdata/first_party_file_and_directory_modules/foo.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 foo():
1617
print("foo")

gazelle/python/testdata/first_party_file_and_directory_modules/one/two.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 two():
1617
return "two"

gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.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 find_me():
1617
return "found"

gazelle/python/testdata/generated_test_entrypoint/foo.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 foo():
1617
return "foo"

gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-

gazelle/python/testdata/naming_convention/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414

1515
# For test purposes only.
16-
import __init__
16+
import __init__

gazelle/python/testdata/naming_convention/__test__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414

1515
# For test purposes only.
16-
import __init__
16+
import __init__

gazelle/python/testdata/naming_convention/dont_rename/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414

1515
# For test purposes only.
16-
import __init__
16+
import __init__

gazelle/python/testdata/naming_convention/dont_rename/__test__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414

1515
# For test purposes only.
16-
import __init__
16+
import __init__

gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414

1515
# For test purposes only.
16-
import __init__
16+
import __init__

gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414

1515
# For test purposes only.
16-
import __init__
16+
import __init__

gazelle/python/testdata/per_file_subdirs/bar/foo.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 func():
1617
pass

gazelle/python/testdata/python_target_with_test_in_name/real_test.py

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

15-
import boto3
1615
import __init__
16+
import boto3
1717

1818
_ = boto3

gazelle/python/testdata/python_target_with_test_in_name/test_reality.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414

1515
# For test purposes only.
16-
import __init__
16+
import __init__

gazelle/python/testdata/relative_imports/package1/module2.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 function2():
1617
return "function2"

gazelle/python/testdata/relative_imports/package2/__init__.py

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

15+
1516
class Class1:
1617
def method1(self):
1718
return "method1"

gazelle/python/testdata/relative_imports/package2/module3.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import resolved_package
16+
1517
from . import Class1
1618
from .subpackage1.module5 import function5
1719

18-
import resolved_package
1920

2021
def function3():
2122
c1 = Class1()

gazelle/python/testdata/relative_imports/package2/module4.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 function4():
1617
return "function4"

0 commit comments

Comments
 (0)