Skip to content

Deprecate isinstance and function identity checks #16

Open
@dwf

Description

@dwf

Writing this down so I don't forget.

One of the goals is to be able to distribute partialplus.py with your project and have it interoperate with other projects that bundle partialplus.py (or searchspaces). To save ourselves computation and headaches, we need a way of checking that objects are PartialPlus objects (or special functions defined by partialplus as node markers) without using isinstance/equality checks on functions.

The plan:

  • Add a class-level _partialplus_version_ attribute to Node.
  • For make_* and *_node functions, add a decorator @annotate_version that adds a 'partialplus_version' attribute, equal to partialplus's __version__.
  • All the is_* functions should then check the function's name attribute and the _partialplus_version_ attribute (there should be a separate function that checks that __version__ is greater than or equal to the node's _partialplus_version_).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions