Skip to content

Commit 0bd46ef

Browse files
gcf-owl-bot[bot]parthea
authored andcommitted
chore(python): add nox session to sort python imports (#312)
* chore(python): add nox session to sort python imports Source-Link: googleapis/synthtool@1b71c10 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert change to region tag Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent b30473f commit 0bd46ef

File tree

7 files changed

+90
-7
lines changed

7 files changed

+90
-7
lines changed

videointelligence/samples/analyze/analyze_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import time
1818

1919
from google.api_core.exceptions import ServiceUnavailable
20-
2120
import pytest
2221

2322
import analyze

videointelligence/samples/analyze/beta_snippets_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import beta_snippets
2727

28-
2928
POSSIBLE_TEXTS = [
3029
"Google",
3130
"SUR",

videointelligence/samples/analyze/noxfile.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
import nox
2424

25-
2625
# WARNING - WARNING - WARNING - WARNING - WARNING
2726
# WARNING - WARNING - WARNING - WARNING - WARNING
2827
# DO NOT EDIT THIS FILE EVER!
2928
# WARNING - WARNING - WARNING - WARNING - WARNING
3029
# WARNING - WARNING - WARNING - WARNING - WARNING
3130

3231
BLACK_VERSION = "black==22.3.0"
32+
ISORT_VERSION = "isort==5.10.1"
3333

3434
# Copy `noxfile_config.py` to your directory and modify it instead.
3535

@@ -168,12 +168,33 @@ def lint(session: nox.sessions.Session) -> None:
168168

169169
@nox.session
170170
def blacken(session: nox.sessions.Session) -> None:
171+
"""Run black. Format code to uniform standard."""
171172
session.install(BLACK_VERSION)
172173
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
173174

174175
session.run("black", *python_files)
175176

176177

178+
#
179+
# format = isort + black
180+
#
181+
182+
183+
@nox.session
184+
def format(session: nox.sessions.Session) -> None:
185+
"""
186+
Run isort to sort imports. Then run black
187+
to format code to uniform standard.
188+
"""
189+
session.install(BLACK_VERSION, ISORT_VERSION)
190+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
191+
192+
# Use the --fss option to sort imports using strict alphabetical order.
193+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
194+
session.run("isort", "--fss", *python_files)
195+
session.run("black", *python_files)
196+
197+
177198
#
178199
# Sample Tests
179200
#

videointelligence/samples/analyze/video_detect_logo.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-
import io
1615

16+
# isort: split
1717
# [START video_detect_logo]
18+
import io
1819

1920
from google.cloud import videointelligence
2021

videointelligence/samples/labels/noxfile.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
import nox
2424

25-
2625
# WARNING - WARNING - WARNING - WARNING - WARNING
2726
# WARNING - WARNING - WARNING - WARNING - WARNING
2827
# DO NOT EDIT THIS FILE EVER!
2928
# WARNING - WARNING - WARNING - WARNING - WARNING
3029
# WARNING - WARNING - WARNING - WARNING - WARNING
3130

3231
BLACK_VERSION = "black==22.3.0"
32+
ISORT_VERSION = "isort==5.10.1"
3333

3434
# Copy `noxfile_config.py` to your directory and modify it instead.
3535

@@ -168,12 +168,33 @@ def lint(session: nox.sessions.Session) -> None:
168168

169169
@nox.session
170170
def blacken(session: nox.sessions.Session) -> None:
171+
"""Run black. Format code to uniform standard."""
171172
session.install(BLACK_VERSION)
172173
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
173174

174175
session.run("black", *python_files)
175176

176177

178+
#
179+
# format = isort + black
180+
#
181+
182+
183+
@nox.session
184+
def format(session: nox.sessions.Session) -> None:
185+
"""
186+
Run isort to sort imports. Then run black
187+
to format code to uniform standard.
188+
"""
189+
session.install(BLACK_VERSION, ISORT_VERSION)
190+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
191+
192+
# Use the --fss option to sort imports using strict alphabetical order.
193+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
194+
session.run("isort", "--fss", *python_files)
195+
session.run("black", *python_files)
196+
197+
177198
#
178199
# Sample Tests
179200
#

videointelligence/samples/quickstart/noxfile.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
import nox
2424

25-
2625
# WARNING - WARNING - WARNING - WARNING - WARNING
2726
# WARNING - WARNING - WARNING - WARNING - WARNING
2827
# DO NOT EDIT THIS FILE EVER!
2928
# WARNING - WARNING - WARNING - WARNING - WARNING
3029
# WARNING - WARNING - WARNING - WARNING - WARNING
3130

3231
BLACK_VERSION = "black==22.3.0"
32+
ISORT_VERSION = "isort==5.10.1"
3333

3434
# Copy `noxfile_config.py` to your directory and modify it instead.
3535

@@ -168,12 +168,33 @@ def lint(session: nox.sessions.Session) -> None:
168168

169169
@nox.session
170170
def blacken(session: nox.sessions.Session) -> None:
171+
"""Run black. Format code to uniform standard."""
171172
session.install(BLACK_VERSION)
172173
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
173174

174175
session.run("black", *python_files)
175176

176177

178+
#
179+
# format = isort + black
180+
#
181+
182+
183+
@nox.session
184+
def format(session: nox.sessions.Session) -> None:
185+
"""
186+
Run isort to sort imports. Then run black
187+
to format code to uniform standard.
188+
"""
189+
session.install(BLACK_VERSION, ISORT_VERSION)
190+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
191+
192+
# Use the --fss option to sort imports using strict alphabetical order.
193+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
194+
session.run("isort", "--fss", *python_files)
195+
session.run("black", *python_files)
196+
197+
177198
#
178199
# Sample Tests
179200
#

videointelligence/samples/shotchange/noxfile.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
import nox
2424

25-
2625
# WARNING - WARNING - WARNING - WARNING - WARNING
2726
# WARNING - WARNING - WARNING - WARNING - WARNING
2827
# DO NOT EDIT THIS FILE EVER!
2928
# WARNING - WARNING - WARNING - WARNING - WARNING
3029
# WARNING - WARNING - WARNING - WARNING - WARNING
3130

3231
BLACK_VERSION = "black==22.3.0"
32+
ISORT_VERSION = "isort==5.10.1"
3333

3434
# Copy `noxfile_config.py` to your directory and modify it instead.
3535

@@ -168,12 +168,33 @@ def lint(session: nox.sessions.Session) -> None:
168168

169169
@nox.session
170170
def blacken(session: nox.sessions.Session) -> None:
171+
"""Run black. Format code to uniform standard."""
171172
session.install(BLACK_VERSION)
172173
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
173174

174175
session.run("black", *python_files)
175176

176177

178+
#
179+
# format = isort + black
180+
#
181+
182+
183+
@nox.session
184+
def format(session: nox.sessions.Session) -> None:
185+
"""
186+
Run isort to sort imports. Then run black
187+
to format code to uniform standard.
188+
"""
189+
session.install(BLACK_VERSION, ISORT_VERSION)
190+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
191+
192+
# Use the --fss option to sort imports using strict alphabetical order.
193+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
194+
session.run("isort", "--fss", *python_files)
195+
session.run("black", *python_files)
196+
197+
177198
#
178199
# Sample Tests
179200
#

0 commit comments

Comments
 (0)