Skip to content

Commit

Permalink
chore(python): add nox session to sort python imports (#312)
Browse files Browse the repository at this point in the history
Source-Link: googleapis/synthtool@1b71c10
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Apr 21, 2022
1 parent c81aabb commit 9429f13
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 19 deletions.
3 changes: 0 additions & 3 deletions documentai/snippets/batch_parse_form_v1beta2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
import uuid

from google.cloud import storage

import pytest

from samples.snippets import batch_parse_form_v1beta2


BUCKET = "document-ai-{}".format(uuid.uuid4())
OUTPUT_PREFIX = "TEST_OUTPUT_{}".format(uuid.uuid4())
PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]
Expand Down
3 changes: 0 additions & 3 deletions documentai/snippets/batch_parse_table_v1beta2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
import uuid

from google.cloud import storage

import pytest

from samples.snippets import batch_parse_table_v1beta2


BUCKET = "document-ai-{}".format(uuid.uuid4())
OUTPUT_PREFIX = "TEST_OUTPUT_{}".format(uuid.uuid4())
PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]
Expand Down
2 changes: 0 additions & 2 deletions documentai/snippets/batch_process_documents_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

from google.cloud import storage
from google.cloud.exceptions import NotFound

import pytest

from samples.snippets import batch_process_documents_sample

location = "us"
Expand Down
23 changes: 22 additions & 1 deletion documentai/snippets/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

import nox


# WARNING - WARNING - WARNING - WARNING - WARNING
# WARNING - WARNING - WARNING - WARNING - WARNING
# DO NOT EDIT THIS FILE EVER!
# WARNING - WARNING - WARNING - WARNING - WARNING
# WARNING - WARNING - WARNING - WARNING - WARNING

BLACK_VERSION = "black==22.3.0"
ISORT_VERSION = "isort==5.10.1"

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

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

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

session.run("black", *python_files)


#
# format = isort + black
#


@nox.session
def format(session: nox.sessions.Session) -> None:
"""
Run isort to sort imports. Then run black
to format code to uniform standard.
"""
session.install(BLACK_VERSION, ISORT_VERSION)
python_files = [path for path in os.listdir(".") if path.endswith(".py")]

# Use the --fss option to sort imports using strict alphabetical order.
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
session.run("isort", "--fss", *python_files)
session.run("black", *python_files)


#
# Sample Tests
#
Expand Down
1 change: 0 additions & 1 deletion documentai/snippets/parse_form_v1beta2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from samples.snippets import parse_form_v1beta2


PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]
INPUT_URI = "gs://cloud-samples-data/documentai/form.pdf"

Expand Down
1 change: 0 additions & 1 deletion documentai/snippets/parse_table_v1beta2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from samples.snippets import parse_table_v1beta2


PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]
INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf"

Expand Down
1 change: 0 additions & 1 deletion documentai/snippets/parse_with_model_v1beta2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from samples.snippets import parse_with_model_v1beta2


PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]
INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf"
AUTOML_NL_MODEL_ID = "TCN3472481026502981088"
Expand Down
1 change: 0 additions & 1 deletion documentai/snippets/process_document_form_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from samples.snippets import process_document_form_sample


location = "us"
project_id = os.environ["GOOGLE_CLOUD_PROJECT"]
processor_id = "90484cfdedb024f6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from samples.snippets import process_document_quality_sample


location = "us"
project_id = os.environ["GOOGLE_CLOUD_PROJECT"]
processor_id = "7fcb597c523721b3"
Expand Down
1 change: 0 additions & 1 deletion documentai/snippets/process_document_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from samples.snippets import process_document_sample


location = "us"
project_id = os.environ["GOOGLE_CLOUD_PROJECT"]
processor_id = "90484cfdedb024f6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from samples.snippets import process_document_specialized_sample


location = "us"
project_id = os.environ["GOOGLE_CLOUD_PROJECT"]
processor_id = "feacd98c28866ede"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from samples.snippets import process_document_splitter_sample


location = "us"
project_id = os.environ["GOOGLE_CLOUD_PROJECT"]
processor_id = "ed55eeb2b276066f"
Expand Down
1 change: 0 additions & 1 deletion documentai/snippets/quickstart_v1beta2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from samples.snippets import quickstart_v1beta2


PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]
INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf"

Expand Down
1 change: 0 additions & 1 deletion documentai/snippets/set_endpoint_v1beta2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from samples.snippets import set_endpoint_v1beta2


PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]
INPUT_URI = "gs://cloud-samples-data/documentai/invoice.pdf"

Expand Down

0 comments on commit 9429f13

Please sign in to comment.