Skip to content

Fix TypeError in version display by adopting importlib.metadata#27

Open
sauravkeshrii wants to merge 1 commit intopetercorke:mainfrom
sauravkeshrii:main
Open

Fix TypeError in version display by adopting importlib.metadata#27
sauravkeshrii wants to merge 1 commit intopetercorke:mainfrom
sauravkeshrii:main

Conversation

@sauravkeshrii
Copy link

Description

This PR fixes a critical bug in rvctool.py where the script called version('package-name') – but the version function takes no arguments, leading to a TypeError at startup.

The issue is resolved by replacing the erroneous calls with the standard importlib.metadata.version('package-name') method, which reliably retrieves the installed version of any Python package. A helper function get_version gracefully handles missing packages by returning "not installed", preserving the original behaviour.

Additionally, the auto‑generated rvc3python.egg-info/ directory has been added to .gitignore to keep the working directory clean and prevent accidental commits.

Changes

  • Added import importlib.metadata
  • Introduced get_version(pkg_name) helper
  • Replaced all version(...) calls with get_version(...)
  • Updated .gitignore to ignore rvc3python.egg-info/

Testing

  • Verified that the script now runs without the TypeError
  • Confirmed version strings display correctly for installed and missing packages

This fix makes the tool more robust and user‑friendly for everyone.

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

Comments