Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecation: add fine-grained deprecation on models #874

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichalHe
Copy link
Member

Add fine grained deprecation, alloowing the developer to specify individual fields of a model that are deprecated. For example:

class A(Model):
    deprecated = fields.Boolean()
    a = fields.Boolean()

@add_deprecation('b.deprecated')
class B(Model):
    b = fields.Model(A)
    c = fields.Int()

Accessing (set or get) b_instance.b.deprecated triggers deprecation warnining.

The add_deprecation can be defined as follows:

def add_deprecation(path):
    def decorator(cls):
        if getattr(cls, '_deprecated_nodes', None) is None:
            cls._deprecated_nodes = []
        cls._deprecated_nodes.append(path.split('.'))
        return cls
    return decorator

Add fine grained deprecation, alloowing the developer to specify
individual fields of a model that are deprecated. For example:

    class A():
      deprecated = fields.Boolean()
      a = fields.Boolean()

    @deprecated('b.deprecated')
    class B():
      b = fields.Model(A)
      c = fields.Int()

Accessing (set or get) b_instance.b.deprecated triggers deprecation
warnining.
@MichalHe MichalHe marked this pull request as draft July 15, 2024 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant