"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pylint/pyreverse/diagrams.py" between
pylint-2.17.5.tar.gz and pylint-2.17.6.tar.gz

About: pylint analyzes Python source code looking for bugs and signs of poor quality.

diagrams.py  (pylint-2.17.5):diagrams.py  (pylint-2.17.6)
skipping to change at line 112 skipping to change at line 112
) -> Relationship: ) -> Relationship:
"""Return a relationship or None.""" """Return a relationship or None."""
for rel in self.relationships.get(relation_type, ()): for rel in self.relationships.get(relation_type, ()):
if rel.from_object is from_object: if rel.from_object is from_object:
return rel return rel
raise KeyError(relation_type) raise KeyError(relation_type)
def get_attrs(self, node: nodes.ClassDef) -> list[str]: def get_attrs(self, node: nodes.ClassDef) -> list[str]:
"""Return visible attributes, possibly with class name.""" """Return visible attributes, possibly with class name."""
attrs = [] attrs = []
properties = [ properties = {
(n, m) local_name: local_node
for n, m in node.items() for local_name, local_node in node.items()
if isinstance(m, nodes.FunctionDef) and decorated_with_property(m) if isinstance(local_node, nodes.FunctionDef)
] and decorated_with_property(local_node)
for node_name, associated_nodes in ( }
list(node.instance_attrs_type.items()) for attr_name, attr_type in list(node.locals_type.items()) + list(
+ list(node.locals_type.items()) node.instance_attrs_type.items()
+ properties
): ):
if attr_name not in properties:
properties[attr_name] = attr_type
for node_name, associated_nodes in properties.items():
if not self.show_attr(node_name): if not self.show_attr(node_name):
continue continue
names = self.class_names(associated_nodes) names = self.class_names(associated_nodes)
if names: if names:
node_name = f"{node_name} : {', '.join(names)}" node_name = f"{node_name} : {', '.join(names)}"
attrs.append(node_name) attrs.append(node_name)
return sorted(attrs) return sorted(attrs)
def get_methods(self, node: nodes.ClassDef) -> list[nodes.FunctionDef]: def get_methods(self, node: nodes.ClassDef) -> list[nodes.FunctionDef]:
"""Return visible methods.""" """Return visible methods."""
skipping to change at line 165 skipping to change at line 168
if ( if (
isinstance( isinstance(
node, (nodes.ClassDef, nodes.Name, nodes.Subscript, nodes.Bi nOp) node, (nodes.ClassDef, nodes.Name, nodes.Subscript, nodes.Bi nOp)
) )
and hasattr(node, "name") and hasattr(node, "name")
and not self.has_node(node) and not self.has_node(node)
): ):
if node.name not in names: if node.name not in names:
node_name = node.name node_name = node.name
names.append(node_name) names.append(node_name)
return names # sorted to get predictable (hence testable) results
return sorted(
name
for name in names
if all(name not in other or name == other for other in names)
)
def has_node(self, node: nodes.NodeNG) -> bool: def has_node(self, node: nodes.NodeNG) -> bool:
"""Return true if the given node is included in the diagram.""" """Return true if the given node is included in the diagram."""
return node in self._nodes return node in self._nodes
def object_from_node(self, node: nodes.NodeNG) -> DiagramEntity: def object_from_node(self, node: nodes.NodeNG) -> DiagramEntity:
"""Return the diagram object mapped to node.""" """Return the diagram object mapped to node."""
return self._nodes[node] return self._nodes[node]
def classes(self) -> list[ClassEntity]: def classes(self) -> list[ClassEntity]:
skipping to change at line 219 skipping to change at line 227
except KeyError: except KeyError:
continue continue
# associations & aggregations links # associations & aggregations links
for name, values in list(node.aggregations_type.items()): for name, values in list(node.aggregations_type.items()):
for value in values: for value in values:
self.assign_association_relationship( self.assign_association_relationship(
value, obj, name, "aggregation" value, obj, name, "aggregation"
) )
for name, values in list(node.associations_type.items()) + list( associations = node.associations_type.copy()
node.locals_type.items()
): for name, values in node.locals_type.items():
if name not in associations:
associations[name] = values
for name, values in associations.items():
for value in values: for value in values:
self.assign_association_relationship( self.assign_association_relationship(
value, obj, name, "association" value, obj, name, "association"
) )
def assign_association_relationship( def assign_association_relationship(
self, value: astroid.NodeNG, obj: ClassEntity, name: str, type_relations hip: str self, value: astroid.NodeNG, obj: ClassEntity, name: str, type_relations hip: str
) -> None: ) -> None:
if isinstance(value, util.UninferableBase): if isinstance(value, util.UninferableBase):
return return
 End of changes. 4 change blocks. 
13 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)