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

Support deprecated message and fields #126

Merged
merged 1 commit into from
Jul 30, 2020

Conversation

abn
Copy link
Collaborator

@abn abn commented Jul 21, 2020

Initial attempt at warning on deprecated field use.

Generated sample:

# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: deprecated.proto
# plugin: python-betterproto
import warnings
from dataclasses import dataclass

import betterproto


@dataclass
class Test(betterproto.Message):
    """Some documentation about the Test message."""

    v: int = betterproto.int32_field(1)
    value: int = betterproto.int32_field(2)

    def __post_init__(self) -> None:
        warnings.warn("Test is deprecated", DeprecationWarning)
        super().__post_init__()
        if self.v:
            warnings.warn("Test.v is deprecated", DeprecationWarning)

@boukeversteegh
Copy link
Collaborator

Great work! Unfortunately the OOP refactor has made this PR in conflict.
Would you be willing to port it to the new structure?

@abn
Copy link
Collaborator Author

abn commented Jul 25, 2020

@boukeversteegh this should be ready again.

@nat-n nat-n merged commit 0cd9510 into danielgtaylor:master Jul 30, 2020
@abn abn deleted the deprecation-warnings branch July 30, 2020 14:04
@adriangb
Copy link
Contributor

Happy to see that this worked well with that refactor 😄

Gobot1234 added a commit to Gobot1234/python-betterproto that referenced this pull request Aug 6, 2020
Gobot1234 pushed a commit to Gobot1234/python-betterproto that referenced this pull request Aug 24, 2020
@abn abn mentioned this pull request Nov 24, 2020
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.

None yet

4 participants