From 07ea9abfd4f9ad07d1a0d9fee6843dd9d43403c0 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 14 Apr 2025 14:38:55 +0000 Subject: [PATCH 1/3] chore(python): remove noxfile.py from templates Source-Link: https://github.com/googleapis/synthtool/commit/776580213a73a04a3ff4fe2ed7f35c7f3d63a882 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:25de45b58e52021d3a24a6273964371a97a4efeefe6ad3845a64e697c63b6447 --- .github/.OwlBot.lock.yaml | 4 +- noxfile.py | 80 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index c631e1f7d..508ba98ef 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:5581906b957284864632cde4e9c51d1cc66b0094990b27e689132fe5cd036046 -# created: 2025-03-05 + digest: sha256:25de45b58e52021d3a24a6273964371a97a4efeefe6ad3845a64e697c63b6447 +# created: 2025-04-14T14:34:43.260858345Z diff --git a/noxfile.py b/noxfile.py index dd182f105..6b8ebe318 100644 --- a/noxfile.py +++ b/noxfile.py @@ -34,6 +34,8 @@ MYPY_VERSION = "mypy==1.10.0" +MYPY_VERSION = "mypy==1.10.0" + DEFAULT_PYTHON_VERSION = "3.8" UNIT_TEST_PYTHON_VERSIONS: List[str] = [ @@ -87,6 +89,11 @@ "mypy", # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 # "mypy_samples", # TODO: uncomment when the check passes + "mypy", + # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 + # "mypy_samples", # TODO: uncomment when the check passes + # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 + # "mypy_samples", # TODO: uncomment when the check passes "docs", "docfx", "format", @@ -143,6 +150,77 @@ def mypy_samples(session): ) +@nox.session(python=DEFAULT_PYTHON_VERSION) +def mypy(session): + """Run type checks with mypy.""" + session.install("-e", ".[all]") + session.install(MYPY_VERSION) + + # Version 2.1.1 of google-api-core version is the first type-checked release. + # Version 2.2.0 of google-cloud-core version is the first type-checked release. + session.install( + "google-api-core[grpc]>=2.1.1", + "google-cloud-core>=2.2.0", + ) + + # Just install the type info directly, since "mypy --install-types" might + # require an additional pass. + # Exclude types-protobuf==4.24.0.20240106 + # See https://github.com/python/typeshed/issues/11254 + session.install("types-protobuf!=4.24.0.20240106", "types-setuptools") + + # TODO: Only check the hand-written layer, the generated code does not pass + # mypy checks yet. + # https://github.com/googleapis/gapic-generator-python/issues/1092 + session.run("mypy", "-p", "google.cloud") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def mypy_samples(session): + """Run type checks with mypy.""" + + session.install("-e", ".[all]") + + session.install("pytest") + session.install(MYPY_VERSION) + + # Just install the type info directly, since "mypy --install-types" might + # require an additional pass. + session.install("types-mock", "types-protobuf", "types-setuptools") + + session.run( + "mypy", + "--config-file", + str(CURRENT_DIRECTORY / "samples" / "snippets" / "mypy.ini"), + "--no-incremental", # Required by warn-unused-configs from mypy.ini to work + "samples/", + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def mypy_samples(session): + """Run type checks with mypy.""" + + session.install("-e", ".[all]") + + session.install("pytest") + session.install(MYPY_VERSION) + + # Just install the type info directly, since "mypy --install-types" might + # require an additional pass. + session.install("types-mock", "types-protobuf", "types-setuptools") + + session.run( + "mypy", + # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 + # "mypy_samples", # TODO: uncomment when the check passes + "--config-file", + str(CURRENT_DIRECTORY / "samples" / "snippets" / "mypy.ini"), + "--no-incremental", # Required by warn-unused-configs from mypy.ini to work + "samples/", + ) + + @nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): """Run linters. @@ -251,7 +329,7 @@ def unit(session, protobuf_implementation): "py.test", "--quiet", f"--junitxml=unit_{session.python}_sponge_log.xml", - "--cov=google/cloud", + "--cov=google/cloud/cloud", "--cov=tests/unit", "--cov-append", "--cov-config=.coveragerc", From 0a28c649768f06181c0938cc68886f11ad388c15 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Mon, 14 Apr 2025 10:45:54 -0400 Subject: [PATCH 2/3] revert --- noxfile.py | 80 +----------------------------------------------------- 1 file changed, 1 insertion(+), 79 deletions(-) diff --git a/noxfile.py b/noxfile.py index 6b8ebe318..dd182f105 100644 --- a/noxfile.py +++ b/noxfile.py @@ -34,8 +34,6 @@ MYPY_VERSION = "mypy==1.10.0" -MYPY_VERSION = "mypy==1.10.0" - DEFAULT_PYTHON_VERSION = "3.8" UNIT_TEST_PYTHON_VERSIONS: List[str] = [ @@ -89,11 +87,6 @@ "mypy", # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 # "mypy_samples", # TODO: uncomment when the check passes - "mypy", - # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 - # "mypy_samples", # TODO: uncomment when the check passes - # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 - # "mypy_samples", # TODO: uncomment when the check passes "docs", "docfx", "format", @@ -150,77 +143,6 @@ def mypy_samples(session): ) -@nox.session(python=DEFAULT_PYTHON_VERSION) -def mypy(session): - """Run type checks with mypy.""" - session.install("-e", ".[all]") - session.install(MYPY_VERSION) - - # Version 2.1.1 of google-api-core version is the first type-checked release. - # Version 2.2.0 of google-cloud-core version is the first type-checked release. - session.install( - "google-api-core[grpc]>=2.1.1", - "google-cloud-core>=2.2.0", - ) - - # Just install the type info directly, since "mypy --install-types" might - # require an additional pass. - # Exclude types-protobuf==4.24.0.20240106 - # See https://github.com/python/typeshed/issues/11254 - session.install("types-protobuf!=4.24.0.20240106", "types-setuptools") - - # TODO: Only check the hand-written layer, the generated code does not pass - # mypy checks yet. - # https://github.com/googleapis/gapic-generator-python/issues/1092 - session.run("mypy", "-p", "google.cloud") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def mypy_samples(session): - """Run type checks with mypy.""" - - session.install("-e", ".[all]") - - session.install("pytest") - session.install(MYPY_VERSION) - - # Just install the type info directly, since "mypy --install-types" might - # require an additional pass. - session.install("types-mock", "types-protobuf", "types-setuptools") - - session.run( - "mypy", - "--config-file", - str(CURRENT_DIRECTORY / "samples" / "snippets" / "mypy.ini"), - "--no-incremental", # Required by warn-unused-configs from mypy.ini to work - "samples/", - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def mypy_samples(session): - """Run type checks with mypy.""" - - session.install("-e", ".[all]") - - session.install("pytest") - session.install(MYPY_VERSION) - - # Just install the type info directly, since "mypy --install-types" might - # require an additional pass. - session.install("types-mock", "types-protobuf", "types-setuptools") - - session.run( - "mypy", - # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 - # "mypy_samples", # TODO: uncomment when the check passes - "--config-file", - str(CURRENT_DIRECTORY / "samples" / "snippets" / "mypy.ini"), - "--no-incremental", # Required by warn-unused-configs from mypy.ini to work - "samples/", - ) - - @nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): """Run linters. @@ -329,7 +251,7 @@ def unit(session, protobuf_implementation): "py.test", "--quiet", f"--junitxml=unit_{session.python}_sponge_log.xml", - "--cov=google/cloud/cloud", + "--cov=google/cloud", "--cov=tests/unit", "--cov-append", "--cov-config=.coveragerc", From 67529a37f3a6058795d140181767f1f380fa994c Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Mon, 14 Apr 2025 10:46:55 -0400 Subject: [PATCH 3/3] remove replacements in owlbot.py --- owlbot.py | 92 +------------------------------------------------------ 1 file changed, 1 insertion(+), 91 deletions(-) diff --git a/owlbot.py b/owlbot.py index a8044bd6f..3aa352620 100644 --- a/owlbot.py +++ b/owlbot.py @@ -326,7 +326,7 @@ if count < 1: raise Exception(".coveragerc replacement failed.") - s.move([library], excludes=["**/gapic_version.py", "README.rst", "docs/**/*", "setup.py", "testing/constraints-3.7.txt", "testing/constraints-3.8.txt"]) + s.move([library], excludes=["**/gapic_version.py", "noxfile.py", "README.rst", "docs/**/*", "setup.py", "testing/constraints-3.7.txt", "testing/constraints-3.8.txt"]) s.remove_staging_dirs() # ---------------------------------------------------------------------------- @@ -345,96 +345,6 @@ ) s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml", "README.rst", "docs/index.rst"]) -# ---------------------------------------------------------------------------- -# Add mypy nox session. -# ---------------------------------------------------------------------------- -s.replace( - "noxfile.py", - r"LINT_PATHS = \[.*?\]", - '\g<0>\n\nMYPY_VERSION = "mypy==1.10.0"', -) -s.replace( - "noxfile.py", r'"blacken",', '\g<0>\n "mypy",', -) -s.replace( - "noxfile.py", - r"nox\.options\.error_on_missing_interpreters = True", - textwrap.dedent( - ''' \g<0> - - - @nox.session(python=DEFAULT_PYTHON_VERSION) - def mypy(session): - """Run type checks with mypy.""" - session.install("-e", ".[all]") - session.install(MYPY_VERSION) - - # Version 2.1.1 of google-api-core version is the first type-checked release. - # Version 2.2.0 of google-cloud-core version is the first type-checked release. - session.install( - "google-api-core[grpc]>=2.1.1", - "google-cloud-core>=2.2.0", - ) - - # Just install the type info directly, since "mypy --install-types" might - # require an additional pass. - # Exclude types-protobuf==4.24.0.20240106 - # See https://github.com/python/typeshed/issues/11254 - session.install("types-protobuf!=4.24.0.20240106", "types-setuptools") - - # TODO: Only check the hand-written layer, the generated code does not pass - # mypy checks yet. - # https://github.com/googleapis/gapic-generator-python/issues/1092 - session.run("mypy", "-p", "google.cloud")''' - ), -) - - -# ---------------------------------------------------------------------------- -# Add mypy_samples nox session. -# ---------------------------------------------------------------------------- -s.replace( - "noxfile.py", - r' "mypy",', - '\g<0>\n # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936' - '\n # "mypy_samples", # TODO: uncomment when the check passes', -) -s.replace( - "noxfile.py", - r'session\.run\("mypy", "-p", "google.cloud"\)', - textwrap.dedent( - ''' \g<0> - - - @nox.session(python=DEFAULT_PYTHON_VERSION) - def mypy_samples(session): - """Run type checks with mypy.""" - - session.install("-e", ".[all]") - - session.install("pytest") - session.install(MYPY_VERSION) - - # Just install the type info directly, since "mypy --install-types" might - # require an additional pass. - session.install("types-mock", "types-protobuf", "types-setuptools") - - session.run( - "mypy", - "--config-file", - str(CURRENT_DIRECTORY / "samples" / "snippets" / "mypy.ini"), - "--no-incremental", # Required by warn-unused-configs from mypy.ini to work - "samples/", - )''' - ), -) - - -# Only consider the hand-written layer when assessing the test coverage. -s.replace( - "noxfile.py", "--cov=google", "--cov=google/cloud", -) - s.replace(".github/blunderbuss.yml", "googleapis/api-pubsub", "mukund-ananthu") python.py_samples(skip_readmes=True)