Skip to content

add Nh3Char(models.CharField) #44

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

LouisKerdres
Copy link

@LouisKerdres LouisKerdres commented Dec 3, 2024

hello

i need to have a CharField sanitized so I suggest this changes.

I'm not used to make PR on others repo, feel free to ask more modification to fit with your quality policy

rename Nh3Field in Nh3Text and deprecate the old naming too

@marksweb marksweb self-assigned this Jan 20, 2025
@marksweb
Copy link
Owner

@LouisKerdres Apologies for the time it's taking for me to get to this!

I did start looking into the "textbook approach" to deprecating classes, having never actually needed to do that before.

I have also now remembered to assign this to myself so that will (hopefully) help me keep track of it.

@marksweb marksweb self-requested a review February 22, 2025 18:20
return mark_safe(value)


def Nh3Field(*args: Any, **kwargs: Any) -> Nh3Text:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done a little research on the deprecation of a class now. So I think keep Nh3Field as a class.

Add a docstring note of the deprecation along with perhaps adding the typing decorator would be a good idea;

from typing import TypeVar
from typing_extensions import deprecated

@deprecated("Use Nh3Text instead")
class Nh3Field:
    """
    .. deprecated:: 0.2.0
       Use :class:`Nh3Text` instead.
    """
    pass

Then raise the deprecation in the __init__ similar to;

import warnings

class Nh3Field:
    def __init__(self):
        warnings.warn(
            "Nh3Field is deprecated and will be removed in a future version. Use Nh3Text instead.",
            DeprecationWarning,
            stacklevel=2
        )

And to prevent this being a breaking change, it could inherit Nh3Text;

class Nh3Field(Nh3Text):

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.

2 participants