From 22d03f0676a19c6b6d87623273666383bbba2203 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 9 Oct 2023 14:12:25 +0000 Subject: [PATCH] chore: [autoapprove] Update `black` and `isort` to latest versions Source-Link: https://github.com/googleapis/synthtool/commit/0c7b0333f44b2b7075447f43a121a12d15a7b76a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:08e34975760f002746b1d8c86fdc90660be45945ee6d9db914d1508acdf9a547 --- .github/.OwlBot.lock.yaml | 4 +-- .kokoro/requirements.txt | 6 ++-- .pre-commit-config.yaml | 2 +- google/cloud/logging_v2/_http.py | 1 - google/cloud/logging_v2/handlers/handlers.py | 2 +- noxfile.py | 34 ++++++++++--------- tests/system/test_system.py | 1 - .../handlers/test__monitored_resources.py | 3 -- tests/unit/handlers/test_handlers.py | 4 +-- tests/unit/handlers/test_structured_log.py | 14 ++++---- tests/unit/handlers/transports/test_base.py | 1 - tests/unit/handlers/transports/test_sync.py | 1 - tests/unit/test__http.py | 5 --- tests/unit/test__instrumentation.py | 1 - tests/unit/test_client.py | 2 -- tests/unit/test_entries.py | 4 --- tests/unit/test_logger.py | 5 --- tests/unit/test_metric.py | 1 - tests/unit/test_sink.py | 1 - 19 files changed, 33 insertions(+), 59 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index a9bdb1b7a..dd98abbde 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:fac304457974bb530cc5396abd4ab25d26a469cd3bc97cbfb18c8d4324c584eb -# created: 2023-10-02T21:31:03.517640371Z + digest: sha256:08e34975760f002746b1d8c86fdc90660be45945ee6d9db914d1508acdf9a547 +# created: 2023-10-09T14:06:13.397766266Z diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt index 96d593c8c..0332d3267 100644 --- a/.kokoro/requirements.txt +++ b/.kokoro/requirements.txt @@ -467,9 +467,9 @@ typing-extensions==4.4.0 \ --hash=sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa \ --hash=sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e # via -r requirements.in -urllib3==1.26.12 \ - --hash=sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e \ - --hash=sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997 +urllib3==1.26.17 \ + --hash=sha256:24d6a242c28d29af46c3fae832c36db3bbebcc533dd1bb549172cd739c82df21 \ + --hash=sha256:94a757d178c9be92ef5539b8840d48dc9cf1b2709c9d6b588232a055c524458b # via # requests # twine diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 19409cbd3..6a8e16950 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 23.7.0 hooks: - id: black - repo: https://github.com/pycqa/flake8 diff --git a/google/cloud/logging_v2/_http.py b/google/cloud/logging_v2/_http.py index 581dce35e..b90789353 100644 --- a/google/cloud/logging_v2/_http.py +++ b/google/cloud/logging_v2/_http.py @@ -26,7 +26,6 @@ class Connection(_http.JSONConnection): - DEFAULT_API_ENDPOINT = "https://logging.googleapis.com" def __init__(self, client, *, client_info=None, api_endpoint=DEFAULT_API_ENDPOINT): diff --git a/google/cloud/logging_v2/handlers/handlers.py b/google/cloud/logging_v2/handlers/handlers.py index 28960ae71..ce5822fcd 100644 --- a/google/cloud/logging_v2/handlers/handlers.py +++ b/google/cloud/logging_v2/handlers/handlers.py @@ -70,7 +70,7 @@ def _infer_source_location(record): ("function", "funcName"), ] output = {} - for (gcp_name, std_lib_name) in name_map: + for gcp_name, std_lib_name in name_map: value = getattr(record, std_lib_name, None) if value is not None: output[gcp_name] = value diff --git a/noxfile.py b/noxfile.py index 7ebe500a3..565df040b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,22 +17,24 @@ # Generated by synthtool. DO NOT EDIT! from __future__ import absolute_import + import os import pathlib import re import shutil +from typing import Dict, List import warnings import nox FLAKE8_VERSION = "flake8==6.1.0" -BLACK_VERSION = "black==22.3.0" -ISORT_VERSION = "isort==5.10.1" +BLACK_VERSION = "black[jupyter]==23.7.0" +ISORT_VERSION = "isort==5.11.0" LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"] +UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.7", "3.8", "3.9", "3.10", "3.11"] UNIT_TEST_STANDARD_DEPENDENCIES = [ "mock", "asyncmock", @@ -40,32 +42,32 @@ "pytest-cov", "pytest-asyncio", ] -UNIT_TEST_EXTERNAL_DEPENDENCIES = [ +UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = [ "flask", "webob", "django", ] -UNIT_TEST_LOCAL_DEPENDENCIES = [] -UNIT_TEST_DEPENDENCIES = [] -UNIT_TEST_EXTRAS = [] -UNIT_TEST_EXTRAS_BY_PYTHON = {} +UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = [] +UNIT_TEST_DEPENDENCIES: List[str] = [] +UNIT_TEST_EXTRAS: List[str] = [] +UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] -SYSTEM_TEST_STANDARD_DEPENDENCIES = [ +SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES: List[str] = [ "mock", "pytest", "google-cloud-testutils", ] -SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [ +SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = [ "google-cloud-bigquery", "google-cloud-pubsub", "google-cloud-storage", "google-cloud-testutils", ] -SYSTEM_TEST_LOCAL_DEPENDENCIES = [] -SYSTEM_TEST_DEPENDENCIES = [] -SYSTEM_TEST_EXTRAS = [] -SYSTEM_TEST_EXTRAS_BY_PYTHON = {} +SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [] +SYSTEM_TEST_DEPENDENCIES: List[str] = [] +SYSTEM_TEST_EXTRAS: List[str] = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -78,6 +80,7 @@ "lint_setup_py", "blacken", "docs", + "format", ] # Error if a python version is missing @@ -196,7 +199,6 @@ def unit(session): def install_systemtest_dependencies(session, *constraints): - # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. # See https://github.com/grpc/grpc/issues/32163 diff --git a/tests/system/test_system.py b/tests/system/test_system.py index 8d39408d3..ba7fd6c2a 100644 --- a/tests/system/test_system.py +++ b/tests/system/test_system.py @@ -118,7 +118,6 @@ def setUpModule(): class TestLogging(unittest.TestCase): - JSON_PAYLOAD = { "message": "System test: test_log_struct", "weather": { diff --git a/tests/unit/handlers/test__monitored_resources.py b/tests/unit/handlers/test__monitored_resources.py index 16378fd50..838543253 100644 --- a/tests/unit/handlers/test__monitored_resources.py +++ b/tests/unit/handlers/test__monitored_resources.py @@ -45,7 +45,6 @@ class Test_Create_Resources(unittest.TestCase): - PROJECT = "test-project" LOCATION = "test-location" NAME = "test-name" @@ -135,7 +134,6 @@ def test_functions_resource_no_name(self): self.assertEqual(func_resource.labels["function_name"], "") def test_create_kubernetes_resource(self): - patch = mock.patch( "google.cloud.logging_v2.handlers._monitored_resources.retrieve_metadata_server", wraps=self._mock_metadata, @@ -246,7 +244,6 @@ def test_with_no_project_from_server(self): class Test_Resource_Detection(unittest.TestCase): - PROJECT = "test-project" def _mock_k8s_metadata(self, endpoint): diff --git a/tests/unit/handlers/test_handlers.py b/tests/unit/handlers/test_handlers.py index 1e431f1aa..1f86a8e37 100644 --- a/tests/unit/handlers/test_handlers.py +++ b/tests/unit/handlers/test_handlers.py @@ -25,7 +25,6 @@ class TestCloudLoggingFilter(unittest.TestCase): - PROJECT = "PROJECT" @staticmethod @@ -291,7 +290,6 @@ def test_user_overrides(self): class TestCloudLoggingHandler(unittest.TestCase): - PROJECT = "PROJECT" @staticmethod @@ -859,7 +857,7 @@ def test_json_fields_input_unmodified(self): _format_and_parse_message(record, handler) # ensure json_fields has no side-effects self.assertEqual(set(json_fields.keys()), set(json_fields_orig.keys())) - for (key, value) in json_fields_orig.items(): + for key, value in json_fields_orig.items(): self.assertEqual( value, json_fields[key], f"expected_payload[{key}] != result[{key}]" ) diff --git a/tests/unit/handlers/test_structured_log.py b/tests/unit/handlers/test_structured_log.py index 353530ed1..fc6b7c598 100644 --- a/tests/unit/handlers/test_structured_log.py +++ b/tests/unit/handlers/test_structured_log.py @@ -86,7 +86,7 @@ def test_format(self): } handler.filter(record) result = json.loads(handler.format(record)) - for (key, value) in expected_payload.items(): + for key, value in expected_payload.items(): self.assertEqual(value, result[key]) self.assertEqual( len(expected_payload.keys()), @@ -121,7 +121,7 @@ def test_format_minimal(self): handler.filter(record) result = json.loads(handler.format(record)) self.assertEqual(set(expected_payload.keys()), set(result.keys())) - for (key, value) in expected_payload.items(): + for key, value in expected_payload.items(): self.assertEqual( value, result[key], f"expected_payload[{key}] != result[{key}]" ) @@ -304,7 +304,7 @@ def test_format_with_reserved_json_field(self): handler.filter(record) result = json.loads(handler.format(record)) self.assertEqual(set(expected_payload.keys()), set(result.keys())) - for (key, value) in expected_payload.items(): + for key, value in expected_payload.items(): self.assertEqual( value, result[key], f"expected_payload[{key}] != result[{key}]" ) @@ -417,7 +417,7 @@ def test_format_with_request(self): ): handler.filter(record) result = json.loads(handler.format(record)) - for (key, value) in expected_payload.items(): + for key, value in expected_payload.items(): self.assertEqual(value, result[key]) def test_format_with_traceparent(self): @@ -452,7 +452,7 @@ def test_format_with_traceparent(self): ): handler.filter(record) result = json.loads(handler.format(record)) - for (key, value) in expected_payload.items(): + for key, value in expected_payload.items(): self.assertEqual(value, result[key]) def test_format_overrides(self): @@ -509,7 +509,7 @@ def test_format_overrides(self): ) handler.filter(record) result = json.loads(handler.format(record)) - for (key, value) in expected_payload.items(): + for key, value in expected_payload.items(): self.assertEqual(value, result[key]) def test_format_with_json_fields(self): @@ -590,7 +590,7 @@ def test_json_fields_input_unmodified(self): handler.format(record) # ensure json_fields has no side-effects self.assertEqual(set(json_fields.keys()), set(json_fields_orig.keys())) - for (key, value) in json_fields_orig.items(): + for key, value in json_fields_orig.items(): self.assertEqual( value, json_fields[key], f"expected_payload[{key}] != result[{key}]" ) diff --git a/tests/unit/handlers/transports/test_base.py b/tests/unit/handlers/transports/test_base.py index 71ef1366a..a0013cadf 100644 --- a/tests/unit/handlers/transports/test_base.py +++ b/tests/unit/handlers/transports/test_base.py @@ -16,7 +16,6 @@ class TestBaseHandler(unittest.TestCase): - PROJECT = "PROJECT" @staticmethod diff --git a/tests/unit/handlers/transports/test_sync.py b/tests/unit/handlers/transports/test_sync.py index 752a96d9f..01a949d24 100644 --- a/tests/unit/handlers/transports/test_sync.py +++ b/tests/unit/handlers/transports/test_sync.py @@ -17,7 +17,6 @@ class TestSyncHandler(unittest.TestCase): - PROJECT = "PROJECT" @staticmethod diff --git a/tests/unit/test__http.py b/tests/unit/test__http.py index f9b60cfa6..0e83bd82c 100644 --- a/tests/unit/test__http.py +++ b/tests/unit/test__http.py @@ -24,7 +24,6 @@ def _make_credentials(): class TestConnection(unittest.TestCase): - PROJECT = "project" FILTER = "logName:syslog AND severity>=ERROR" @@ -96,7 +95,6 @@ def test_extra_headers(self): class Test_LoggingAPI(unittest.TestCase): - PROJECT = "project" PROJECT_PATH = "projects/project" LIST_ENTRIES_PATH = "entries:list" @@ -354,7 +352,6 @@ def test_logger_delete(self): class Test_SinksAPI(unittest.TestCase): - PROJECT = "project" PROJECT_PATH = "projects/project" FILTER = "logName:syslog AND severity>=ERROR" @@ -636,7 +633,6 @@ def test_sink_delete_hit(self): class Test_MetricsAPI(unittest.TestCase): - PROJECT = "project" FILTER = "logName:syslog AND severity>=ERROR" LIST_METRICS_PATH = "projects/%s/metrics" % (PROJECT,) @@ -865,7 +861,6 @@ def test_metric_delete_hit(self): class _Connection(object): - _called_with = None _raise_conflict = False diff --git a/tests/unit/test__instrumentation.py b/tests/unit/test__instrumentation.py index dc330b0ca..a98aae34c 100644 --- a/tests/unit/test__instrumentation.py +++ b/tests/unit/test__instrumentation.py @@ -17,7 +17,6 @@ class TestInstrumentation(unittest.TestCase): - TEST_NAME = "python" # LONG_NAME > 14 characters LONG_NAME = TEST_NAME + "789ABCDEF" diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 1c47a343b..ec3130ac5 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -34,7 +34,6 @@ def _make_credentials(): class TestClient(unittest.TestCase): - PROJECT = "PROJECT" PROJECT_PATH = f"projects/{PROJECT}" LOGGER_NAME = "LOGGER_NAME" @@ -903,7 +902,6 @@ def test_setup_logging_w_extra_kwargs(self): class _Connection(object): - _called_with = None def __init__(self, *responses): diff --git a/tests/unit/test_entries.py b/tests/unit/test_entries.py index 6f3af684f..4742f5574 100644 --- a/tests/unit/test_entries.py +++ b/tests/unit/test_entries.py @@ -79,7 +79,6 @@ def test_w_str(self): class TestLogEntry(unittest.TestCase): - PROJECT = "PROJECT" LOGGER_NAME = "LOGGER_NAME" @@ -469,7 +468,6 @@ def test_to_api_repr_explicit(self): class TestTextEntry(unittest.TestCase): - PROJECT = "PROJECT" LOGGER_NAME = "LOGGER_NAME" @@ -557,7 +555,6 @@ def test_to_api_repr_explicit(self): class TestStructEntry(unittest.TestCase): - PROJECT = "PROJECT" LOGGER_NAME = "LOGGER_NAME" @@ -659,7 +656,6 @@ def test_to_api_repr_explicit(self): class TestProtobufEntry(unittest.TestCase): - PROJECT = "PROJECT" LOGGER_NAME = "LOGGER_NAME" diff --git a/tests/unit/test_logger.py b/tests/unit/test_logger.py index 16c89959b..cdb56747d 100644 --- a/tests/unit/test_logger.py +++ b/tests/unit/test_logger.py @@ -28,7 +28,6 @@ def _make_credentials(): class TestLogger(unittest.TestCase): - PROJECT = "test-project" LOGGER_NAME = "logger-name" TIME_FORMAT = '"%Y-%m-%dT%H:%M:%S.%f%z"' @@ -1086,7 +1085,6 @@ def test_first_log_emits_instrumentation(self): class TestBatch(unittest.TestCase): - PROJECT = "test-project" @staticmethod @@ -1847,7 +1845,6 @@ def test_batch_error_gets_context(self): class _Logger(object): - labels = None def __init__(self, name="NAME", project="PROJECT"): @@ -1855,7 +1852,6 @@ def __init__(self, name="NAME", project="PROJECT"): class _DummyLoggingAPI(object): - _write_entries_called_with = None def write_entries( @@ -1909,7 +1905,6 @@ class _Bugout(Exception): class _Connection(object): - _called_with = None def __init__(self, *responses): diff --git a/tests/unit/test_metric.py b/tests/unit/test_metric.py index 83b49d02d..f36ae3b2a 100644 --- a/tests/unit/test_metric.py +++ b/tests/unit/test_metric.py @@ -16,7 +16,6 @@ class TestMetric(unittest.TestCase): - PROJECT = "test-project" METRIC_NAME = "metric-name" FULL_METRIC_NAME = f"projects/{PROJECT}/metrics/{METRIC_NAME}" diff --git a/tests/unit/test_sink.py b/tests/unit/test_sink.py index 1e4852ab5..b5005b057 100644 --- a/tests/unit/test_sink.py +++ b/tests/unit/test_sink.py @@ -16,7 +16,6 @@ class TestSink(unittest.TestCase): - PROJECT = "test-project" PROJECT_PATH = f"projects/{PROJECT}" SINK_NAME = "sink-name"