Skip to content

Commit 0c7b033

Browse files
holtskinnerparthea
andauthored
chore: [autoapprove] Update black and isort to latest versions (#1811)
fix: Update `black` and `isort` to latest versions - Add `black[jupyter]` because several samples directories include jupyter notebooks - Add type hinting to avoid lint errors/warnings Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent b7858ba commit 0c7b033

File tree

4 files changed

+66
-62
lines changed

4 files changed

+66
-62
lines changed

synthtool/gcp/templates/python_library/.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
- id: end-of-file-fixer
2323
- id: check-yaml
2424
- repo: https://github.com/psf/black
25-
rev: 22.3.0
25+
rev: 23.7.0
2626
hooks:
2727
- id: black
2828
- repo: https://github.com/pycqa/flake8

synthtool/gcp/templates/python_library/noxfile.py.j2

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@
1717
# Generated by synthtool. DO NOT EDIT!
1818

1919
from __future__ import absolute_import
20+
2021
import os
2122
import pathlib
2223
import re
2324
import shutil
25+
from typing import Dict, List
2426
import warnings
2527

2628
import nox
2729

2830
FLAKE8_VERSION = "flake8==6.1.0"
29-
BLACK_VERSION = "black==22.3.0"
30-
ISORT_VERSION = "isort==5.10.1"
31+
BLACK_VERSION = "black[jupyter]==23.7.0"
32+
ISORT_VERSION = "isort==5.11.0"
3133
LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
3234

3335
DEFAULT_PYTHON_VERSION = "{{ default_python_version }}"
3436

35-
UNIT_TEST_PYTHON_VERSIONS = [{% for v in unit_test_python_versions %}"{{v}}"{% if not loop.last %}, {% endif %}{% endfor %}]
37+
UNIT_TEST_PYTHON_VERSIONS: List[str] = [{% for v in unit_test_python_versions %}"{{v}}"{% if not loop.last %}, {% endif %}{% endfor %}]
3638
UNIT_TEST_STANDARD_DEPENDENCIES = [
3739
"mock",
3840
"asyncmock",
@@ -41,89 +43,89 @@ UNIT_TEST_STANDARD_DEPENDENCIES = [
4143
"pytest-asyncio",
4244
]
4345
{%- if unit_test_external_dependencies %}
44-
UNIT_TEST_EXTERNAL_DEPENDENCIES = [{% for v in unit_test_external_dependencies %}
46+
UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = [{% for v in unit_test_external_dependencies %}
4547
"{{v}}",{% endfor %}
4648
]
4749
{%- else %}
48-
UNIT_TEST_EXTERNAL_DEPENDENCIES = []
50+
UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
4951
{%- endif %}
5052
{%- if unit_test_local_dependencies %}
51-
UNIT_TEST_LOCAL_DEPENDENCIES = [{% for v in unit_test_local_dependencies %}
53+
UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = [{% for v in unit_test_local_dependencies %}
5254
"{{v}}",{% endfor %}
5355
]
5456
{%- else %}
55-
UNIT_TEST_LOCAL_DEPENDENCIES = []
57+
UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = []
5658
{%- endif %}
5759
{%- if unit_test_dependencies %}
58-
UNIT_TEST_DEPENDENCIES = [{% for v in unit_test_dependencies %}
60+
UNIT_TEST_DEPENDENCIES: List[str] = [{% for v in unit_test_dependencies %}
5961
"{{v}}",{% endfor %}
6062
]
6163
{%- else %}
62-
UNIT_TEST_DEPENDENCIES = []
64+
UNIT_TEST_DEPENDENCIES: List[str] = []
6365
{%- endif %}
6466
{%- if unit_test_extras %}
65-
UNIT_TEST_EXTRAS = [{% for v in unit_test_extras %}
67+
UNIT_TEST_EXTRAS: List[str] = [{% for v in unit_test_extras %}
6668
"{{v}}",{% endfor %}
6769
]
6870
{%- else %}
69-
UNIT_TEST_EXTRAS = []
71+
UNIT_TEST_EXTRAS: List[str] = []
7072
{%- endif %}
7173

7274
{%- if unit_test_extras_by_python %}
73-
UNIT_TEST_EXTRAS_BY_PYTHON = {{ '{' }}{% if unit_test_extras_by_python %}{% for python_version, extras in unit_test_extras_by_python.items() %}
75+
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {{ '{' }}{% if unit_test_extras_by_python %}{% for python_version, extras in unit_test_extras_by_python.items() %}
7476
"{{python_version}}": [{% for v in extras %}
7577
"{{v}}",{% endfor %}
7678
],{% endfor %}{% endif %}
7779
}
7880
{%- else %}
79-
UNIT_TEST_EXTRAS_BY_PYTHON = {}
81+
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}
8082
{%- endif %}
8183
{% if system_test_python_versions %}
82-
SYSTEM_TEST_PYTHON_VERSIONS = [{% for v in system_test_python_versions %}"{{v}}"{% if not loop.last %}, {% endif %}{% endfor %}]
84+
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = [{% for v in system_test_python_versions %}"{{v}}"{% if not loop.last %}, {% endif %}{% endfor %}]
8385
{%- else %}
84-
SYSTEM_TEST_PYTHON_VERSIONS = []
86+
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = []
8587
{%- endif %}
86-
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
88+
SYSTEM_TEST_STANDARD_DEPENDENCIES: List[str] = [
8789
"mock",
8890
"pytest",
8991
"google-cloud-testutils",
9092
]
9193
{%- if system_test_external_dependencies %}
92-
SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [{% for v in system_test_external_dependencies %}
94+
SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = [{% for v in system_test_external_dependencies %}
9395
"{{v}}",{% endfor %}
9496
]
9597
{%- else %}
96-
SYSTEM_TEST_EXTERNAL_DEPENDENCIES = []
98+
SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
9799
{%- endif %}
98100
{%- if system_test_local_dependencies %}
99-
SYSTEM_TEST_LOCAL_DEPENDENCIES = [{% for v in system_test_local_dependencies %}
101+
SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [{% for v in system_test_local_dependencies %}
100102
"{{v}}",{% endfor %}
101103
]
102104
{%- else %}
103-
SYSTEM_TEST_LOCAL_DEPENDENCIES = []
105+
SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = []
104106
{%- endif %}
105107
{%- if system_test_dependencies %}
106-
SYSTEM_TEST_DEPENDENCIES = [{% for v in system_test_dependencies %}
108+
SYSTEM_TEST_DEPENDENCIES: List[str] = [{% for v in system_test_dependencies %}
107109
"{{v}}",{% endfor %}
108110
]
109111
{%- else %}
110-
SYSTEM_TEST_DEPENDENCIES = []
112+
SYSTEM_TEST_DEPENDENCIES: List[str] = []
111113
{%- endif %}
112114
{%- if system_test_extras %}
113-
SYSTEM_TEST_EXTRAS = [{% for v in system_test_extras %}
115+
SYSTEM_TEST_EXTRAS: List[str] = [{% for v in system_test_extras %}
114116
"{{v}}",{% endfor %}
115117
]
116118
{%- else %}
117-
SYSTEM_TEST_EXTRAS = []
119+
SYSTEM_TEST_EXTRAS: List[str] = []
118120
{%- endif %}
119121
{%- if system_test_extras_by_python %}
120-
SYSTEM_TEST_EXTRAS_BY_PYTHON = {{ '{' }}{% if system_test_extras_by_python %}{% for python_version, extras in system_test_extras_by_python.items() %}
122+
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {{ '{' }}{% if system_test_extras_by_python %}{% for python_version, extras in system_test_extras_by_python.items() %}
121123
"{{python_version}}": [{% for v in extras %}
122124
"{{v}}",{% endfor %}
123125
],{% endfor %}{% endif %}
124126
}
125127
{%- else %}
126-
SYSTEM_TEST_EXTRAS_BY_PYTHON = {}
128+
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}
127129
{%- endif %}
128130

129131
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
@@ -137,6 +139,7 @@ nox.options.sessions = [
137139
"lint_setup_py",
138140
"blacken",
139141
"docs",
142+
"format",
140143
]
141144

142145
# Error if a python version is missing

synthtool/gcp/templates/python_mono_repo_library/noxfile.py.j2

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ import os
2121
import pathlib
2222
import re
2323
import shutil
24+
from typing import Dict, List
2425
import warnings
2526

2627
import nox
2728

28-
BLACK_VERSION = "black==22.3.0"
29-
ISORT_VERSION = "isort==5.10.1"
29+
BLACK_VERSION = "black[jupyter]==23.7.0"
30+
ISORT_VERSION = "isort==5.11.0"
3031
LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
3132

3233
DEFAULT_PYTHON_VERSION = "{{ default_python_version }}"
3334

34-
UNIT_TEST_PYTHON_VERSIONS = [{% for v in unit_test_python_versions %}"{{v}}"{% if not loop.last %}, {% endif %}{% endfor %}]
35+
UNIT_TEST_PYTHON_VERSIONS: List[str] = [{% for v in unit_test_python_versions %}"{{v}}"{% if not loop.last %}, {% endif %}{% endfor %}]
3536
UNIT_TEST_STANDARD_DEPENDENCIES = [
3637
"mock",
3738
"asyncmock",
@@ -40,89 +41,89 @@ UNIT_TEST_STANDARD_DEPENDENCIES = [
4041
"pytest-asyncio",
4142
]
4243
{%- if unit_test_external_dependencies %}
43-
UNIT_TEST_EXTERNAL_DEPENDENCIES = [{% for v in unit_test_external_dependencies %}
44+
UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = [{% for v in unit_test_external_dependencies %}
4445
"{{v}}",{% endfor %}
4546
]
4647
{%- else %}
47-
UNIT_TEST_EXTERNAL_DEPENDENCIES = []
48+
UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
4849
{%- endif %}
4950
{%- if unit_test_local_dependencies %}
50-
UNIT_TEST_LOCAL_DEPENDENCIES = [{% for v in unit_test_local_dependencies %}
51+
UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = [{% for v in unit_test_local_dependencies %}
5152
"{{v}}",{% endfor %}
5253
]
5354
{%- else %}
54-
UNIT_TEST_LOCAL_DEPENDENCIES = []
55+
UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = []
5556
{%- endif %}
5657
{%- if unit_test_dependencies %}
57-
UNIT_TEST_DEPENDENCIES = [{% for v in unit_test_dependencies %}
58+
UNIT_TEST_DEPENDENCIES: List[str] = [{% for v in unit_test_dependencies %}
5859
"{{v}}",{% endfor %}
5960
]
6061
{%- else %}
61-
UNIT_TEST_DEPENDENCIES = []
62+
UNIT_TEST_DEPENDENCIES: List[str] = []
6263
{%- endif %}
6364
{%- if unit_test_extras %}
64-
UNIT_TEST_EXTRAS = [{% for v in unit_test_extras %}
65+
UNIT_TEST_EXTRAS: List[str] = [{% for v in unit_test_extras %}
6566
"{{v}}",{% endfor %}
6667
]
6768
{%- else %}
68-
UNIT_TEST_EXTRAS = []
69+
UNIT_TEST_EXTRAS: List[str] = []
6970
{%- endif %}
7071

7172
{%- if unit_test_extras_by_python %}
72-
UNIT_TEST_EXTRAS_BY_PYTHON = {{ '{' }}{% if unit_test_extras_by_python %}{% for python_version, extras in unit_test_extras_by_python.items() %}
73+
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {{ '{' }}{% if unit_test_extras_by_python %}{% for python_version, extras in unit_test_extras_by_python.items() %}
7374
"{{python_version}}": [{% for v in extras %}
7475
"{{v}}",{% endfor %}
7576
],{% endfor %}{% endif %}
7677
}
7778
{%- else %}
78-
UNIT_TEST_EXTRAS_BY_PYTHON = {}
79+
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}
7980
{%- endif %}
8081
{% if system_test_python_versions %}
81-
SYSTEM_TEST_PYTHON_VERSIONS = [{% for v in system_test_python_versions %}"{{v}}"{% if not loop.last %}, {% endif %}{% endfor %}]
82+
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = [{% for v in system_test_python_versions %}"{{v}}"{% if not loop.last %}, {% endif %}{% endfor %}]
8283
{%- else %}
83-
SYSTEM_TEST_PYTHON_VERSIONS = []
84+
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = []
8485
{%- endif %}
8586
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
8687
"mock",
8788
"pytest",
8889
"google-cloud-testutils",
8990
]
9091
{%- if system_test_external_dependencies %}
91-
SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [{% for v in system_test_external_dependencies %}
92+
SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = [{% for v in system_test_external_dependencies %}
9293
"{{v}}",{% endfor %}
9394
]
9495
{%- else %}
95-
SYSTEM_TEST_EXTERNAL_DEPENDENCIES = []
96+
SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
9697
{%- endif %}
9798
{%- if system_test_local_dependencies %}
98-
SYSTEM_TEST_LOCAL_DEPENDENCIES = [{% for v in system_test_local_dependencies %}
99+
SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [{% for v in system_test_local_dependencies %}
99100
"{{v}}",{% endfor %}
100101
]
101102
{%- else %}
102-
SYSTEM_TEST_LOCAL_DEPENDENCIES = []
103+
SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = []
103104
{%- endif %}
104105
{%- if system_test_dependencies %}
105-
SYSTEM_TEST_DEPENDENCIES = [{% for v in system_test_dependencies %}
106+
SYSTEM_TEST_DEPENDENCIES: List[str] = [{% for v in system_test_dependencies %}
106107
"{{v}}",{% endfor %}
107108
]
108109
{%- else %}
109-
SYSTEM_TEST_DEPENDENCIES = []
110+
SYSTEM_TEST_DEPENDENCIES: List[str] = []
110111
{%- endif %}
111112
{%- if system_test_extras %}
112-
SYSTEM_TEST_EXTRAS = [{% for v in system_test_extras %}
113+
SYSTEM_TEST_EXTRAS: List[str] = [{% for v in system_test_extras %}
113114
"{{v}}",{% endfor %}
114115
]
115116
{%- else %}
116-
SYSTEM_TEST_EXTRAS = []
117+
SYSTEM_TEST_EXTRAS: List[str] = []
117118
{%- endif %}
118119
{%- if system_test_extras_by_python %}
119-
SYSTEM_TEST_EXTRAS_BY_PYTHON = {{ '{' }}{% if system_test_extras_by_python %}{% for python_version, extras in system_test_extras_by_python.items() %}
120+
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {{ '{' }}{% if system_test_extras_by_python %}{% for python_version, extras in system_test_extras_by_python.items() %}
120121
"{{python_version}}": [{% for v in extras %}
121122
"{{v}}",{% endfor %}
122123
],{% endfor %}{% endif %}
123124
}
124125
{%- else %}
125-
SYSTEM_TEST_EXTRAS_BY_PYTHON = {}
126+
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}
126127
{%- endif %}
127128

128129
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()

tests/test_python_library.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
{"unit_test_local_dependencies": ["../testutils", "../unitutils"]},
3636
[
3737
"""\
38-
UNIT_TEST_LOCAL_DEPENDENCIES = [
38+
UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = [
3939
"../testutils",
4040
"../unitutils",
4141
]""",
@@ -45,7 +45,7 @@
4545
{"system_test_local_dependencies": ["../testutils", "../sysutils"]},
4646
[
4747
"""\
48-
SYSTEM_TEST_LOCAL_DEPENDENCIES = [
48+
SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [
4949
"../testutils",
5050
"../sysutils",
5151
]""",
@@ -55,7 +55,7 @@
5555
{"unit_test_extras": ["abc", "def"]},
5656
[
5757
"""\
58-
UNIT_TEST_EXTRAS = [
58+
UNIT_TEST_EXTRAS: List[str] = [
5959
"abc",
6060
"def",
6161
]""",
@@ -64,7 +64,7 @@
6464
(
6565
{"system_test_extras": ["abc", "def"]},
6666
"""\
67-
SYSTEM_TEST_EXTRAS = [
67+
SYSTEM_TEST_EXTRAS: List[str] = [
6868
"abc",
6969
"def",
7070
]""",
@@ -73,7 +73,7 @@
7373
{"unit_test_extras_by_python": {"3.8": ["abc", "def"]}},
7474
[
7575
"""\
76-
UNIT_TEST_EXTRAS_BY_PYTHON = {
76+
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
7777
"3.8": [
7878
"abc",
7979
"def",
@@ -85,7 +85,7 @@
8585
{"system_test_extras_by_python": {"3.8": ["abc", "def"]}},
8686
[
8787
"""\
88-
SYSTEM_TEST_EXTRAS_BY_PYTHON = {
88+
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
8989
"3.8": [
9090
"abc",
9191
"def",
@@ -100,12 +100,12 @@
100100
},
101101
[
102102
"""\
103-
UNIT_TEST_EXTRAS = [
103+
UNIT_TEST_EXTRAS: List[str] = [
104104
"tuv",
105105
"wxyz",
106106
]""",
107107
"""\
108-
UNIT_TEST_EXTRAS_BY_PYTHON = {
108+
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
109109
"3.8": [
110110
"abc",
111111
"def",
@@ -120,12 +120,12 @@
120120
},
121121
[
122122
"""\
123-
SYSTEM_TEST_EXTRAS = [
123+
SYSTEM_TEST_EXTRAS: List[str] = [
124124
"tuv",
125125
"wxyz",
126126
]""",
127127
"""\
128-
SYSTEM_TEST_EXTRAS_BY_PYTHON = {
128+
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
129129
"3.8": [
130130
"abc",
131131
"def",

0 commit comments

Comments
 (0)