Skip to content

ci: remove hardcoded version from _version.py via post_generate.py#177

Merged
Aaron ("AJ") Steers (aaronsteers) merged 5 commits into
mainfrom
devin/1782184333-remove-hardcoded-version
Jun 23, 2026
Merged

ci: remove hardcoded version from _version.py via post_generate.py#177
Aaron ("AJ") Steers (aaronsteers) merged 5 commits into
mainfrom
devin/1782184333-remove-hardcoded-version

Conversation

@aaronsteers

@aaronsteers Aaron ("AJ") Steers (aaronsteers) commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #175 and #176. Removes the hardcoded __version__ from the Speakeasy-generated _version.py using post_generate.py — a surgical patch that runs after each Speakeasy generation.

Approach: Let Speakeasy generate _version.py normally (keeping __openapi_doc_version__ and __gen_version__ current), then post_generate.py replaces:

-__version__: str = "1.0.0"
+__version__: str = importlib.metadata.version(__title__)

-__user_agent__: str = "speakeasy-sdk/python 1.0.0 2.911.0 1.0.0 airbyte-api"
+__user_agent__: str = (
+    f"speakeasy-sdk/python {__version__} {__gen_version__}"
+    f" {__openapi_doc_version__} {__title__}"
+)

-try:
-    if __package__ is not None:
-        __version__ = importlib.metadata.version(__package__)
-except importlib.metadata.PackageNotFoundError:
-    pass

No silent fallback — importlib.metadata.version() raises PackageNotFoundError if the package isn't installed. At build time, uv-dynamic-versioning writes the git tag version into package metadata.

The script is idempotent — running it on an already-patched file is a no-op. No .genignore needed since generation metadata stays auto-updated by Speakeasy.

Link to Devin session: https://app.devin.ai/sessions/854c664803f3400387fdaa02e123b888
Requested by: Aaron ("AJ") Steers (@aaronsteers)

Rewrites _version.py to resolve __version__ from installed package
metadata (set at build time by uv-dynamic-versioning from the git tag)
instead of hardcoding it. This matches the PyAirbyte pattern.

Adds _version.py to .genignore so Speakeasy won't overwrite it with a
hardcoded version on regeneration.

Co-Authored-By: AJ Steers <aj@airbyte.io>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Comment thread src/airbyte_api/_version.py Outdated
@aaronsteers Aaron ("AJ") Steers (aaronsteers) marked this pull request as ready for review June 23, 2026 03:17
Copilot AI review requested due to automatic review settings June 23, 2026 03:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the SDK’s runtime version reporting to derive __version__ from installed package metadata (populated by uv-dynamic-versioning from git tags), removing the hardcoded version string previously committed in _version.py.

Changes:

  • Resolve __version__ via importlib.metadata.version("airbyte-api") with a fallback when metadata is unavailable.
  • Recompute __user_agent__ based on the resolved runtime version and existing Speakeasy metadata constants.
  • Add src/airbyte_api/_version.py to .genignore to prevent regeneration from reintroducing a hardcoded version.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/airbyte_api/_version.py Switches __version__ to runtime metadata lookup and rebuilds __user_agent__; adds explanatory module docstring.
.genignore Excludes _version.py from Speakeasy regeneration to avoid hardcoded version drift.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/airbyte_api/_version.py Outdated
Comment thread .genignore Outdated
Comment thread src/airbyte_api/_version.py Outdated

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread .genignore Outdated
…lib.metadata

Instead of .genignore (which prevents Speakeasy from updating generation
metadata), let Speakeasy generate _version.py normally and then
post_generate.py surgically replaces:

- __version__: str = "X.Y.Z" → importlib.metadata.version(__title__)
- __user_agent__ static string → f-string using dynamic version
- Removes the stale try/except fallback block

Generation metadata (__openapi_doc_version__, __gen_version__) stays
intact and gets updated on each Speakeasy regeneration.

Co-Authored-By: AJ Steers <aj@airbyte.io>
@devin-ai-integration devin-ai-integration Bot changed the title ci: remove hardcoded version from _version.py, use importlib.metadata ci: remove hardcoded version from _version.py via post_generate.py Jun 23, 2026
Comment thread scripts/post_generate.uv
devin-ai-integration Bot and others added 2 commits June 23, 2026 03:36
Renames post_generate.py → post_generate.uv with PEP 723 inline
metadata and uv shebang. Updates all references in poe_tasks.toml,
AGENTS.md, and CONTRIBUTING.md.

Co-Authored-By: AJ Steers <aj@airbyte.io>
…n__ and __user_agent__

Co-Authored-By: AJ Steers <aj@airbyte.io>
Comment thread scripts/post_generate.uv Outdated
Co-Authored-By: AJ Steers <aj@airbyte.io>
@aaronsteers Aaron ("AJ") Steers (aaronsteers) merged commit 90501fe into main Jun 23, 2026
4 checks passed
@aaronsteers Aaron ("AJ") Steers (aaronsteers) deleted the devin/1782184333-remove-hardcoded-version branch June 23, 2026 03:49
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.

2 participants