Skip to content

feat(internal/librarian/python): first part of bump for python#3938

Open
jskeet wants to merge 3 commits intogoogleapis:mainfrom
jskeet:python-bump
Open

feat(internal/librarian/python): first part of bump for python#3938
jskeet wants to merge 3 commits intogoogleapis:mainfrom
jskeet:python-bump

Conversation

@jskeet
Copy link
Contributor

@jskeet jskeet commented Feb 6, 2026

Adds version bumping for gapic_version.py files. There will be other files (in other formats) to bump over time, but this gets us a bit closer.

@jskeet jskeet requested a review from a team as a code owner February 6, 2026 16:07
Copy link
Contributor

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

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 introduces version bumping functionality for Python libraries by updating gapic_version.py files. While the implementation is well-structured and includes comprehensive unit tests, it contains a reliability issue (potential panic on directory access errors) and a security vulnerability due to insecure handling of symbolic links. These issues, particularly related to error handling, should be addressed by adding proper error checking and ensuring that only regular files are processed during directory traversal.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.32%. Comparing base (9d04c44) to head (849ee95).

Files with missing lines Patch % Lines
internal/librarian/bump.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3938      +/-   ##
==========================================
- Coverage   83.35%   83.32%   -0.03%     
==========================================
  Files          69       69              
  Lines        6188     6190       +2     
==========================================
  Hits         5158     5158              
- Misses        671      673       +2     
  Partials      359      359              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Adds version bumping for gapic_version.py files. There will be other
files (in other formats) to bump over time, but this gets us a bit
closer.
// we don't expect version numbers to require quoting). Any existing text after
// "__version__ = " (on the same line) is omitted. All other lines are
// preserved.
func bumpGapicVersions(output, version string) error {
Copy link
Member

Choose a reason for hiding this comment

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

It looks like Bump and bumpGapicVersions have the exact same function signature. Can we just inline bumpGapicVersions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There will definitely be additional files to bump. My intention is to keep Bump really simple, just calling one function after another. I figured I might as well start with the structure I want to use later.

)

const gapicVersionLinePrefix = "__version__ = "
const gapicVersionFile = "gapic_version.py"
Copy link
Member

Choose a reason for hiding this comment

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

nit:

const (
gapicVersionLinePrefix = "version = "
apicVersionFile = "gapic_version.py"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

// preserved.
func bumpGapicVersions(output, version string) error {
return filepath.WalkDir(output, func(path string, d fs.DirEntry, err error) error {
if d.Name() == gapicVersionFile {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you change to

if d.Name() != gapicVersionFile {
  return nil
}

See https://github.com/googleapis/librarian/blob/main/doc/howwewritego.md#avoid-unnecessary-else

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.

3 participants