diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-04-15 16:04:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-15 16:04:06 +0200 |
commit | 95f25f2330a339adee8c57a265bcea7c3d92d47e (patch) | |
tree | 960f507ec22228e0081c8aef71e1ef0ea9652702 /pylint/pyreverse | |
parent | 18bf64cb06b1f58c69c074c157b038c106ec0a31 (diff) | |
download | pylint-git-95f25f2330a339adee8c57a265bcea7c3d92d47e.tar.gz |
Transition ``pyreverse`` from ``optparse`` to ``argparse`` (#6334)
Diffstat (limited to 'pylint/pyreverse')
-rw-r--r-- | pylint/pyreverse/main.py | 21 | ||||
-rw-r--r-- | pylint/pyreverse/writer.py | 3 |
2 files changed, 12 insertions, 12 deletions
diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py index 2ad451c08..a2d83a443 100644 --- a/pylint/pyreverse/main.py +++ b/pylint/pyreverse/main.py @@ -2,17 +2,15 @@ # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE # Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt -"""%prog [options] <packages>. - - create UML diagrams for classes and modules in <packages> -""" +"""Create UML diagrams for classes and modules in <packages>.""" from __future__ import annotations import sys -from collections.abc import Iterable +from collections.abc import Sequence -from pylint.config import ConfigurationMixIn +from pylint.config.arguments_manager import _ArgumentsManager +from pylint.config.arguments_provider import _ArgumentsProvider from pylint.lint.utils import fix_import_path from pylint.pyreverse import writer from pylint.pyreverse.diadefslib import DiadefsHandler @@ -58,7 +56,7 @@ OPTIONS: Options = ( "class", dict( short="c", - action="append", + action="extend", metavar="<class>", type="csv", dest="classes", @@ -204,18 +202,19 @@ OPTIONS: Options = ( ) -class Run(ConfigurationMixIn): +class Run(_ArgumentsManager, _ArgumentsProvider): """Base class providing common behaviour for pyreverse commands.""" options = OPTIONS name = "pyreverse" - def __init__(self, args: Iterable[str]): - super().__init__(usage=__doc__) + def __init__(self, args: Sequence[str]) -> None: + _ArgumentsManager.__init__(self, prog="pyreverse", description=__doc__) + _ArgumentsProvider.__init__(self, self) # Parse options insert_default_options() - args = self.load_command_line_configuration(args) + args = self._parse_command_line_configuration(args) if self.config.output_format not in DIRECTLY_SUPPORTED_FORMATS: check_graphviz_availability() diff --git a/pylint/pyreverse/writer.py b/pylint/pyreverse/writer.py index b0f2df370..91229dc03 100644 --- a/pylint/pyreverse/writer.py +++ b/pylint/pyreverse/writer.py @@ -6,6 +6,7 @@ from __future__ import annotations +import argparse import itertools import os @@ -26,7 +27,7 @@ from pylint.pyreverse.utils import is_exception class DiagramWriter: """Base class for writing project diagrams.""" - def __init__(self, config): + def __init__(self, config: argparse.Namespace) -> None: self.config = config self.printer_class = get_printer_for_filetype(self.config.output_format) self.printer: Printer # defined in set_printer |