From 6d041802f328c3d0f3eba0ca1d9c5fd4523f18cb Mon Sep 17 00:00:00 2001 From: DudeNr33 <3929834+DudeNr33@users.noreply.github.com> Date: Tue, 7 Feb 2023 21:15:41 +0100 Subject: [PATCH 1/4] Add `--color-palette` option to `pyreverse` and modify default colors. --- doc/whatsnew/fragments/6738.feature | 4 ++ pylint/pyreverse/main.py | 24 +++++++++++ pylint/pyreverse/writer.py | 23 +--------- pylint/testutils/pyreverse.py | 4 ++ tests/pyreverse/data/classes_colorized.dot | 16 +++---- tests/pyreverse/data/classes_colorized.puml | 16 +++---- tests/pyreverse/data/packages_colorized.dot | 8 ++-- tests/pyreverse/data/packages_colorized.puml | 8 ++-- .../colorized_output/colorized.puml | 8 ++-- .../colorized_output/custom_colors.puml | 42 +++++++++++++++++++ .../colorized_output/custom_colors.py | 10 +++++ .../colorized_output/custom_colors.rc | 3 ++ 12 files changed, 117 insertions(+), 49 deletions(-) create mode 100644 doc/whatsnew/fragments/6738.feature create mode 100644 tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml create mode 100644 tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.py create mode 100644 tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc diff --git a/doc/whatsnew/fragments/6738.feature b/doc/whatsnew/fragments/6738.feature new file mode 100644 index 0000000000..5e159e6c74 --- /dev/null +++ b/doc/whatsnew/fragments/6738.feature @@ -0,0 +1,4 @@ +`pyreverse` now supports custom color palettes with the `--color-palette` option. +The default color palette has been changed to be more accessible for color blind people. + +Closes #6738 diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py index 8a2055c411..f718429f61 100644 --- a/pylint/pyreverse/main.py +++ b/pylint/pyreverse/main.py @@ -33,6 +33,19 @@ "html", ) +DEFAULT_COLOR_PALETTE = ( + "dodgerblue", + "orange", + "teal", + "sienna", + "orchid", + "lightsalmon", + "plum", + "gray", + "yellow", + "steelblue", +) + OPTIONS: Options = ( ( "filter-mode", @@ -172,6 +185,17 @@ "help": "Use separate colors up to package depth of ", }, ), + ( + "color-palette", + { + "dest": "color_palette", + "action": "store", + "default": DEFAULT_COLOR_PALETTE, + "metavar": "", + "type": "csv", + "help": "Comma separated list of colors to use", + }, + ), ( "ignore", { diff --git a/pylint/pyreverse/writer.py b/pylint/pyreverse/writer.py index 68a49eea19..88e3d05356 100644 --- a/pylint/pyreverse/writer.py +++ b/pylint/pyreverse/writer.py @@ -34,27 +34,8 @@ def __init__(self, config: argparse.Namespace) -> None: 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 fc20b5453f..e426ea31a8 100644 --- a/pylint/testutils/pyreverse.py +++ b/pylint/testutils/pyreverse.py @@ -11,6 +11,8 @@ 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 @@ def __init__( 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 @@ def __init__( 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 diff --git a/tests/pyreverse/data/classes_colorized.dot b/tests/pyreverse/data/classes_colorized.dot index 4ff12a8191..b098e2f19b 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
cls_member
|get_value()
set_value(value)
}>, shape="record", style="filled"]; -"data.suppliermodule_test.CustomException" [color="aliceblue", fontcolor="red", label=<{CustomException|
|}>, shape="record", style="filled"]; -"data.suppliermodule_test.DoNothing" [color="aliceblue", fontcolor="black", label=<{DoNothing|
|}>, shape="record", style="filled"]; -"data.suppliermodule_test.DoNothing2" [color="aliceblue", fontcolor="black", label=<{DoNothing2|
|}>, shape="record", style="filled"]; -"data.suppliermodule_test.DoSomething" [color="aliceblue", fontcolor="black", label=<{DoSomething|my_int : Optional[int]
my_int_2 : Optional[int]
my_string : str
|do_it(new_int: int): int
}>, shape="record", style="filled"]; -"data.suppliermodule_test.Interface" [color="aliceblue", fontcolor="black", label=<{Interface|
|get_value()
set_value(value)
}>, shape="record", style="filled"]; -"data.property_pattern.PropertyPatterns" [color="aliceblue", fontcolor="black", label=<{PropertyPatterns|prop1
prop2
|}>, shape="record", style="filled"]; -"data.clientmodule_test.Specialization" [color="aliceblue", fontcolor="black", label=<{Specialization|TYPE : str
relation
relation2
top : str
|from_value(value: int)
increment_value(): None
transform_value(value: int): int
}>, shape="record", style="filled"]; +"data.clientmodule_test.Ancestor" [color="dodgerblue", fontcolor="black", label=<{Ancestor|attr : str
cls_member
|get_value()
set_value(value)
}>, shape="record", style="filled"]; +"data.suppliermodule_test.CustomException" [color="dodgerblue", fontcolor="red", label=<{CustomException|
|}>, shape="record", style="filled"]; +"data.suppliermodule_test.DoNothing" [color="dodgerblue", fontcolor="black", label=<{DoNothing|
|}>, shape="record", style="filled"]; +"data.suppliermodule_test.DoNothing2" [color="dodgerblue", fontcolor="black", label=<{DoNothing2|
|}>, shape="record", style="filled"]; +"data.suppliermodule_test.DoSomething" [color="dodgerblue", fontcolor="black", label=<{DoSomething|my_int : Optional[int]
my_int_2 : Optional[int]
my_string : str
|do_it(new_int: int): int
}>, shape="record", style="filled"]; +"data.suppliermodule_test.Interface" [color="dodgerblue", fontcolor="black", label=<{Interface|
|get_value()
set_value(value)
}>, shape="record", style="filled"]; +"data.property_pattern.PropertyPatterns" [color="dodgerblue", fontcolor="black", label=<{PropertyPatterns|prop1
prop2
|}>, shape="record", style="filled"]; +"data.clientmodule_test.Specialization" [color="dodgerblue", fontcolor="black", label=<{Specialization|TYPE : str
relation
relation2
top : str
|from_value(value: int)
increment_value(): None
transform_value(value: int): int
}>, shape="record", style="filled"]; "data.clientmodule_test.Specialization" -> "data.clientmodule_test.Ancestor" [arrowhead="empty", arrowtail="none"]; "data.clientmodule_test.Ancestor" -> "data.suppliermodule_test.Interface" [arrowhead="empty", arrowtail="node", style="dashed"]; "data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Ancestor" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="cls_member", style="solid"]; diff --git a/tests/pyreverse/data/classes_colorized.puml b/tests/pyreverse/data/classes_colorized.puml index 7398ee60f6..2e550022c9 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 #dodgerblue { attr : str cls_member get_value() set_value(value) } -class "CustomException" as data.suppliermodule_test.CustomException #aliceblue { +class "CustomException" as data.suppliermodule_test.CustomException #dodgerblue { } -class "DoNothing" as data.suppliermodule_test.DoNothing #aliceblue { +class "DoNothing" as data.suppliermodule_test.DoNothing #dodgerblue { } -class "DoNothing2" as data.suppliermodule_test.DoNothing2 #aliceblue { +class "DoNothing2" as data.suppliermodule_test.DoNothing2 #dodgerblue { } -class "DoSomething" as data.suppliermodule_test.DoSomething #aliceblue { +class "DoSomething" as data.suppliermodule_test.DoSomething #dodgerblue { 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 #dodgerblue { {abstract}get_value() {abstract}set_value(value) } -class "PropertyPatterns" as data.property_pattern.PropertyPatterns #aliceblue { +class "PropertyPatterns" as data.property_pattern.PropertyPatterns #dodgerblue { prop1 prop2 } -class "Specialization" as data.clientmodule_test.Specialization #aliceblue { +class "Specialization" as data.clientmodule_test.Specialization #dodgerblue { TYPE : str relation relation2 diff --git a/tests/pyreverse/data/packages_colorized.dot b/tests/pyreverse/data/packages_colorized.dot index 10005f26cb..4c71cae5af 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=, shape="box", style="filled"]; -"data.clientmodule_test" [color="aliceblue", label=, shape="box", style="filled"]; -"data.property_pattern" [color="aliceblue", label=, shape="box", style="filled"]; -"data.suppliermodule_test" [color="aliceblue", label=, shape="box", style="filled"]; +"data" [color="dodgerblue", label=, shape="box", style="filled"]; +"data.clientmodule_test" [color="dodgerblue", label=, shape="box", style="filled"]; +"data.property_pattern" [color="dodgerblue", label=, shape="box", style="filled"]; +"data.suppliermodule_test" [color="dodgerblue", label=, 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 353ae8c476..aac720a742 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 #dodgerblue { } -package "data.clientmodule_test" as data.clientmodule_test #aliceblue { +package "data.clientmodule_test" as data.clientmodule_test #dodgerblue { } -package "data.property_pattern" as data.property_pattern #aliceblue { +package "data.property_pattern" as data.property_pattern #dodgerblue { } -package "data.suppliermodule_test" as data.suppliermodule_test #aliceblue { +package "data.suppliermodule_test" as data.suppliermodule_test #dodgerblue { } 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 a5ccf11f79..1262c18fc5 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 #dodgerblue { checker1 checker2 checker3 } -class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #antiquewhite { +class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #orange { 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 #teal { 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 #teal { 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.puml b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml new file mode 100644 index 0000000000..34dc814ffa --- /dev/null +++ b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.puml @@ -0,0 +1,42 @@ +@startuml classes +set namespaceSeparator none +class "CheckerCollector" as custom_colors.CheckerCollector #red { + checker1 + checker2 + checker3 +} +class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #green { + 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 #yellow { + msgs : dict + name : str + options : tuple + open() -> None + visit_binop(node: nodes.BinOp) -> None + visit_compare(node: nodes.Compare) -> None + visit_raise(node: nodes.Raise) -> None + visit_tryexcept(node: nodes.TryExcept) -> None +} +class "StdlibChecker" as pylint.checkers.stdlib.StdlibChecker #yellow { + msgs : dict[str, MessageDefinitionTuple] + name : str + deprecated_arguments(method: str) -> tuple[tuple[int | None, str], ...] + deprecated_classes(module: str) -> Iterable[str] + deprecated_decorators() -> Iterable[str] + deprecated_methods() -> set[str] + visit_boolop(node: nodes.BoolOp) -> None + visit_call(node: nodes.Call) -> None + visit_functiondef(node: nodes.FunctionDef) -> None + visit_if(node: nodes.If) -> None + visit_ifexp(node: nodes.IfExp) -> None + visit_unaryop(node: nodes.UnaryOp) -> None +} +pylint.checkers.exceptions.ExceptionsChecker --* custom_colors.CheckerCollector : checker1 +pylint.checkers.stdlib.StdlibChecker --* custom_colors.CheckerCollector : checker3 +pylint.extensions.check_elif.ElseifUsedChecker --* custom_colors.CheckerCollector : checker2 +@enduml diff --git a/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.py b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.py new file mode 100644 index 0000000000..b46c97e753 --- /dev/null +++ b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.py @@ -0,0 +1,10 @@ +from pylint.checkers.exceptions import ExceptionsChecker +from pylint.checkers.stdlib import StdlibChecker +from pylint.extensions.check_elif import ElseifUsedChecker + + +class CheckerCollector: + def __init__(self): + self.checker1 = ExceptionsChecker(None) + self.checker2 = ElseifUsedChecker(None) + self.checker3 = StdlibChecker(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 new file mode 100644 index 0000000000..ea30ad4a47 --- /dev/null +++ b/tests/pyreverse/functional/class_diagrams/colorized_output/custom_colors.rc @@ -0,0 +1,3 @@ +[testoptions] +output_formats=puml +command_line_args=-S --colorized --max-color-depth=2 --color-palette=red,green,yellow From 24f6e4afec1473d364338535a69998ecba2e6180 Mon Sep 17 00:00:00 2001 From: DudeNr33 <3929834+DudeNr33@users.noreply.github.com> Date: Wed, 8 Feb 2023 18:37:59 +0100 Subject: [PATCH 2/4] add seaborn to custom dict --- .pyenchant_pylint_custom_dict.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.pyenchant_pylint_custom_dict.txt b/.pyenchant_pylint_custom_dict.txt index a82b2e1bf0..130cf5305d 100644 --- a/.pyenchant_pylint_custom_dict.txt +++ b/.pyenchant_pylint_custom_dict.txt @@ -281,6 +281,7 @@ rstrip rtype runtime se +seaborn sep setcomp shortstrings From 31ccdb3ea7ff821a5c526724c42659279f547b5d Mon Sep 17 00:00:00 2001 From: DudeNr33 <3929834+DudeNr33@users.noreply.github.com> Date: Wed, 8 Feb 2023 19:39:49 +0100 Subject: [PATCH 3/4] revert default colors --- pylint/pyreverse/main.py | 37 ++++++++++++++----- tests/pyreverse/data/classes_colorized.dot | 16 ++++---- tests/pyreverse/data/classes_colorized.puml | 16 ++++---- tests/pyreverse/data/packages_colorized.dot | 8 ++-- tests/pyreverse/data/packages_colorized.puml | 8 ++-- .../colorized_output/colorized.puml | 8 ++-- 6 files changed, 56 insertions(+), 37 deletions(-) diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py index f718429f61..0b088c198a 100644 --- a/pylint/pyreverse/main.py +++ b/pylint/pyreverse/main.py @@ -34,16 +34,35 @@ ) DEFAULT_COLOR_PALETTE = ( + "aliceblue", + "antiquewhite", + "aquamarine", + "burlywood", + "cadetblue", + "chartreuse", + "chocolate", + "coral", + "cornflowerblue", + "cyan", + "darkgoldenrod", + "darkseagreen", "dodgerblue", - "orange", - "teal", - "sienna", - "orchid", - "lightsalmon", - "plum", - "gray", - "yellow", - "steelblue", + "forestgreen", + "gold", + "hotpink", + "mediumspringgreen", + # TODO for 3.0: replace the colors above with the ones below + # Those are more colorblind friendly + # "dodgerblue", + # "orange", + # "teal", + # "sienna", + # "orchid", + # "lightsalmon", + # "plum", + # "gray", + # "yellow", + # "steelblue", ) OPTIONS: Options = ( diff --git a/tests/pyreverse/data/classes_colorized.dot b/tests/pyreverse/data/classes_colorized.dot index b098e2f19b..4ff12a8191 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="dodgerblue", fontcolor="black", label=<{Ancestor|attr : str
cls_member
|get_value()
set_value(value)
}>, shape="record", style="filled"]; -"data.suppliermodule_test.CustomException" [color="dodgerblue", fontcolor="red", label=<{CustomException|
|}>, shape="record", style="filled"]; -"data.suppliermodule_test.DoNothing" [color="dodgerblue", fontcolor="black", label=<{DoNothing|
|}>, shape="record", style="filled"]; -"data.suppliermodule_test.DoNothing2" [color="dodgerblue", fontcolor="black", label=<{DoNothing2|
|}>, shape="record", style="filled"]; -"data.suppliermodule_test.DoSomething" [color="dodgerblue", fontcolor="black", label=<{DoSomething|my_int : Optional[int]
my_int_2 : Optional[int]
my_string : str
|do_it(new_int: int): int
}>, shape="record", style="filled"]; -"data.suppliermodule_test.Interface" [color="dodgerblue", fontcolor="black", label=<{Interface|
|get_value()
set_value(value)
}>, shape="record", style="filled"]; -"data.property_pattern.PropertyPatterns" [color="dodgerblue", fontcolor="black", label=<{PropertyPatterns|prop1
prop2
|}>, shape="record", style="filled"]; -"data.clientmodule_test.Specialization" [color="dodgerblue", fontcolor="black", label=<{Specialization|TYPE : str
relation
relation2
top : str
|from_value(value: int)
increment_value(): None
transform_value(value: int): int
}>, shape="record", style="filled"]; +"data.clientmodule_test.Ancestor" [color="aliceblue", fontcolor="black", label=<{Ancestor|attr : str
cls_member
|get_value()
set_value(value)
}>, shape="record", style="filled"]; +"data.suppliermodule_test.CustomException" [color="aliceblue", fontcolor="red", label=<{CustomException|
|}>, shape="record", style="filled"]; +"data.suppliermodule_test.DoNothing" [color="aliceblue", fontcolor="black", label=<{DoNothing|
|}>, shape="record", style="filled"]; +"data.suppliermodule_test.DoNothing2" [color="aliceblue", fontcolor="black", label=<{DoNothing2|
|}>, shape="record", style="filled"]; +"data.suppliermodule_test.DoSomething" [color="aliceblue", fontcolor="black", label=<{DoSomething|my_int : Optional[int]
my_int_2 : Optional[int]
my_string : str
|do_it(new_int: int): int
}>, shape="record", style="filled"]; +"data.suppliermodule_test.Interface" [color="aliceblue", fontcolor="black", label=<{Interface|
|get_value()
set_value(value)
}>, shape="record", style="filled"]; +"data.property_pattern.PropertyPatterns" [color="aliceblue", fontcolor="black", label=<{PropertyPatterns|prop1
prop2
|}>, shape="record", style="filled"]; +"data.clientmodule_test.Specialization" [color="aliceblue", fontcolor="black", label=<{Specialization|TYPE : str
relation
relation2
top : str
|from_value(value: int)
increment_value(): None
transform_value(value: int): int
}>, shape="record", style="filled"]; "data.clientmodule_test.Specialization" -> "data.clientmodule_test.Ancestor" [arrowhead="empty", arrowtail="none"]; "data.clientmodule_test.Ancestor" -> "data.suppliermodule_test.Interface" [arrowhead="empty", arrowtail="node", style="dashed"]; "data.suppliermodule_test.DoNothing" -> "data.clientmodule_test.Ancestor" [arrowhead="diamond", arrowtail="none", fontcolor="green", label="cls_member", style="solid"]; diff --git a/tests/pyreverse/data/classes_colorized.puml b/tests/pyreverse/data/classes_colorized.puml index 2e550022c9..7398ee60f6 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 #dodgerblue { +class "Ancestor" as data.clientmodule_test.Ancestor #aliceblue { attr : str cls_member get_value() set_value(value) } -class "CustomException" as data.suppliermodule_test.CustomException #dodgerblue { +class "CustomException" as data.suppliermodule_test.CustomException #aliceblue { } -class "DoNothing" as data.suppliermodule_test.DoNothing #dodgerblue { +class "DoNothing" as data.suppliermodule_test.DoNothing #aliceblue { } -class "DoNothing2" as data.suppliermodule_test.DoNothing2 #dodgerblue { +class "DoNothing2" as data.suppliermodule_test.DoNothing2 #aliceblue { } -class "DoSomething" as data.suppliermodule_test.DoSomething #dodgerblue { +class "DoSomething" as data.suppliermodule_test.DoSomething #aliceblue { 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 #dodgerblue { +class "Interface" as data.suppliermodule_test.Interface #aliceblue { {abstract}get_value() {abstract}set_value(value) } -class "PropertyPatterns" as data.property_pattern.PropertyPatterns #dodgerblue { +class "PropertyPatterns" as data.property_pattern.PropertyPatterns #aliceblue { prop1 prop2 } -class "Specialization" as data.clientmodule_test.Specialization #dodgerblue { +class "Specialization" as data.clientmodule_test.Specialization #aliceblue { TYPE : str relation relation2 diff --git a/tests/pyreverse/data/packages_colorized.dot b/tests/pyreverse/data/packages_colorized.dot index 4c71cae5af..10005f26cb 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="dodgerblue", label=, shape="box", style="filled"]; -"data.clientmodule_test" [color="dodgerblue", label=, shape="box", style="filled"]; -"data.property_pattern" [color="dodgerblue", label=, shape="box", style="filled"]; -"data.suppliermodule_test" [color="dodgerblue", label=, shape="box", style="filled"]; +"data" [color="aliceblue", label=, shape="box", style="filled"]; +"data.clientmodule_test" [color="aliceblue", label=, shape="box", style="filled"]; +"data.property_pattern" [color="aliceblue", label=, shape="box", style="filled"]; +"data.suppliermodule_test" [color="aliceblue", label=, 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 aac720a742..353ae8c476 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 #dodgerblue { +package "data" as data #aliceblue { } -package "data.clientmodule_test" as data.clientmodule_test #dodgerblue { +package "data.clientmodule_test" as data.clientmodule_test #aliceblue { } -package "data.property_pattern" as data.property_pattern #dodgerblue { +package "data.property_pattern" as data.property_pattern #aliceblue { } -package "data.suppliermodule_test" as data.suppliermodule_test #dodgerblue { +package "data.suppliermodule_test" as data.suppliermodule_test #aliceblue { } 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 1262c18fc5..a5ccf11f79 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 #dodgerblue { +class "CheckerCollector" as colorized.CheckerCollector #aliceblue { checker1 checker2 checker3 } -class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #orange { +class "ElseifUsedChecker" as pylint.extensions.check_elif.ElseifUsedChecker #antiquewhite { 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 #teal { +class "ExceptionsChecker" as pylint.checkers.exceptions.ExceptionsChecker #aquamarine { msgs : dict name : str options : tuple @@ -22,7 +22,7 @@ class "ExceptionsChecker" as pylint.checkers.exceptions.ExceptionsChecker #teal visit_raise(node: nodes.Raise) -> None visit_tryexcept(node: nodes.TryExcept) -> None } -class "StdlibChecker" as pylint.checkers.stdlib.StdlibChecker #teal { +class "StdlibChecker" as pylint.checkers.stdlib.StdlibChecker #aquamarine { msgs : dict[str, MessageDefinitionTuple] name : str deprecated_arguments(method: str) -> tuple[tuple[int | None, str], ...] From 64e68b51250361a02e44779db320b170bee03126 Mon Sep 17 00:00:00 2001 From: DudeNr33 <3929834+DudeNr33@users.noreply.github.com> Date: Thu, 9 Feb 2023 19:43:54 +0100 Subject: [PATCH 4/4] Remove commented out colors and adjust newsfragment --- doc/whatsnew/fragments/6738.feature | 1 - pylint/pyreverse/main.py | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/doc/whatsnew/fragments/6738.feature b/doc/whatsnew/fragments/6738.feature index 5e159e6c74..d6895df365 100644 --- a/doc/whatsnew/fragments/6738.feature +++ b/doc/whatsnew/fragments/6738.feature @@ -1,4 +1,3 @@ `pyreverse` now supports custom color palettes with the `--color-palette` option. -The default color palette has been changed to be more accessible for color blind people. Closes #6738 diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py index 0b088c198a..a236b41b71 100644 --- a/pylint/pyreverse/main.py +++ b/pylint/pyreverse/main.py @@ -51,18 +51,6 @@ "gold", "hotpink", "mediumspringgreen", - # TODO for 3.0: replace the colors above with the ones below - # Those are more colorblind friendly - # "dodgerblue", - # "orange", - # "teal", - # "sienna", - # "orchid", - # "lightsalmon", - # "plum", - # "gray", - # "yellow", - # "steelblue", ) OPTIONS: Options = (