Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit 72c5b1d

Browse files
chore(python): add nox session to sort python imports (#80)
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>
1 parent 614c640 commit 72c5b1d

File tree

7 files changed

+49
-27
lines changed

7 files changed

+49
-27
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163
17-
# created: 2022-04-06T10:30:21.687684602Z
16+
digest: sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416
17+
# created: 2022-04-20T23:42:53.970438194Z

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
# All configuration values have a default; values that are commented out
2525
# serve to show the default.
2626

27-
import sys
2827
import os
2928
import shlex
29+
import sys
3030

3131
# If extensions (or modules to document with autodoc) are in another directory,
3232
# add these directories to sys.path here. If the directory is relative to the

google/cloud/source_context/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
#
1616

1717

18-
from google.cloud.source_context_v1.types.source_context import AliasContext
19-
from google.cloud.source_context_v1.types.source_context import CloudRepoSourceContext
20-
from google.cloud.source_context_v1.types.source_context import CloudWorkspaceId
2118
from google.cloud.source_context_v1.types.source_context import (
19+
AliasContext,
20+
CloudRepoSourceContext,
21+
CloudWorkspaceId,
2222
CloudWorkspaceSourceContext,
23+
ExtendedSourceContext,
24+
GerritSourceContext,
25+
GitSourceContext,
26+
ProjectRepoId,
27+
RepoId,
28+
SourceContext,
2329
)
24-
from google.cloud.source_context_v1.types.source_context import ExtendedSourceContext
25-
from google.cloud.source_context_v1.types.source_context import GerritSourceContext
26-
from google.cloud.source_context_v1.types.source_context import GitSourceContext
27-
from google.cloud.source_context_v1.types.source_context import ProjectRepoId
28-
from google.cloud.source_context_v1.types.source_context import RepoId
29-
from google.cloud.source_context_v1.types.source_context import SourceContext
3030

3131
__all__ = (
3232
"AliasContext",

google/cloud/source_context_v1/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
#
1616

1717

18-
from .types.source_context import AliasContext
19-
from .types.source_context import CloudRepoSourceContext
20-
from .types.source_context import CloudWorkspaceId
21-
from .types.source_context import CloudWorkspaceSourceContext
22-
from .types.source_context import ExtendedSourceContext
23-
from .types.source_context import GerritSourceContext
24-
from .types.source_context import GitSourceContext
25-
from .types.source_context import ProjectRepoId
26-
from .types.source_context import RepoId
27-
from .types.source_context import SourceContext
18+
from .types.source_context import (
19+
AliasContext,
20+
CloudRepoSourceContext,
21+
CloudWorkspaceId,
22+
CloudWorkspaceSourceContext,
23+
ExtendedSourceContext,
24+
GerritSourceContext,
25+
GitSourceContext,
26+
ProjectRepoId,
27+
RepoId,
28+
SourceContext,
29+
)
2830

2931
__all__ = (
3032
"AliasContext",

google/cloud/source_context_v1/types/source_context.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#
1616
import proto # type: ignore
1717

18-
1918
__protobuf__ = proto.module(
2019
package="google.devtools.source.v1",
2120
manifest={

noxfile.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# Generated by synthtool. DO NOT EDIT!
1818

1919
from __future__ import absolute_import
20+
2021
import os
2122
import pathlib
2223
import shutil
@@ -25,7 +26,8 @@
2526
import nox
2627

2728
BLACK_VERSION = "black==22.3.0"
28-
BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
29+
ISORT_VERSION = "isort==5.10.1"
30+
LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
2931

3032
DEFAULT_PYTHON_VERSION = "3.8"
3133

@@ -83,7 +85,7 @@ def lint(session):
8385
session.run(
8486
"black",
8587
"--check",
86-
*BLACK_PATHS,
88+
*LINT_PATHS,
8789
)
8890
session.run("flake8", "google", "tests")
8991

@@ -94,7 +96,27 @@ def blacken(session):
9496
session.install(BLACK_VERSION)
9597
session.run(
9698
"black",
97-
*BLACK_PATHS,
99+
*LINT_PATHS,
100+
)
101+
102+
103+
@nox.session(python=DEFAULT_PYTHON_VERSION)
104+
def format(session):
105+
"""
106+
Run isort to sort imports. Then run black
107+
to format code to uniform standard.
108+
"""
109+
session.install(BLACK_VERSION, ISORT_VERSION)
110+
# Use the --fss option to sort imports using strict alphabetical order.
111+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
112+
session.run(
113+
"isort",
114+
"--fss",
115+
*LINT_PATHS,
116+
)
117+
session.run(
118+
"black",
119+
*LINT_PATHS,
98120
)
99121

100122

setup.py

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

2020
import setuptools
2121

22-
2322
name = "google-cloud-source-context"
2423
description = "Python client for Source Context"
2524
version = "1.2.2"

0 commit comments

Comments
 (0)