summaryrefslogtreecommitdiff
path: root/pylint
diff options
context:
space:
mode:
authorAndreas Finkler <3929834+DudeNr33@users.noreply.github.com>2022-04-15 12:26:54 +0200
committerGitHub <noreply@github.com>2022-04-15 12:26:54 +0200
commit64675c571f60bc5146b0e81a48126c1e088a205a (patch)
tree237a9e946abe70f77f390ae9b5438cc1ef6771ee /pylint
parent868f5d573b4d282ce258be009cd25d624894fe65 (diff)
parentf120a798bbe122e87442fa9df809057777fb658a (diff)
downloadpylint-git-64675c571f60bc5146b0e81a48126c1e088a205a.tar.gz
Merge pull request #6298 from DanielNoord/argparse-pyreverse-2
Add typing and small refactors to pyreverse
Diffstat (limited to 'pylint')
-rw-r--r--pylint/config/arguments_manager.py3
-rw-r--r--pylint/pyreverse/main.py4
-rw-r--r--pylint/pyreverse/utils.py4
-rw-r--r--pylint/pyreverse/writer.py8
4 files changed, 13 insertions, 6 deletions
diff --git a/pylint/config/arguments_manager.py b/pylint/config/arguments_manager.py
index ec7ec3fbc..b1712ad7f 100644
--- a/pylint/config/arguments_manager.py
+++ b/pylint/config/arguments_manager.py
@@ -16,6 +16,7 @@ import re
import sys
import textwrap
import warnings
+from collections.abc import Sequence
from pathlib import Path
from typing import TYPE_CHECKING, Any, TextIO, Union
@@ -224,7 +225,7 @@ class _ArgumentsManager:
self.config = self._arg_parser.parse_known_args(arguments, self.config)[0]
def _parse_command_line_configuration(
- self, arguments: list[str] | None = None
+ self, arguments: Sequence[str] | None = None
) -> list[str]:
"""Parse the arguments found on the command line into the namespace."""
arguments = sys.argv[1:] if arguments is None else arguments
diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py
index fcb82bc25..2ad451c08 100644
--- a/pylint/pyreverse/main.py
+++ b/pylint/pyreverse/main.py
@@ -208,11 +208,15 @@ class Run(ConfigurationMixIn):
"""Base class providing common behaviour for pyreverse commands."""
options = OPTIONS
+ name = "pyreverse"
def __init__(self, args: Iterable[str]):
super().__init__(usage=__doc__)
+
+ # Parse options
insert_default_options()
args = self.load_command_line_configuration(args)
+
if self.config.output_format not in DIRECTLY_SUPPORTED_FORMATS:
check_graphviz_availability()
print(
diff --git a/pylint/pyreverse/utils.py b/pylint/pyreverse/utils.py
index 2bd8585e0..393ff8c77 100644
--- a/pylint/pyreverse/utils.py
+++ b/pylint/pyreverse/utils.py
@@ -18,7 +18,7 @@ from astroid import nodes
RCFILE = ".pyreverserc"
-def get_default_options():
+def get_default_options() -> list[str]:
"""Read config file and return list of options."""
options = []
home = os.environ.get("HOME", "")
@@ -32,7 +32,7 @@ def get_default_options():
return options
-def insert_default_options():
+def insert_default_options() -> None:
"""Insert default options to sys.argv."""
options = get_default_options()
options.reverse()
diff --git a/pylint/pyreverse/writer.py b/pylint/pyreverse/writer.py
index a3120e6d9..b0f2df370 100644
--- a/pylint/pyreverse/writer.py
+++ b/pylint/pyreverse/writer.py
@@ -4,6 +4,8 @@
"""Utilities for creating VCG and Dot diagrams."""
+from __future__ import annotations
+
import itertools
import os
@@ -16,7 +18,7 @@ from pylint.pyreverse.diagrams import (
PackageDiagram,
PackageEntity,
)
-from pylint.pyreverse.printer import EdgeType, NodeProperties, NodeType
+from pylint.pyreverse.printer import EdgeType, NodeProperties, NodeType, Printer
from pylint.pyreverse.printer_factory import get_printer_for_filetype
from pylint.pyreverse.utils import is_exception
@@ -27,7 +29,7 @@ class DiagramWriter:
def __init__(self, config):
self.config = config
self.printer_class = get_printer_for_filetype(self.config.output_format)
- self.printer = None # defined in set_printer
+ self.printer: Printer # defined in set_printer
self.file_name = "" # defined in set_printer
self.depth = self.config.max_color_depth
self.available_colors = itertools.cycle(
@@ -51,7 +53,7 @@ class DiagramWriter:
"mediumspringgreen",
]
)
- self.used_colors = {}
+ self.used_colors: dict[str, str] = {}
def write(self, diadefs):
"""Write files for <project> according to <diadefs>."""