Skip to content

Commit c39cbe4

Browse files
chore(python): add nox session to sort python imports (#58)
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 7f655dc commit c39cbe4

File tree

17 files changed

+99
-103
lines changed

17 files changed

+99
-103
lines changed

packages/google-cloud-monitoring-metrics-scopes/.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

packages/google-cloud-monitoring-metrics-scopes/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

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope/__init__.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,22 @@
1414
# limitations under the License.
1515
#
1616

17-
from google.cloud.monitoring_metrics_scope_v1.services.metrics_scopes.client import (
18-
MetricsScopesClient,
19-
)
2017
from google.cloud.monitoring_metrics_scope_v1.services.metrics_scopes.async_client import (
2118
MetricsScopesAsyncClient,
2219
)
23-
24-
from google.cloud.monitoring_metrics_scope_v1.types.metrics_scope import MetricsScope
20+
from google.cloud.monitoring_metrics_scope_v1.services.metrics_scopes.client import (
21+
MetricsScopesClient,
22+
)
2523
from google.cloud.monitoring_metrics_scope_v1.types.metrics_scope import (
24+
MetricsScope,
2625
MonitoredProject,
2726
)
2827
from google.cloud.monitoring_metrics_scope_v1.types.metrics_scopes import (
2928
CreateMonitoredProjectRequest,
30-
)
31-
from google.cloud.monitoring_metrics_scope_v1.types.metrics_scopes import (
3229
DeleteMonitoredProjectRequest,
33-
)
34-
from google.cloud.monitoring_metrics_scope_v1.types.metrics_scopes import (
3530
GetMetricsScopeRequest,
36-
)
37-
from google.cloud.monitoring_metrics_scope_v1.types.metrics_scopes import (
3831
ListMetricsScopesByMonitoredProjectRequest,
39-
)
40-
from google.cloud.monitoring_metrics_scope_v1.types.metrics_scopes import (
4132
ListMetricsScopesByMonitoredProjectResponse,
42-
)
43-
from google.cloud.monitoring_metrics_scope_v1.types.metrics_scopes import (
4433
OperationMetadata,
4534
)
4635

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/__init__.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
# limitations under the License.
1515
#
1616

17-
from .services.metrics_scopes import MetricsScopesClient
18-
from .services.metrics_scopes import MetricsScopesAsyncClient
19-
20-
from .types.metrics_scope import MetricsScope
21-
from .types.metrics_scope import MonitoredProject
22-
from .types.metrics_scopes import CreateMonitoredProjectRequest
23-
from .types.metrics_scopes import DeleteMonitoredProjectRequest
24-
from .types.metrics_scopes import GetMetricsScopeRequest
25-
from .types.metrics_scopes import ListMetricsScopesByMonitoredProjectRequest
26-
from .types.metrics_scopes import ListMetricsScopesByMonitoredProjectResponse
27-
from .types.metrics_scopes import OperationMetadata
17+
from .services.metrics_scopes import MetricsScopesAsyncClient, MetricsScopesClient
18+
from .types.metrics_scope import MetricsScope, MonitoredProject
19+
from .types.metrics_scopes import (
20+
CreateMonitoredProjectRequest,
21+
DeleteMonitoredProjectRequest,
22+
GetMetricsScopeRequest,
23+
ListMetricsScopesByMonitoredProjectRequest,
24+
ListMetricsScopesByMonitoredProjectResponse,
25+
OperationMetadata,
26+
)
2827

2928
__all__ = (
3029
"MetricsScopesAsyncClient",

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/services/metrics_scopes/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from .client import MetricsScopesClient
1716
from .async_client import MetricsScopesAsyncClient
17+
from .client import MetricsScopesClient
1818

1919
__all__ = (
2020
"MetricsScopesClient",

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/services/metrics_scopes/async_client.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
import functools
1818
import re
1919
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
20-
import pkg_resources
2120

22-
from google.api_core.client_options import ClientOptions
2321
from google.api_core import exceptions as core_exceptions
2422
from google.api_core import gapic_v1
2523
from google.api_core import retry as retries
24+
from google.api_core.client_options import ClientOptions
2625
from google.auth import credentials as ga_credentials # type: ignore
2726
from google.oauth2 import service_account # type: ignore
27+
import pkg_resources
2828

2929
try:
3030
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
@@ -33,13 +33,14 @@
3333

3434
from google.api_core import operation # type: ignore
3535
from google.api_core import operation_async # type: ignore
36-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope
37-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scopes
3836
from google.protobuf import empty_pb2 # type: ignore
3937
from google.protobuf import timestamp_pb2 # type: ignore
40-
from .transports.base import MetricsScopesTransport, DEFAULT_CLIENT_INFO
41-
from .transports.grpc_asyncio import MetricsScopesGrpcAsyncIOTransport
38+
39+
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope, metrics_scopes
40+
4241
from .client import MetricsScopesClient
42+
from .transports.base import DEFAULT_CLIENT_INFO, MetricsScopesTransport
43+
from .transports.grpc_asyncio import MetricsScopesGrpcAsyncIOTransport
4344

4445

4546
class MetricsScopesAsyncClient:

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/services/metrics_scopes/client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
import os
1818
import re
1919
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
20-
import pkg_resources
2120

2221
from google.api_core import client_options as client_options_lib
2322
from google.api_core import exceptions as core_exceptions
2423
from google.api_core import gapic_v1
2524
from google.api_core import retry as retries
2625
from google.auth import credentials as ga_credentials # type: ignore
26+
from google.auth.exceptions import MutualTLSChannelError # type: ignore
2727
from google.auth.transport import mtls # type: ignore
2828
from google.auth.transport.grpc import SslCredentials # type: ignore
29-
from google.auth.exceptions import MutualTLSChannelError # type: ignore
3029
from google.oauth2 import service_account # type: ignore
30+
import pkg_resources
3131

3232
try:
3333
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
@@ -36,11 +36,12 @@
3636

3737
from google.api_core import operation # type: ignore
3838
from google.api_core import operation_async # type: ignore
39-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope
40-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scopes
4139
from google.protobuf import empty_pb2 # type: ignore
4240
from google.protobuf import timestamp_pb2 # type: ignore
43-
from .transports.base import MetricsScopesTransport, DEFAULT_CLIENT_INFO
41+
42+
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope, metrics_scopes
43+
44+
from .transports.base import DEFAULT_CLIENT_INFO, MetricsScopesTransport
4445
from .transports.grpc import MetricsScopesGrpcTransport
4546
from .transports.grpc_asyncio import MetricsScopesGrpcAsyncIOTransport
4647

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/services/metrics_scopes/transports/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from .grpc import MetricsScopesGrpcTransport
2121
from .grpc_asyncio import MetricsScopesGrpcAsyncIOTransport
2222

23-
2423
# Compile a registry of transports.
2524
_transport_registry = OrderedDict() # type: Dict[str, Type[MetricsScopesTransport]]
2625
_transport_registry["grpc"] = MetricsScopesGrpcTransport

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/services/metrics_scopes/transports/base.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@
1515
#
1616
import abc
1717
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
18-
import pkg_resources
1918

20-
import google.auth # type: ignore
2119
import google.api_core
2220
from google.api_core import exceptions as core_exceptions
23-
from google.api_core import gapic_v1
21+
from google.api_core import gapic_v1, operations_v1
2422
from google.api_core import retry as retries
25-
from google.api_core import operations_v1
23+
import google.auth # type: ignore
2624
from google.auth import credentials as ga_credentials # type: ignore
25+
from google.longrunning import operations_pb2 # type: ignore
2726
from google.oauth2 import service_account # type: ignore
27+
import pkg_resources
2828

29-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope
30-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scopes
31-
from google.longrunning import operations_pb2 # type: ignore
29+
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope, metrics_scopes
3230

3331
try:
3432
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/services/metrics_scopes/transports/grpc.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,19 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
import warnings
1716
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
17+
import warnings
1818

19-
from google.api_core import grpc_helpers
20-
from google.api_core import operations_v1
21-
from google.api_core import gapic_v1
19+
from google.api_core import gapic_v1, grpc_helpers, operations_v1
2220
import google.auth # type: ignore
2321
from google.auth import credentials as ga_credentials # type: ignore
2422
from google.auth.transport.grpc import SslCredentials # type: ignore
25-
23+
from google.longrunning import operations_pb2 # type: ignore
2624
import grpc # type: ignore
2725

28-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope
29-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scopes
30-
from google.longrunning import operations_pb2 # type: ignore
31-
from .base import MetricsScopesTransport, DEFAULT_CLIENT_INFO
26+
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope, metrics_scopes
27+
28+
from .base import DEFAULT_CLIENT_INFO, MetricsScopesTransport
3229

3330

3431
class MetricsScopesGrpcTransport(MetricsScopesTransport):

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/services/metrics_scopes/transports/grpc_asyncio.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,19 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
import warnings
1716
from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
17+
import warnings
1818

19-
from google.api_core import gapic_v1
20-
from google.api_core import grpc_helpers_async
21-
from google.api_core import operations_v1
19+
from google.api_core import gapic_v1, grpc_helpers_async, operations_v1
2220
from google.auth import credentials as ga_credentials # type: ignore
2321
from google.auth.transport.grpc import SslCredentials # type: ignore
24-
22+
from google.longrunning import operations_pb2 # type: ignore
2523
import grpc # type: ignore
2624
from grpc.experimental import aio # type: ignore
2725

28-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope
29-
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scopes
30-
from google.longrunning import operations_pb2 # type: ignore
31-
from .base import MetricsScopesTransport, DEFAULT_CLIENT_INFO
26+
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope, metrics_scopes
27+
28+
from .base import DEFAULT_CLIENT_INFO, MetricsScopesTransport
3229
from .grpc import MetricsScopesGrpcTransport
3330

3431

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/types/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from .metrics_scope import (
17-
MetricsScope,
18-
MonitoredProject,
19-
)
16+
from .metrics_scope import MetricsScope, MonitoredProject
2017
from .metrics_scopes import (
2118
CreateMonitoredProjectRequest,
2219
DeleteMonitoredProjectRequest,

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/types/metrics_scope.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
import proto # type: ignore
17-
1816
from google.protobuf import timestamp_pb2 # type: ignore
19-
17+
import proto # type: ignore
2018

2119
__protobuf__ = proto.module(
2220
package="google.monitoring.metricsscope.v1",

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/types/metrics_scopes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from google.protobuf import timestamp_pb2 # type: ignore
1617
import proto # type: ignore
1718

1819
from google.cloud.monitoring_metrics_scope_v1.types import metrics_scope
19-
from google.protobuf import timestamp_pb2 # type: ignore
20-
2120

2221
__protobuf__ = proto.module(
2322
package="google.monitoring.metricsscope.v1",

packages/google-cloud-monitoring-metrics-scopes/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

packages/google-cloud-monitoring-metrics-scopes/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#
1616
import io
1717
import os
18+
1819
import setuptools # type: ignore
1920

2021
version = "1.1.1"

0 commit comments

Comments
 (0)