Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ jobs:
PY_VERSION: "unused"
run: |
ci/run_conditional_tests.sh
- name: Run lint_setup_py
- name: Run twine check
env:
BUILD_TYPE: presubmit
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
TEST_ALL_PACKAGES: ${{ steps.check-label.outputs.is_full_run }}
TEST_TYPE: lint_setup_py
TEST_TYPE: lint_twine_check
# TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session.
PY_VERSION: "unused"
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ replacements:
"mypy",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
"format",
Expand Down Expand Up @@ -567,10 +567,11 @@ replacements:


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ replacements:
count: 1
- paths:
- "packages/google-cloud-pubsub/noxfile.py"
before: 'nox\.options\.sessions = \[\n(?:[ \t]+)"unit",\n(?:[ \t]+)"system",\n(?:[ \t]+)"cover",\n(?:[ \t]+)"lint",\n(?:[ \t]+)"lint_setup_py",\n(?:[ \t]+)"blacken",\n(?:[ \t]+)"docs",\n\]'
before: 'nox\.options\.sessions = \[\n(?:[ \t]+)"unit",\n(?:[ \t]+)"system",\n(?:[ \t]+)"cover",\n(?:[ \t]+)"lint",\n(?:[ \t]+)"lint_twine_check",\n(?:[ \t]+)"blacken",\n(?:[ \t]+)"docs",\n\]'
after: |-
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
# Path to the centralized mypy configuration file at the repository root.
Expand All @@ -420,7 +420,7 @@ replacements:
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"mypy",
# https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ replacements:
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
"docfx",
Expand Down Expand Up @@ -821,10 +821,11 @@ replacements:


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
2 changes: 1 addition & 1 deletion ci/run_single_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

# This script requires the following environment variables to be set:
# `TEST_TYPE` should be one of ["lint", "lint_setup_py", "docs", "docfx", "prerelease"]
# `TEST_TYPE` should be one of ["lint", "lint_twine_check", "docs", "docfx", "prerelease"]
# `PY_VERSION` should be one of ["3.10", "3.11", "3.12", "3.13"]

# This script is called by the `ci/run_conditional_tests.sh` script.
Expand Down
11 changes: 6 additions & 5 deletions packages/gapic-generator/gapic/templates/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ nox.options.sessions = [
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -228,10 +228,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")
Comment on lines +231 to +235

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In nox, session.run executes commands directly without a shell by default (shell=False). Consequently, the wildcard pattern dist/* will not be expanded by the shell, and twine will receive the literal string 'dist/*', causing the check to fail. Use Python's glob module to expand the wildcard pattern before passing the file paths to session.run.

def lint_twine_check(session):
    """Verify that the package is valid using twine."""
    session.install("twine", "build")
    session.run("python", "-m", "build", "--sdist")
    import glob
    session.run("twine", "check", "--strict", *glob.glob("dist/*"))



def install_unittest_dependencies(session, *constraints):
Expand Down
12 changes: 5 additions & 7 deletions packages/gapic-generator/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,11 @@ def lint(session):


@nox.session(python=NEWEST_PYTHON)
def lint_setup_py(session):
# TODO(https://github.com/googleapis/google-cloud-python/issues/16186):
# SKIP: This session was not enforced in the standalone (split) repo
# and is disabled here to ensure a "move-only" migration.
session.skip(
"Skipping now to avoid changing code during migration. See Issue #16186"
)
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")
Comment on lines +793 to +797

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In nox, session.run executes commands directly without a shell by default (shell=False). Consequently, the wildcard pattern dist/* will not be expanded by the shell, and twine will receive the literal string 'dist/*', causing the check to fail. Use Python's glob module to expand the wildcard pattern before passing the file paths to session.run.

Suggested change
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
import glob
session.run("twine", "check", "--strict", *glob.glob("dist/*"))



@nox.session(python="3.10")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -226,10 +226,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -226,10 +226,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -226,10 +226,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -226,10 +226,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -226,10 +226,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -226,10 +226,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -226,10 +226,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -226,10 +226,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
11 changes: 6 additions & 5 deletions packages/google-ads-admanager/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -239,10 +239,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
11 changes: 6 additions & 5 deletions packages/google-ads-datamanager/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"system",
"cover",
"lint",
"lint_setup_py",
"lint_twine_check",
"blacken",
"docs",
]
Expand Down Expand Up @@ -239,10 +239,11 @@ def format(session):


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("setuptools", "docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
def lint_twine_check(session):
"""Verify that the package is valid using twine."""
session.install("twine", "build")
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


def install_unittest_dependencies(session, *constraints):
Expand Down
Loading
Loading