Skip to content

Clarify what's a breaking change in commitizen #1446

Open
@Lee-W

Description

@Lee-W

Description

#1435 (comment)

Possible Solution

No response

Additional context

No response

Additional context

No response

Activity

added theissue type on May 22, 2025
bearomorphism

bearomorphism commented on May 22, 2025

@bearomorphism
Contributor

Relevant commit: 94c02b3

bearomorphism

bearomorphism commented on May 22, 2025

@bearomorphism
Contributor

I'll probably do something like the following in defaults.py

# mymodule.py

import warnings

# ✅ Non-deprecated export
NEW_CONSTANT = "new value"

# ⚠️ Deprecated export (will warn on access)
_OLD_CONSTANT = "old value"

def __getattr__(name):
    if name == "OLD_CONSTANT":
        warnings.warn(
            "OLD_CONSTANT is deprecated and will be removed in a future version. Use NEW_CONSTANT instead.",
            category=DeprecationWarning,
            stacklevel=2,
        )
        return _OLD_CONSTANT
    raise AttributeError(f"module {__name__} has no attribute {name}")
added a commit that references this issue on May 22, 2025
9c8e840
Lee-W

Lee-W commented on May 23, 2025

@Lee-W
MemberAuthor

I'll probably do something like the following in defaults.py

mymodule.py

import warnings

✅ Non-deprecated export

NEW_CONSTANT = "new value"

⚠️ Deprecated export (will warn on access)

_OLD_CONSTANT = "old value"

def getattr(name):
if name == "OLD_CONSTANT":
warnings.warn(
"OLD_CONSTANT is deprecated and will be removed in a future version. Use NEW_CONSTANT instead.",
category=DeprecationWarning,
stacklevel=2,
)
return _OLD_CONSTANT
raise AttributeError(f"module {name} has no attribute {name}")

Yep, PEP562 is definitely something we should use 🙂

4 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Clarify what's a breaking change in commitizen · Issue #1446 · commitizen-tools/commitizen