Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pylint/pyreverse/diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def class_names(self, nodes_lst: Iterable[nodes.NodeNG]) -> list[str]:
if node.name not in names:
node_name = node.name
names.append(node_name)
return names
# sorted to get predictable (hence testable) results
return sorted(names)

def has_node(self, node: nodes.NodeNG) -> bool:
"""Return true if the given node is included in the diagram."""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
digraph "classes" {
rankdir=BT
charset="utf-8"
"line_breaks.A" [color="black", fontcolor="black", label=<{A|<br ALIGN="LEFT"/>|<I>f</I>(x: str | None)<br ALIGN="LEFT"/>}>, shape="record", style="solid"];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
classDiagram
class A {
f(x: str | None)*
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@startuml classes
set namespaceSeparator none
class "A" as line_breaks.A {
{abstract}f(x: str | None)
}
@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OPEN BUG: https://github.com/pylint-dev/pylint/issues/8671

class A:
def f(self, x: str | None):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
output_formats=mmd,dot,puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
classDiagram
class A {
}
class DuplicateAnnotations {
lav : list, list[str]
val : str, str | int
bar() None
}
class DuplicateArrows {
a
a
}
class DuplicateFields {
example1 : int
example1 : int
example2 : int
example2 : int
}
A --* DuplicateArrows : a
A --* DuplicateArrows : a
31 changes: 31 additions & 0 deletions tests/pyreverse/functional/class_diagrams/attributes/duplicates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# OPEN BUG: https://github.com/pylint-dev/pylint/issues/8189
class DuplicateFields():
example1: int
example2: int

def __init__(self):
self.example1 = 1
self.example2 = 2


# OPEN BUG: https://github.com/pylint-dev/pylint/issues/8522
class A:
pass

class DuplicateArrows:
a: A

def __init__(self):
self.a = A()



# OPEN BUG: https://github.com/pylint-dev/pylint/issues/8888
class DuplicateAnnotations:
def __init__(self) -> None:
self.val: str | int = "1"
self.lav: list[str] = []

def bar(self) -> None:
self.val = "2"
self.lav = []