From 8e5226ece07f1c8b9e5a742f705aa867b4894fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Mon, 21 Nov 2022 20:28:01 +0545 Subject: [PATCH] cli: remove version action --- dvc/cli/parser.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/dvc/cli/parser.py b/dvc/cli/parser.py index c1ce67183..c4f527f5d 100644 --- a/dvc/cli/parser.py +++ b/dvc/cli/parser.py @@ -2,8 +2,8 @@ import argparse import logging import os -import sys +from dvc import __version__ from dvc.commands import ( add, cache, @@ -128,17 +128,6 @@ class DvcParser(argparse.ArgumentParser): return args -class VersionAction(argparse.Action): # pragma: no cover - # pylint: disable=too-few-public-methods - """Shows DVC version and exits.""" - - def __call__(self, parser, namespace, values, option_string=None): - from dvc import __version__ - - print(__version__) - sys.exit(0) - - def get_parent_parser(): """Create instances of a parser containing common arguments shared among all the commands. @@ -186,13 +175,11 @@ def get_main_parser(): help="Show this help message and exit.", ) - # NOTE: On some python versions action='version' prints to stderr - # instead of stdout https://bugs.python.org/issue18920 parser.add_argument( "-V", "--version", - action=VersionAction, - nargs=0, + action="version", + version=__version__, help="Show program's version.", )