Skip to content

tests: add twine presubmit check - #18292

Draft
parthea wants to merge 4 commits into
mainfrom
add-twine-check
Draft

tests: add twine presubmit check#18292
parthea wants to merge 4 commits into
mainfrom
add-twine-check

Conversation

@parthea

@parthea parthea commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Towards #18211

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request replaces the deprecated lint_setup_py Nox session with a new lint_twine_check session across multiple packages to verify package validity using Twine. The review feedback correctly identifies critical issues in several of the updated configuration files: some files incorrectly reference the session as "twine_check" instead of "lint_twine_check", and multiple session definitions attempt to run python -m build before installing the build package, while also calling twine check without specifying the target files (e.g., dist/*).

Comment thread .librarian/generator-input/client-post-processing/bigtable-integration.yaml Outdated
Comment thread .librarian/generator-input/client-post-processing/bigtable-integration.yaml Outdated
Comment thread .librarian/generator-input/client-post-processing/spanner-integration.yaml Outdated
Comment thread packages/gapic-generator/noxfile.py Outdated
Comment thread packages/google-cloud-bigtable/noxfile.py Outdated
Comment thread packages/google-cloud-bigtable/noxfile.py Outdated
Comment thread packages/google-cloud-spanner/noxfile.py Outdated
@parthea

parthea commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request replaces the lint_setup_py Nox session with lint_twine_check across all packages to verify package validity using twine and build. A critical issue was identified where the wildcard pattern dist/* in session.run will not be expanded by the shell, causing the twine check command to fail. To resolve this, Python's glob module should be used to dynamically expand the file paths before passing them to session.run.

Comment on lines +231 to +235
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/*")

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/*"))

Comment on lines +793 to +797
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/*")

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/*"))

Comment on lines +210 to +214
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/*")

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/*"))

Comment on lines +300 to +304
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/*")

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/*"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant