Skip to content

Commit

Permalink
Add --version option to pyreverse (#8257) (#8258)
Browse files Browse the repository at this point in the history
(cherry picked from commit bd22f28)

Co-authored-by: Andreas Finkler <3929834+DudeNr33@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and DudeNr33 committed Feb 10, 2023
1 parent 27e3624 commit 4aedc4f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/7851.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add `--version` option to `pyreverse`.

Refs #7851
6 changes: 6 additions & 0 deletions pylint/pyreverse/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ class Run(_ArgumentsManager, _ArgumentsProvider):
name = "pyreverse"

def __init__(self, args: Sequence[str]) -> NoReturn:
# Immediately exit if user asks for version
if "--version" in args:
print("pyreverse is included in pylint:")
print(constants.full_version)
sys.exit(0)

_ArgumentsManager.__init__(self, prog="pyreverse", description=__doc__)
_ArgumentsProvider.__init__(self, self)

Expand Down
13 changes: 13 additions & 0 deletions tests/pyreverse/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,16 @@ def test_class_command(
)
assert "data.clientmodule_test.Ancestor" in runner.config.classes
assert "data.property_pattern.PropertyPatterns" in runner.config.classes


def test_version_info(
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture
) -> None:
"""Test that it is possible to display the version information."""
test_full_version = "1.2.3.4"
monkeypatch.setattr(main.constants, "full_version", test_full_version) # type: ignore[attr-defined]
with pytest.raises(SystemExit):
main.Run(["--version"])
out, _ = capsys.readouterr()
assert "pyreverse is included in pylint" in out
assert test_full_version in out

0 comments on commit 4aedc4f

Please sign in to comment.