dzhu/rstfmt

Cannot check version of rstfmt binary

kayhayen opened this issue · 2 comments

Hello,

something I found missing when I was adding it to my commit hook, is the ability to check the version used, if it's current. My formatting and commit hooks check the versions of isort, black, pylint etc. against the requirements file, so make sure nobody misses out on an update and uses a tool that potentially undoes things or does it incorrectly.

Since it may use a rstfmt.exe on Windows, there is no real way to know which Python it belongs to, so asking pip is not a good idea. The rstfmt package has no version attribute. I would have liked to find __version__ set, and as I added a plugin for that in Nuitka recently, using something like pkg_resources.get_distribution("rstfmt").parsed_version would be a good addition, and means you have no double booking of the version, I think it will take what's in pip or setup.py somehow. But I would prefer a --version command line flag for that to be output.

I also found that a style of execution, with python -m rstfmt would be really nice to have. It allows me to know exactly which Python binary is used and most tools support that. It really only needs a __main__.py in your package.

For now though, I am unable to check the rstfmt version and will have to live without a version check. But please add it. :)

dzhu commented

Hi! Great suggestions. Version 0.0.9, now on PyPI, supports python -m rstfmt and rstfmt --version. I just noticed, after uploading the new version, that you also mentioned a programmatically accessible __version__ variable. I'm not quite sure: is that something you would like in addition to the CLI flag or was it meant as an alternative?

It's just something, that you could have used, ultimately what counts is that the version is properly output and correct, and bumped on releases. ;-)