Skip to content

refactor: move __version__ and __version_info__ into _version.py#865

Merged
chaoming0625 merged 1 commit into
masterfrom
worktree-move-version
Jul 9, 2026
Merged

refactor: move __version__ and __version_info__ into _version.py#865
chaoming0625 merged 1 commit into
masterfrom
worktree-move-version

Conversation

@chaoming0625

@chaoming0625 chaoming0625 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Extract the version definitions from brainpy/__init__.py into a dedicated brainpy/_version.py module and re-export them from the package root.

  • brainpy._version is now the single source of truth for the version string.
  • brainpy/__init__.py re-exports __version__ and __version_info__, so pyproject's version = { attr = "brainpy.__version__" } still resolves.
  • _version.py is already listed in the coverage omit lists in pyproject.toml.

Verified import brainpy yields 2.8.0 / (2, 8, 0).

Summary by Sourcery

Enhancements:

  • Introduce brainpy._version as the single source of truth for version and version_info and re-export these attributes from brainpy.init.py.

Extract the version definitions from brainpy/__init__.py into a dedicated
brainpy/_version.py module and re-export them from the package root, so the
canonical version string lives in a single small file. pyproject already
reads brainpy.__version__ and lists _version.py in its coverage omit lists.
@sourcery-ai

sourcery-ai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors version handling by moving the package version definitions into a dedicated brainpy._version module and re-exporting them from brainpy.init to keep existing public APIs and packaging configuration working.

File-Level Changes

Change Details Files
Centralize version constants in a dedicated _version module while preserving the public API.
  • Removed inline version and version_info definitions from the package init file.
  • Added imports in the package init to re-export version and version_info from the new _version module.
  • Created a new _version module containing the version string and derived version_info tuple, with standard project license header.
brainpy/__init__.py
brainpy/_version.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chaoming0625 chaoming0625 merged commit ca1d233 into master Jul 9, 2026
5 of 13 checks passed

@sourcery-ai sourcery-ai Bot 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.

Hey - I've left some high level feedback:

  • Consider using a relative import (from ._version import __version__, __version_info__) in __init__.py to avoid potential issues if the package is ever renamed or vendored.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider using a relative import (`from ._version import __version__, __version_info__`) in `__init__.py` to avoid potential issues if the package is ever renamed or vendored.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chaoming0625 chaoming0625 deleted the worktree-move-version branch July 9, 2026 02:39
chaoming0625 added a commit that referenced this pull request Jul 9, 2026
PR #865 moved __version__ into brainpy/_version.py and made __init__ re-export
it. That broke static version resolution for consumers still pointing at
brainpy.__init__:

- pyproject.toml used `attr = "brainpy.__version__"`. setuptools reads attr via
  AST only when it is a literal assignment; after the move __init__ exposes the
  name through an ImportFrom, so setuptools falls back to importing the whole
  brainpy package. In Publish.yml's isolated `python -m build` env (no jax /
  brainstate) that import fails. Point the attr at brainpy._version.__version__,
  which resolves statically without importing the package.
- docs/conf.py imported the full brainpy package solely to read
  brainpy.__version__. Read it directly from brainpy._version instead.

brainpy/__init__.py keeps re-exporting __version__/__version_info__, so
bp.__version__ still works for users.
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