summaryrefslogtreecommitdiff
path: root/pylint
diff options
context:
space:
mode:
authorAndreas Finkler <3929834+DudeNr33@users.noreply.github.com>2023-02-09 20:38:10 +0100
committerGitHub <noreply@github.com>2023-02-09 20:38:10 +0100
commitf9d796f21e0619304be4c1a3f1fb6c6578acff3b (patch)
treea9e98ac4b702a2ff5a77e07ea83da8a5caa452ba /pylint
parent71b6325c8499c8a66e90d90e88c75d7c7ab13b23 (diff)
downloadpylint-git-f9d796f21e0619304be4c1a3f1fb6c6578acff3b.tar.gz
Add `--color-palette` option to `pyreverse` (#8223)
Diffstat (limited to 'pylint')
-rw-r--r--pylint/pyreverse/main.py31
-rw-r--r--pylint/pyreverse/writer.py23
-rw-r--r--pylint/testutils/pyreverse.py4
3 files changed, 37 insertions, 21 deletions
diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py
index 13669d5b4..5641aedb8 100644
--- a/pylint/pyreverse/main.py
+++ b/pylint/pyreverse/main.py
@@ -34,6 +34,26 @@ DIRECTLY_SUPPORTED_FORMATS = (
"html",
)
+DEFAULT_COLOR_PALETTE = (
+ "aliceblue",
+ "antiquewhite",
+ "aquamarine",
+ "burlywood",
+ "cadetblue",
+ "chartreuse",
+ "chocolate",
+ "coral",
+ "cornflowerblue",
+ "cyan",
+ "darkgoldenrod",
+ "darkseagreen",
+ "dodgerblue",
+ "forestgreen",
+ "gold",
+ "hotpink",
+ "mediumspringgreen",
+)
+
OPTIONS: Options = (
(
"filter-mode",
@@ -174,6 +194,17 @@ OPTIONS: Options = (
},
),
(
+ "color-palette",
+ {
+ "dest": "color_palette",
+ "action": "store",
+ "default": DEFAULT_COLOR_PALETTE,
+ "metavar": "<color1,color2,...>",
+ "type": "csv",
+ "help": "Comma separated list of colors to use",
+ },
+ ),
+ (
"ignore",
{
"type": "csv",
diff --git a/pylint/pyreverse/writer.py b/pylint/pyreverse/writer.py
index 68a49eea1..88e3d0535 100644
--- a/pylint/pyreverse/writer.py
+++ b/pylint/pyreverse/writer.py
@@ -34,27 +34,8 @@ class DiagramWriter:
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(
- [
- "aliceblue",
- "antiquewhite",
- "aquamarine",
- "burlywood",
- "cadetblue",
- "chartreuse",
- "chocolate",
- "coral",
- "cornflowerblue",
- "cyan",
- "darkgoldenrod",
- "darkseagreen",
- "dodgerblue",
- "forestgreen",
- "gold",
- "hotpink",
- "mediumspringgreen",
- ]
- )
+ # default colors are an adaption of the seaborn colorblind palette
+ self.available_colors = itertools.cycle(self.config.color_palette)
self.used_colors: dict[str, str] = {}
def write(self, diadefs: Iterable[ClassDiagram | PackageDiagram]) -> None:
diff --git a/pylint/testutils/pyreverse.py b/pylint/testutils/pyreverse.py
index 7a61ff5fe..20dce84dd 100644
--- a/pylint/testutils/pyreverse.py
+++ b/pylint/testutils/pyreverse.py
@@ -11,6 +11,8 @@ import sys
from pathlib import Path
from typing import NamedTuple
+from pylint.pyreverse.main import DEFAULT_COLOR_PALETTE
+
if sys.version_info >= (3, 8):
from typing import TypedDict
else:
@@ -41,6 +43,7 @@ class PyreverseConfig(
output_format: str = "dot",
colorized: bool = False,
max_color_depth: int = 2,
+ color_palette: tuple[str, ...] = DEFAULT_COLOR_PALETTE,
ignore_list: tuple[str, ...] = tuple(),
project: str = "",
output_directory: str = "",
@@ -61,6 +64,7 @@ class PyreverseConfig(
self.output_format = output_format
self.colorized = colorized
self.max_color_depth = max_color_depth
+ self.color_palette = color_palette
self.ignore_list = ignore_list
self.project = project
self.output_directory = output_directory