Skip to content

refactor(version): remove hardcoded __version__, resolve from setup.py only#55

Merged
advaitpatel merged 2 commits into
mainfrom
refactor/single-source-version
Apr 2, 2026
Merged

refactor(version): remove hardcoded __version__, resolve from setup.py only#55
advaitpatel merged 2 commits into
mainfrom
refactor/single-source-version

Conversation

@advaitpatel
Copy link
Copy Markdown
Collaborator

Description

Removes the hardcoded __version__ = "2026.2.23" constant from docksec.py. Version is now read dynamically so setup.py is the single source of truth — no risk of the two drifting out of sync.

How it works

get_version() resolution order:

  1. importlib.metadata.version("docksec") — works when installed via pip
  2. Parses version= from setup.py on disk — works when running from source
  3. Returns "unknown" as a last resort

Before vs After

Before — two places to update on every release:

  • setup.py: version="2026.2.23"
  • docksec.py: __version__ = "2026.2.23" (could drift)

After — one place only:

  • setup.py: version="2026.4.2"
  • docksec.py: no hardcoded version constant

Type of Change

  • Code refactoring (no functional changes)

Checklist

  • Code follows the style guidelines of this project
  • Self-review completed
  • No new warnings or errors introduced
  • All existing tests pass

…lve from setup.py only

Version is now read via importlib.metadata (installed) or by parsing setup.py
(source). setup.py is the single source of truth — no hardcoded constant to
drift out of sync.
Comment thread docksec.py Outdated
match = re.search(r'version="([^"]+)"', f.read())
if match:
return match.group(1)
except Exception:

Check notice

Code scanning / CodeQL

Empty except

'except' clause does nothing but pass and there is no explanatory comment.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

resolved this issue

@advaitpatel advaitpatel merged commit 88fcb2d into main Apr 2, 2026
6 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.

2 participants