tests: add twine presubmit check - #18292
Conversation
There was a problem hiding this comment.
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/*).
b955710 to
ccd0c73
Compare
|
/gemini review |
There was a problem hiding this comment.
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.
| 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/*") |
There was a problem hiding this comment.
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 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/*") |
There was a problem hiding this comment.
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") | |
| 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/*")) |
| 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/*") |
There was a problem hiding this comment.
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") | |
| 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/*")) |
| 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/*") |
There was a problem hiding this comment.
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") | |
| 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/*")) |
Towards #18211