summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Finkler <3929834+DudeNr33@users.noreply.github.com>2023-03-10 21:48:48 +0100
committerGitHub <noreply@github.com>2023-03-10 20:48:48 +0000
commit0d26e3cda507bb1a5bca21a0a6e3b86a8ffe92b6 (patch)
tree5b9cf8d60067ac5a9fa697007df7ae5b28905fd3
parentceb241047100db4821aaf9bd0edcbe4c4f5d86fc (diff)
downloadpylint-git-0d26e3cda507bb1a5bca21a0a6e3b86a8ffe92b6.tar.gz
`pyreverse`: use colorblind friendly default colors (#8415)
Using Paul Tol's colorblind palette. Also enable both hex codes and css/html color names Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
-rw-r--r--.pyenchant_pylint_custom_dict.txt1
-rw-r--r--doc/whatsnew/fragments/8251.breaking5
-rw-r--r--pylint/pyreverse/main.py27
-rw-r--r--pylint/pyreverse/plantuml_printer.py2
-rw-r--r--tests/pyreverse/data/classes_colorized.dot16
-rw-r--r--tests/pyreverse/data/classes_colorized.puml16
-rw-r--r--tests/pyreverse/data/packages_colorized.dot8
-rw-r--r--tests/pyreverse/data/packages_colorized.puml8
-rw-r--r--tests/pyreverse/functional/class_diagrams/colorized_output/colorized.puml8
-rw-r--r--tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.dot11
-rw-r--r--tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml2
-rw-r--r--tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc4
12 files changed, 59 insertions, 49 deletions
diff --git a/.pyenchant_pylint_custom_dict.txt b/.pyenchant_pylint_custom_dict.txt
index 5969ff639..507babde2 100644
--- a/.pyenchant_pylint_custom_dict.txt
+++ b/.pyenchant_pylint_custom_dict.txt
@@ -132,6 +132,7 @@ globbing
GPL
graphname
graphviz
+grey
guido's
gv
hashable
diff --git a/doc/whatsnew/fragments/8251.breaking b/doc/whatsnew/fragments/8251.breaking
new file mode 100644
index 000000000..5410c9a98
--- /dev/null
+++ b/doc/whatsnew/fragments/8251.breaking
@@ -0,0 +1,5 @@
+`pyreverse` now uses a new default color palette that is more colorblind friendly.
+The color scheme is taken from `Paul Tol's Notes <https://personal.sron.nl/~pault/>`_.
+If you prefer other colors, you can use the `--color-palette` option to specify custom colors.
+
+Closes #8251
diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py
index c2eaf699b..8cd0d567e 100644
--- a/pylint/pyreverse/main.py
+++ b/pylint/pyreverse/main.py
@@ -34,23 +34,16 @@ DIRECTLY_SUPPORTED_FORMATS = (
)
DEFAULT_COLOR_PALETTE = (
- "aliceblue",
- "antiquewhite",
- "aquamarine",
- "burlywood",
- "cadetblue",
- "chartreuse",
- "chocolate",
- "coral",
- "cornflowerblue",
- "cyan",
- "darkgoldenrod",
- "darkseagreen",
- "dodgerblue",
- "forestgreen",
- "gold",
- "hotpink",
- "mediumspringgreen",
+ # colorblind scheme taken from https://personal.sron.nl/~pault/
+ "#77AADD", # light blue
+ "#99DDFF", # light cyan
+ "#44BB99", # mint
+ "#BBCC33", # pear
+ "#AAAA00", # olive
+ "#EEDD88", # light yellow
+ "#EE8866", # orange
+ "#FFAABB", # pink
+ "#DDDDDD", # pale grey
)
OPTIONS: Options = (
diff --git a/pylint/pyreverse/plantuml_printer.py b/pylint/pyreverse/plantuml_printer.py
index 73c9b2640..42cd6e43c 100644
--- a/pylint/pyreverse/plantuml_printer.py
+++ b/pylint/pyreverse/plantuml_printer.py
@@ -56,7 +56,7 @@ class PlantUmlPrinter(Printer):
properties = NodeProperties(label=name)
nodetype = self.NODES[type_]
if properties.color and properties.color != self.DEFAULT_COLOR:
- color = f" #{properties.color}"
+ color = f" #{properties.color.lstrip('#')}"
else:
color = ""
body = []
diff --git a/tests/pyreverse/data/classes_colorized.dot b/tests/pyreverse/data/classes_colorized.dot
index 3ea2d8395..7c43f0888 100644
--- a/tests/pyreverse/data/classes_colorized.dot
+++ b/tests/pyreverse/data/classes_colorized.dot
@@ -1,14 +1,14 @@
digraph "classes_colorized" {
rankdir=BT
charset="utf-8"
-"data.clientmodule_test.Ancestor" [color="aliceblue", fontcolor="black", label=<{Ancestor|attr : str<br ALIGN="LEFT"/>cls_member<br ALIGN="LEFT"/>|get_value()<br ALIGN="LEFT"/>set_value(value)<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
-"data.suppliermodule_test.CustomException" [color="aliceblue", fontcolor="red", label=<{CustomException|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"];
-"data.suppliermodule_test.DoNothing" [color="aliceblue", fontcolor="black", label=<{DoNothing|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"];
-"data.suppliermodule_test.DoNothing2" [color="aliceblue", fontcolor="black", label=<{DoNothing2|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"];
-"data.suppliermodule_test.DoSomething" [color="aliceblue", fontcolor="black", label=<{DoSomething|my_int : Optional[int]<br ALIGN="LEFT"/>my_int_2 : Optional[int]<br ALIGN="LEFT"/>my_string : str<br ALIGN="LEFT"/>|do_it(new_int: int): int<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
-"data.suppliermodule_test.Interface" [color="aliceblue", fontcolor="black", label=<{Interface|<br ALIGN="LEFT"/>|<I>get_value</I>()<br ALIGN="LEFT"/><I>set_value</I>(value)<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
-"data.property_pattern.PropertyPatterns" [color="aliceblue", fontcolor="black", label=<{PropertyPatterns|prop1<br ALIGN="LEFT"/>prop2<br ALIGN="LEFT"/>|}>, shape="record", style="filled"];
-"data.clientmodule_test.Specialization" [color="aliceblue", fontcolor="black", label=<{Specialization|TYPE : str<br ALIGN="LEFT"/>relation<br ALIGN="LEFT"/>relation2<br ALIGN="LEFT"/>top : str<br ALIGN="LEFT"/>|from_value(value: int)<br ALIGN="LEFT"/>increment_value(): None<br ALIGN="LEFT"/>transform_value(value: int): int<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
+"data.clientmodule_test.Ancestor" [color="#77AADD", fontcolor="black", label=<{Ancestor|attr : str<br ALIGN="LEFT"/>cls_member<br ALIGN="LEFT"/>|get_value()<br ALIGN="LEFT"/>set_value(value)<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
+"data.suppliermodule_test.CustomException" [color="#77AADD", fontcolor="red", label=<{CustomException|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"];
+"data.suppliermodule_test.DoNothing" [color="#77AADD", fontcolor="black", label=<{DoNothing|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"];
+"data.suppliermodule_test.DoNothing2" [color="#77AADD", fontcolor="black", label=<{DoNothing2|<br ALIGN="LEFT"/>|}>, shape="record", style="filled"];
+"data.suppliermodule_test.DoSomething" [color="#77AADD", fontcolor="black", label=<{DoSomething|my_int : Optional[int]<br ALIGN="LEFT"/>my_int_2 : Optional[int]<br ALIGN="LEFT"/>my_string : str<br ALIGN="LEFT"/>|do_it(new_int: int): int<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
+"data.suppliermodule_test.Interface" [color="#77AADD", fontcolor="black", label=<{Interface|<br ALIGN="LEFT"/>|<I>get_value</I>()<br ALIGN="LEFT"/><I>set_value</I>(value)<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
+"data.property_pattern.PropertyPatterns" [color="#77AADD", fontcolor="black", label=<{PropertyPatterns|prop1<br ALIGN="LEFT"/>prop2<br ALIGN="LEFT"/>|}>, shape="record", style="filled"];
+"data.clientmodule_test.Specialization" [color="#77AADD", fontcolor="black", label=<{Specialization|TYPE : str<br ALIGN="LEFT"/>relation<br ALIGN="LEFT"/>relation2<br ALIGN="LEFT"/>top : str<br ALIGN="LEFT"/>|from_value(value: int)<br ALIGN="LEFT"/>increment_value(): None<br ALIGN="LEFT"/>transform_value(value: int): int<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
"data.clientmodule_test.Specialization" -> "data.clientmodule_test.Ancestor" [arrowhead="empty", arrowtail="none"];
"data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Ancestor" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="cls_member", style="solid"];
"data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Specialization" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="relation", style="solid"];
diff --git a/tests/pyreverse/data/classes_colorized.puml b/tests/pyreverse/data/classes_colorized.puml
index d96ee3e4f..d1106153d 100644
--- a/tests/pyreverse/data/classes_colorized.puml
+++ b/tests/pyreverse/data/classes_colorized.puml
@@ -1,32 +1,32 @@
@startuml classes_colorized
set namespaceSeparator none
-class "Ancestor" as data.clientmodule_test.Ancestor #aliceblue {
+class "Ancestor" as data.clientmodule_test.Ancestor #77AADD {
attr : str
cls_member
get_value()
set_value(value)
}
-class "<color:red>CustomException</color>" as data.suppliermodule_test.CustomException #aliceblue {
+class "<color:red>CustomException</color>" as data.suppliermodule_test.CustomException #77AADD {
}
-class "DoNothing" as data.suppliermodule_test.DoNothing #aliceblue {
+class "DoNothing" as data.suppliermodule_test.DoNothing #77AADD {
}
-class "DoNothing2" as data.suppliermodule_test.DoNothing2 #aliceblue {
+class "DoNothing2" as data.suppliermodule_test.DoNothing2 #77AADD {
}
-class "DoSomething" as data.suppliermodule_test.DoSomething #aliceblue {
+class "DoSomething" as data.suppliermodule_test.DoSomething #77AADD {
my_int : Optional[int]
my_int_2 : Optional[int]
my_string : str
do_it(new_int: int) -> int
}
-class "Interface" as data.suppliermodule_test.Interface #aliceblue {
+class "Interface" as data.suppliermodule_test.Interface #77AADD {
{abstract}get_value()
{abstract}set_value(value)
}
-class "PropertyPatterns" as data.property_pattern.PropertyPatterns #aliceblue {
+class "PropertyPatterns" as data.property_pattern.PropertyPatterns #77AADD {
prop1
prop2
}
-class "Specialization" as data.clientmodule_test.Specialization #aliceblue {
+class "Specialization" as data.clientmodule_test.Specialization #77AADD {
TYPE : str
relation
relation2
diff --git a/tests/pyreverse/data/packages_colorized.dot b/tests/pyreverse/data/packages_colorized.dot
index 10005f26c..69346a355 100644
--- a/tests/pyreverse/data/packages_colorized.dot
+++ b/tests/pyreverse/data/packages_colorized.dot
@@ -1,9 +1,9 @@
digraph "packages_colorized" {
rankdir=BT
charset="utf-8"
-"data" [color="aliceblue", label=<data>, shape="box", style="filled"];
-"data.clientmodule_test" [color="aliceblue", label=<data.clientmodule_test>, shape="box", style="filled"];
-"data.property_pattern" [color="aliceblue", label=<data.property_pattern>, shape="box", style="filled"];
-"data.suppliermodule_test" [color="aliceblue", label=<data.suppliermodule_test>, shape="box", style="filled"];
+"data" [color="#77AADD", label=<data>, shape="box", style="filled"];
+"data.clientmodule_test" [color="#77AADD", label=<data.clientmodule_test>, shape="box", style="filled"];
+"data.property_pattern" [color="#77AADD", label=<data.property_pattern>, shape="box", style="filled"];
+"data.suppliermodule_test" [color="#77AADD", label=<data.suppliermodule_test>, shape="box", style="filled"];
"data.clientmodule_test" -> "data.suppliermodule_test" [arrowhead="open", arrowtail="none"];
}
diff --git a/tests/pyreverse/data/packages_colorized.puml b/tests/pyreverse/data/packages_colorized.puml
index 353ae8c47..afc12b512 100644
--- a/tests/pyreverse/data/packages_colorized.puml
+++ b/tests/pyreverse/data/packages_colorized.puml
@@ -1,15 +1,15 @@
@startuml packages_colorized
set namespaceSeparator none
-package "data" as data #aliceblue {
+package "data" as data #77AADD {
}
-package "data.clientmodule_test" as data.clientmodule_test #aliceblue {
+package "data.clientmodule_test" as data.clientmodule_test #77AADD {
}
-package "data.property_pattern" as data.property_pattern #aliceblue {
+package "data.property_pattern" as data.property_pattern #77AADD {
}
-package "data.suppliermodule_test" as data.suppliermodule_test #aliceblue {
+package "data.suppliermodule_test" as data.suppliermodule_test #77AADD {
}
data.clientmodule_test --> data.suppliermodule_test
diff --git a/tests/pyreverse/functional/class_diagrams/colorized_output/colorized.puml b/tests/pyreverse/functional/class_diagrams/colorized_output/colorized.puml
index a5ccf11f7..10575159d 100644
--- a/tests/pyreverse/functional/class_diagrams/colorized_output/colorized.puml
+++ b/tests/pyreverse/functional/class_diagrams/colorized_output/colorized.puml
@@ -1,18 +1,18 @@
@startuml classes
set namespaceSeparator none
-class "CheckerCollector" as colorized.CheckerCollector #aliceblue {
+class "CheckerCollector" as colorized.CheckerCollector #77AADD {
checker1
checker2
checker3
}
-class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #antiquewhite {
+class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #99DDFF {
msgs : dict
name : str
leave_module(_: nodes.Module) -> None
process_tokens(tokens: list[TokenInfo]) -> None
visit_if(node: nodes.If) -> None
}
-class "ExceptionsChecker" as pylint.checkers.exceptions.ExceptionsChecker #aquamarine {
+class "ExceptionsChecker" as pylint.checkers.exceptions.ExceptionsChecker #44BB99 {
msgs : dict
name : str
options : tuple
@@ -22,7 +22,7 @@ class "ExceptionsChecker" as pylint.checkers.exceptions.ExceptionsChecker #aquam
visit_raise(node: nodes.Raise) -> None
visit_tryexcept(node: nodes.TryExcept) -> None
}
-class "StdlibChecker" as pylint.checkers.stdlib.StdlibChecker #aquamarine {
+class "StdlibChecker" as pylint.checkers.stdlib.StdlibChecker #44BB99 {
msgs : dict[str, MessageDefinitionTuple]
name : str
deprecated_arguments(method: str) -> tuple[tuple[int | None, str], ...]
diff --git a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.dot b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.dot
new file mode 100644
index 000000000..e1af85e58
--- /dev/null
+++ b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.dot
@@ -0,0 +1,11 @@
+digraph "classes" {
+rankdir=BT
+charset="utf-8"
+"custom_colors.CheckerCollector" [color="red", fontcolor="black", label=<{CheckerCollector|checker1<br ALIGN="LEFT"/>checker2<br ALIGN="LEFT"/>checker3<br ALIGN="LEFT"/>|}>, shape="record", style="filled"];
+"pylint.extensions.check_elif.ElseifUsedChecker" [color="#44BB88", fontcolor="black", label=<{ElseifUsedChecker|msgs : dict<br ALIGN="LEFT"/>name : str<br ALIGN="LEFT"/>|leave_module(_: nodes.Module): None<br ALIGN="LEFT"/>process_tokens(tokens: list[TokenInfo]): None<br ALIGN="LEFT"/>visit_if(node: nodes.If): None<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
+"pylint.checkers.exceptions.ExceptionsChecker" [color="yellow", fontcolor="black", label=<{ExceptionsChecker|msgs : dict<br ALIGN="LEFT"/>name : str<br ALIGN="LEFT"/>options : tuple<br ALIGN="LEFT"/>|open(): None<br ALIGN="LEFT"/>visit_binop(node: nodes.BinOp): None<br ALIGN="LEFT"/>visit_compare(node: nodes.Compare): None<br ALIGN="LEFT"/>visit_raise(node: nodes.Raise): None<br ALIGN="LEFT"/>visit_tryexcept(node: nodes.TryExcept): None<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
+"pylint.checkers.stdlib.StdlibChecker" [color="yellow", fontcolor="black", label=<{StdlibChecker|msgs : dict[str, MessageDefinitionTuple]<br ALIGN="LEFT"/>name : str<br ALIGN="LEFT"/>|deprecated_arguments(method: str): tuple[tuple[int | None, str], ...]<br ALIGN="LEFT"/>deprecated_classes(module: str): Iterable[str]<br ALIGN="LEFT"/>deprecated_decorators(): Iterable[str]<br ALIGN="LEFT"/>deprecated_methods(): set[str]<br ALIGN="LEFT"/>visit_boolop(node: nodes.BoolOp): None<br ALIGN="LEFT"/>visit_call(node: nodes.Call): None<br ALIGN="LEFT"/>visit_functiondef(node: nodes.FunctionDef): None<br ALIGN="LEFT"/>visit_if(node: nodes.If): None<br ALIGN="LEFT"/>visit_ifexp(node: nodes.IfExp): None<br ALIGN="LEFT"/>visit_unaryop(node: nodes.UnaryOp): None<br ALIGN="LEFT"/>}>, shape="record", style="filled"];
+"pylint.checkers.exceptions.ExceptionsChecker" -> "custom_colors.CheckerCollector" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="checker1", style="solid"];
+"pylint.checkers.stdlib.StdlibChecker" -> "custom_colors.CheckerCollector" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="checker3", style="solid"];
+"pylint.extensions.check_elif.ElseifUsedChecker" -> "custom_colors.CheckerCollector" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="checker2", style="solid"];
+}
diff --git a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml
index 34dc814ff..f2cea9f63 100644
--- a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml
+++ b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml
@@ -5,7 +5,7 @@ class "CheckerCollector" as custom_colors.CheckerCollector #red {
checker2
checker3
}
-class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #green {
+class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #44BB88 {
msgs : dict
name : str
leave_module(_: nodes.Module) -> None
diff --git a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc
index ea30ad4a4..08f68bbb3 100644
--- a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc
+++ b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc
@@ -1,3 +1,3 @@
[testoptions]
-output_formats=puml
-command_line_args=-S --colorized --max-color-depth=2 --color-palette=red,green,yellow
+output_formats=puml,dot
+command_line_args=-S --colorized --max-color-depth=2 --color-palette=red,#44BB88,yellow