As we run into problem where a workaround is necessary, it would be
good to have a way to be able to mark the code so that when the
problem is fixed we can update the code.

e.g. in issue 1934 is raised the issue of Function not having a
".is_number" property. This means that code that is interested in
making this query has to do something like

if hasattr(foo, 'is_number) and foo.is_number:
    bar()

Someday that problem will be fixed, but will the code get updated? It
won't break when the problem is fixed so until someone notices it, it
won't get changed.

I'm wondering if we shouldn't be doing something to help make these
updates mandatory.

One could put a test in a test suite,

try:
    Function('f').is_number
    assert None, "Function.is_number does not fail. Update code."
except AttributeError:
    pass

but that doesn't directly link one to the code. What if we had a
function that can mark the code for update, something like:

if broken("Function('f').is_number"):
    if hasattr(foo, 'is_number) and foo.is_number:
        bar()
else:
    raise NotBrokenError
    if foo.is_number:
        bar()

broken() would try to execute the code string and if it failed it
would return True, otherwise False. When it gives False, the
NotBrokenError (or a simple assert None) causes the code to raise an
exception and the user can just replace the if/else with the else-part
of the statement.

This is a way to keep the code from collecting workaround garbage.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to