Skip to content

Commit 4aedc4f

Browse files
Add --version option to pyreverse (#8257) (#8258)
(cherry picked from commit bd22f28) Co-authored-by: Andreas Finkler <[email protected]>
1 parent 27e3624 commit 4aedc4f

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

doc/whatsnew/fragments/7851.feature

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add `--version` option to `pyreverse`.
2+
3+
Refs #7851

pylint/pyreverse/main.py

+6
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ class Run(_ArgumentsManager, _ArgumentsProvider):
213213
name = "pyreverse"
214214

215215
def __init__(self, args: Sequence[str]) -> NoReturn:
216+
# Immediately exit if user asks for version
217+
if "--version" in args:
218+
print("pyreverse is included in pylint:")
219+
print(constants.full_version)
220+
sys.exit(0)
221+
216222
_ArgumentsManager.__init__(self, prog="pyreverse", description=__doc__)
217223
_ArgumentsProvider.__init__(self, self)
218224

tests/pyreverse/test_main.py

+13
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,16 @@ def test_class_command(
189189
)
190190
assert "data.clientmodule_test.Ancestor" in runner.config.classes
191191
assert "data.property_pattern.PropertyPatterns" in runner.config.classes
192+
193+
194+
def test_version_info(
195+
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture
196+
) -> None:
197+
"""Test that it is possible to display the version information."""
198+
test_full_version = "1.2.3.4"
199+
monkeypatch.setattr(main.constants, "full_version", test_full_version) # type: ignore[attr-defined]
200+
with pytest.raises(SystemExit):
201+
main.Run(["--version"])
202+
out, _ = capsys.readouterr()
203+
assert "pyreverse is included in pylint" in out
204+
assert test_full_version in out

0 commit comments

Comments
 (0)