Skip to content

docs: fixes version detection logic#561

Merged
psschwei merged 1 commit intogenerative-computing:mainfrom
serjikibm:docs-action-fix
Feb 26, 2026
Merged

docs: fixes version detection logic#561
psschwei merged 1 commit intogenerative-computing:mainfrom
serjikibm:docs-action-fix

Conversation

@serjikibm
Copy link
Contributor

@serjikibm serjikibm commented Feb 26, 2026

Misc PR

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

  • Link to Issue:

The Problem:
The GitHub Action is passing --pypi-version main to the script. The normalize_version function in tooling/docs-autogen/generate-ast.py at L64-L67, only strips a leading "v" from versions but doesn't handle branch names like "main".

This results in pip_install constructing mellea==main at tooling/docs-autogen/generate-ast.py at L171, which is invalid pip syntax. Pip expects a semver version like 0.3.0, not a git branch name.

The normalize_version function doesn't validate that the version is actually a valid version number. When "main" is passed, it's passed through unchanged, creating the invalid requirement mellea==main.

The Fix:
Update normalize_version to return None for non-version strings like "main" (or any value that doesn't look like a valid version). When normalize_version returns None, pip_install already handles it correctly by installing without a version pin (i.e., latest from PyPI).

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code as added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Manually tested with this snippet

def normalize_version(v):
    if not v:
        return None
    v = v[1:] if v.startswith('v') else v
    if not v or not v[0].isdigit():
        return None
    return v

tests = [
    ('main', None),
    ('master', None),
    ('v0.3.0', '0.3.0'),
    ('0.3.0', '0.3.0'),
    (None, None),
    ('', None),
]

for input_val, expected in tests:
    result = normalize_version(input_val)
    status = '✓' if result == expected else '✗'
    print(f'{status} normalize_version({input_val!r}) = {result!r} (expected {expected!r})')

@serjikibm serjikibm requested a review from a team as a code owner February 26, 2026 14:32
@github-actions
Copy link
Contributor

The PR description has been updated. Please fill out the template for your PR to be reviewed.

@mergify
Copy link

mergify bot commented Feb 26, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

@psschwei psschwei added this pull request to the merge queue Feb 26, 2026
Merged via the queue into generative-computing:main with commit 7393095 Feb 26, 2026
10 of 12 checks passed
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.

4 participants