Skip to content

Strange priorities in EditorFactory.string_value #1695

@aaronayres35

Description

@aaronayres35

Motivated by this comment:
https://github.com/enthought/traitsui/pull/1684/files#r655198812

See relevant code block here:

def string_value(self, value, format_func=None):
""" Returns the text representation of a specified object trait value.
If the **format_func** attribute is set on the editor factory, then
this method calls that function to do the formatting. If the
**format_str** attribute is set on the editor factory, then this
method uses that string for formatting. If neither attribute is
set, then this method just calls the appropriate text type to format.
"""
if self.format_func is not None:
return self.format_func(value)
if self.format_str != "":
return self.format_str % value
if format_func is not None:
return format_func(value)
return str(value)

The docstring does not mention the format_func kwarg, and it seems strange that one can pass a format_func kwarg explicitly and have it go unused if the factory has its format_func or format_str traits set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: discussionIssues on topics for discussions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions