• 
      

    Add properties for defining aliases and type enforcement.

    Review Request #10495 — Created April 2, 2019 and submitted

    Information

    Djblets
    release-2.0.x

    Reviewers

    This introduces a couple of specialized properties that help with
    deprecating older APIs and enforcing type safety with minimal effort.

    AliasProperty forwards on any property access (sets and gets) to
    another attribute, optionally converting the new or existing value, and
    optionally emitting a deprecation warning.

    TypedProperty takes one or more value types that are allowed to be
    set, and checks any new values against those types, optionally allowing
    or disallowing None values.

    These make use of a new function, get_descriptor_attr_name(), which
    can locate the attribute of a descriptor/property in a class and return
    the attribute name. It's used by these properties for error reporting
    and for setting an attribute on a class instance based on the property's
    name.

    Unit tests passed.

    Made use of these in some upcoming changes.

    Summary ID
    Add properties for defining aliases and type enforcement.
    This introduces a couple of specialized properties that help with deprecating older APIs and enforcing type safety with minimal effort. `AliasProperty` forwards on any property access (sets and gets) to another attribute, optionally converting the new or existing value, and optionally emitting a deprecation warning. `TypedProperty` takes one or more value types that are allowed to be set, and checks any new values against those types, optionally allowing or disallowing `None` values. These make use of a new function, `get_descriptor_attr_name()`, which can locate the attribute of a descriptor/property in a class and return the attribute name. It's used by these properties for error reporting and for setting an attribute on a class instance based on the property's name.
    7ad4bdb7b2fbb3f495227bd843019e62c93ef845
    Description From Last Updated

    E501 line too long (80 > 79 characters)

    reviewbotreviewbot
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    chipx86
    chipx86
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-2.0.x (328b328)