Anyone know if there’s a way to deprecate individu...
# development
b
Anyone know if there’s a way to deprecate individual fields within a model? I know that the
deprecated
decorator exists for functions but I don’t know exactly how this works for fields. Concrete example:
Copy code
class PythonFaaSRuntimeField(StringField, ABC):
    alias = "runtime"
    default = None

    known_runtimes_docker_repo: ClassVar[str] # <--- want to deprecate this
    known_runtimes: ClassVar[tuple[PythonFaaSKnownRuntime, ...]] = ()
i.e. rename the field, and stick the old name into the
deprecated_alias
field.
b
The code you highlighted is for the field as a whole, this is just some extra metadata attached to the field
c
Oh.. so not a "outside" interface deprecation..
sorry, didn't read your example 😬
🤔
I guess the way to go would be to introduce the new name, and have a check that calls maybe_warn if the old name is being used.. 🤷
b
It's unclear to me whether it requires deprecation at all tbh - I have a PR up including this change and I just removed that variable
👍 1