Skip to content

Commit

Permalink
chore(python): add nox session to sort python imports (#164)
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 dbf7750 commit f6f8865
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
23 changes: 22 additions & 1 deletion contact-center-insights/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
2 changes: 0 additions & 2 deletions contact-center-insights/snippets/test_create_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.
#
import google.auth

from google.cloud import contact_center_insights_v1

import pytest

import create_analysis
Expand Down
2 changes: 0 additions & 2 deletions contact-center-insights/snippets/test_create_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.
#
import google.auth

from google.cloud import contact_center_insights_v1

import pytest

import create_conversation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.
#
import google.auth

from google.cloud import contact_center_insights_v1

import pytest

import create_conversation_with_ttl
Expand Down
2 changes: 0 additions & 2 deletions contact-center-insights/snippets/test_create_issue_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.
#
import google.auth

from google.cloud import contact_center_insights_v1

import pytest

import create_issue_model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.
#
import google.auth

from google.cloud import contact_center_insights_v1

import pytest

import create_phrase_matcher_all_of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.
#
import google.auth

from google.cloud import contact_center_insights_v1

import pytest

import create_phrase_matcher_any_of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
import uuid

import google.auth

from google.cloud import contact_center_insights_v1
from google.cloud import pubsub_v1
from google.cloud import contact_center_insights_v1, pubsub_v1
from google.protobuf import field_mask_pb2

import pytest

import enable_pubsub_notifications
Expand Down
2 changes: 0 additions & 2 deletions contact-center-insights/snippets/test_export_to_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import uuid

import google.auth

from google.cloud import bigquery

import pytest

import export_to_bigquery
Expand Down
2 changes: 0 additions & 2 deletions contact-center-insights/snippets/test_get_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.
#
import google.auth

from google.cloud import contact_center_insights_v1

import pytest

import get_operation
Expand Down
2 changes: 0 additions & 2 deletions contact-center-insights/snippets/test_set_project_ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
# limitations under the License.
#
import google.auth

from google.cloud import contact_center_insights_v1
from google.protobuf import field_mask_pb2

import pytest

import set_project_ttl
Expand Down

0 comments on commit f6f8865

Please sign in to comment.