From d05a6a7072ddf1da751d2233944dc4c0aa43b113 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Thu, 8 Aug 2024 17:06:59 +0000 Subject: [PATCH 1/7] tests: Added mypy to noxfile --- owlbot.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/owlbot.py b/owlbot.py index f1a5b697e..6164c5206 100644 --- a/owlbot.py +++ b/owlbot.py @@ -265,3 +265,22 @@ def place_before(path, text, *before_text, escape=None): file_path, merge=lambda src, dst, _,: f"{dst}\n{src}", ) + +place_before( + "noxfile.py", + """ +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint(session): +""", +''' +@nox.session(python=DEFAULT_PYTHON_VERSION) +def mypy(session): + """Verify type hints are mypy compatible.""" + session.install("-e", ".") + session.install("mypy", "types-setuptools") + # TODO: also verify types on tests and logging_v2 + session.run("mypy", "-p", "google.cloud.logging", "--no-incremental") + + +''', +) \ No newline at end of file From 74165ff294205621cadbba210beca183507e1115 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Thu, 8 Aug 2024 17:07:31 +0000 Subject: [PATCH 2/7] Added newline after owlbot.py --- owlbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/owlbot.py b/owlbot.py index 6164c5206..8587e821b 100644 --- a/owlbot.py +++ b/owlbot.py @@ -283,4 +283,4 @@ def mypy(session): ''', -) \ No newline at end of file +) From 5b6175c35902e3875a2d60a8b0252e1c9ddc6693 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Thu, 8 Aug 2024 17:20:24 +0000 Subject: [PATCH 3/7] Added backslashes --- owlbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/owlbot.py b/owlbot.py index 8587e821b..d067b023b 100644 --- a/owlbot.py +++ b/owlbot.py @@ -268,11 +268,11 @@ def place_before(path, text, *before_text, escape=None): place_before( "noxfile.py", - """ + """\ @nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): """, -''' +'''\ @nox.session(python=DEFAULT_PYTHON_VERSION) def mypy(session): """Verify type hints are mypy compatible.""" From 6ae5d94883488c380fe851a506f4d449d82ffae0 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Thu, 8 Aug 2024 17:50:47 +0000 Subject: [PATCH 4/7] Moved noxfile change to account for library --- owlbot.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/owlbot.py b/owlbot.py index d067b023b..cd3190c74 100644 --- a/owlbot.py +++ b/owlbot.py @@ -64,6 +64,25 @@ def place_before(path, text, *before_text, escape=None): escape="()", ) + place_before( + library / "noxfile.py", + """\ +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint(session): +""", +'''\ +@nox.session(python=DEFAULT_PYTHON_VERSION) +def mypy(session): + """Verify type hints are mypy compatible.""" + session.install("-e", ".") + session.install("mypy", "types-setuptools") + # TODO: also verify types on tests and logging_v2 + session.run("mypy", "-p", "google.cloud.logging", "--no-incremental") + + +''', +) + s.move([library], excludes=[ "**/gapic_version.py", "setup.py", @@ -265,22 +284,3 @@ def place_before(path, text, *before_text, escape=None): file_path, merge=lambda src, dst, _,: f"{dst}\n{src}", ) - -place_before( - "noxfile.py", - """\ -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): -""", -'''\ -@nox.session(python=DEFAULT_PYTHON_VERSION) -def mypy(session): - """Verify type hints are mypy compatible.""" - session.install("-e", ".") - session.install("mypy", "types-setuptools") - # TODO: also verify types on tests and logging_v2 - session.run("mypy", "-p", "google.cloud.logging", "--no-incremental") - - -''', -) From 3ae918accd01be94845eea740895bdf6690bf579 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Thu, 8 Aug 2024 19:59:17 +0000 Subject: [PATCH 5/7] Replaced place_before with s.replace --- owlbot.py | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/owlbot.py b/owlbot.py index cd3190c74..8f9bf40a1 100644 --- a/owlbot.py +++ b/owlbot.py @@ -64,28 +64,10 @@ def place_before(path, text, *before_text, escape=None): escape="()", ) - place_before( - library / "noxfile.py", - """\ -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): -""", -'''\ -@nox.session(python=DEFAULT_PYTHON_VERSION) -def mypy(session): - """Verify type hints are mypy compatible.""" - session.install("-e", ".") - session.install("mypy", "types-setuptools") - # TODO: also verify types on tests and logging_v2 - session.run("mypy", "-p", "google.cloud.logging", "--no-incremental") - - -''', -) - s.move([library], excludes=[ "**/gapic_version.py", "setup.py", + "noxfile.py", "testing/constraints-3.7.txt", "testing/constraints-3.8.txt", "README.rst", @@ -155,6 +137,29 @@ def mypy(session): }""", ) +# Add mypy to noxfile. +# TODO: Remove this once this functionality gets added in synthtool +s.replace( + "noxfile.py", + """\ +@nox.session\(python=DEFAULT_PYTHON_VERSION\) +def lint_setup_py\(session\): +""", +'''\ +@nox.session(python=DEFAULT_PYTHON_VERSION) +def mypy(session): + """Verify type hints are mypy compatible.""" + session.install("-e", ".") + session.install("mypy", "types-setuptools") + # TODO: also verify types on tests and logging_v2, big undertakings + session.run("mypy", "-p", "google.cloud.logging", "--no-incremental") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint_setup_py(session): +''' +) + # -------------------------------------------------------------------------- # Samples templates # -------------------------------------------------------------------------- From ad0319e953f084a38b2cf4cb2dc13720684a5942 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 8 Aug 2024 20:04:53 +0000 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- noxfile.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/noxfile.py b/noxfile.py index 65e583ec2..43e8a6da1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -134,6 +134,15 @@ def format(session): ) +@nox.session(python=DEFAULT_PYTHON_VERSION) +def mypy(session): + """Verify type hints are mypy compatible.""" + session.install("-e", ".") + session.install("mypy", "types-setuptools") + # TODO: also verify types on tests and logging_v2, big undertakings + session.run("mypy", "-p", "google.cloud.logging", "--no-incremental") + + @nox.session(python=DEFAULT_PYTHON_VERSION) def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" From a13b338e75baf91a924c5baa9cff8c64f70c80b2 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Thu, 8 Aug 2024 20:04:24 +0000 Subject: [PATCH 7/7] Removed noxfile from excludes. --- owlbot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/owlbot.py b/owlbot.py index 8f9bf40a1..794140613 100644 --- a/owlbot.py +++ b/owlbot.py @@ -67,7 +67,6 @@ def place_before(path, text, *before_text, escape=None): s.move([library], excludes=[ "**/gapic_version.py", "setup.py", - "noxfile.py", "testing/constraints-3.7.txt", "testing/constraints-3.8.txt", "README.rst",