consistent attribute history with no side effects

Issue #2128 resolved
Mike Bayer repo owner created an issue

with #2127 I'm digging into the inconsistencies in history reporting. I don't think we can change the conventions too heavily at this point in 0.7. This ticket would address inconsistencies like this:

def test_scalar_init():
    class Foo(object):
        pass
    instrumentation.register_class(Foo)
    attributes.register_attribute(Foo, 'someattr', uselist=False,
            useobject=False, active_history=True)
    f = Foo()
    assert \
        attributes.get_state_history(attributes.instance_state(f), 'someattr') == \
        ((), (), ())

def test_object_init():
    class Foo(object):
        pass
    instrumentation.register_class(Foo)
    attributes.register_attribute(Foo, 'someattr', uselist=False,
            useobject=True, active_history=True)
    f = Foo()
    assert \
        attributes.get_state_history(attributes.instance_state(f), 'someattr') == \
        ((), [None](None), ())

and others. Symbols like NEVER_SET, NO_VALUE should be used in a fully consistent way for scalars, and object scalars, and full detail should be returned in history tuples - no more returning () when we are actually able to tell if the value was previously present or not. The "default value" of None being set in get() needs to never occur when doing history - this is a side effect. A facade for the current get_history() should be supplied to provide backwards compatibility, if possible.

Comments (2)

  1. Log in to comment