You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a reminder issue that during development of pydot 2.0.0 we should see if we can use Python property for getters/setters of DOT attributes. This was suggested by @johnyf in #151 (comment) and by @sandrotosi in #217 (comment) for example.
Some points of attention already:
Currently (pydot 1.4.2.dev0), we dynamically create getter/setter methods, also known as convenience methods, like Node.get_color(), Edge.set_label(), etc. These seem to be used a lot, so we will need to have a generous transition/deprecation period for those.
Currently (pydot 1.4.2.dev0), we have no clear way to prevent name clashes between pydot attributes and (custom) DOT attributes. For example, Node.set_name() and Graph.set_type() set pydot attributes, so getter/setter methods created for custom DOT attributes name and type would clash with those. Perhaps when introducing new getters/setters based on Python properties, we can somehow provide separate namespaces for them, at least for the (custom) DOT attributes over which we have no control. For example by prefixing getters/setters for (custom) DOT attributes with dot_: node.dot_color = 'blue' (DOT attribute used by Graphviz), node.dot_name = 'My Name', graph.dot_type = 'My Type' (custom DOT attributes). The main drawback of this of course the inconvenience of having to use the dot_-prefix all the time, so other suggestions are welcome.
There are over 200 DOT attributes for which we need to generate getters/setters. Even when using Python properties, it may be desirable to dynamically generate them instead of having a long source file with duplicate code to set up property for each DOT attribute individually. In PR Full pickle support #242, also targeted for pydot 2.0.0, I proposed changes to how the current getter/setter methods are dynamically created. We will have to see if the dynamic generation of Python properties can fit in there as well.
The text was updated successfully, but these errors were encountered:
Perhaps when introducing new getters/setters based on Python properties, we can somehow provide separate namespaces for them, at least for the (custom) DOT attributes over which we have no control. For example by prefixing getters/setters for (custom) DOT attributes with dot_: node.dot_color = 'blue' (DOT attribute used by Graphviz), node.dot_name = 'My Name', graph.dot_type = 'My Type' (custom DOT attributes). The main drawback of this of course the inconvenience of having to use the dot_-prefix all the time, so other suggestions are welcome.
My suggestion, on this, would be to simply put all of the attributes inside a member object of the class. So, e.g.:
Oh, and as an added bonus, if node.attrib implements the MutableMapping interface (basically, has implementations for the abstract __len__, __iter__, __getitem__, __setitem__, and __delitem__ methods, and is a subclass of collections.abc.MutableMapping), then it can also be used as a dictionary:
This is a reminder issue that during development of pydot 2.0.0 we should see if we can use Python
property
for getters/setters of DOT attributes. This was suggested by @johnyf in #151 (comment) and by @sandrotosi in #217 (comment) for example.Some points of attention already:
Node.get_color()
,Edge.set_label()
, etc. These seem to be used a lot, so we will need to have a generous transition/deprecation period for those.Node.set_name()
andGraph.set_type()
set pydot attributes, so getter/setter methods created for custom DOT attributesname
andtype
would clash with those. Perhaps when introducing new getters/setters based on Python properties, we can somehow provide separate namespaces for them, at least for the (custom) DOT attributes over which we have no control. For example by prefixing getters/setters for (custom) DOT attributes withdot_
:node.dot_color = 'blue'
(DOT attribute used by Graphviz),node.dot_name = 'My Name'
,graph.dot_type = 'My Type'
(custom DOT attributes). The main drawback of this of course the inconvenience of having to use thedot_
-prefix all the time, so other suggestions are welcome.property
for each DOT attribute individually. In PR Full pickle support #242, also targeted for pydot 2.0.0, I proposed changes to how the current getter/setter methods are dynamically created. We will have to see if the dynamic generation of Python properties can fit in there as well.The text was updated successfully, but these errors were encountered: