Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Accept --version argument, to print the package version #139

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

amotl
Copy link
Contributor

@amotl amotl commented Oct 24, 2023

Hi again,

using the --version argument helps in debugging situations to find out about the installed version of pyproject-fmt.

With kind regards,
Andreas.

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

Test please.

src/pyproject_fmt/cli.py Outdated Show resolved Hide resolved
src/pyproject_fmt/cli.py Outdated Show resolved Hide resolved
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

Please add tests 👍

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

test suite is failing

@amotl
Copy link
Contributor Author

amotl commented Oct 24, 2023

test suite is failing

Apologies. It worked on my machine. I will have a look.

tests/test_cli.py Outdated Show resolved Hide resolved
@amotl amotl force-pushed the amo/cli-add-version branch 2 times, most recently from 897b269 to a63df55 Compare October 24, 2023 19:58
@amotl
Copy link
Contributor Author

amotl commented Oct 24, 2023

It looks like to works better now on CI. 🌻
Do you like the corresponding adjustments?

cli_args(["--version"])
assert context.value.code == 0
out, err = capsys.readouterr()
assert out.startswith(("pytest", "__main__.py"))
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be pyproject-fmt? Perhaps we should set prog above.

Copy link
Member

Choose a reason for hiding this comment

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

Also there's no assert that it prints out the correct version.

Copy link
Contributor Author

@amotl amotl Oct 24, 2023

Choose a reason for hiding this comment

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

Thank you.

a) The patch has been amended to define the prog parameter to ArgumentParser. Is it the right choice? If not, please educate me how to do it differently.
b) The test case has been adjusted to also verify the correct version number is actually used when printing to stdout.

@amotl amotl force-pushed the amo/cli-add-version branch 3 times, most recently from d3f0096 to 34119ba Compare October 24, 2023 23:46
This helps in debugging situations to find out about the installed
version of `pyproject_fmt`.
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

@gaborbernat gaborbernat merged commit ea4dc58 into tox-dev:main Oct 25, 2023
10 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.

None yet

2 participants