| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Every deprecation has two texts for two different readers: the runtime warning, read in a terminal far from the deprecated symbol, and the `Deprecated:` notice in the API documentation, read right where it is documented. The deprecations guide (frequenz-floss/docs#6) now gives them different rules: the warning is plain text without the version, and the notice says since which version the symbol is deprecated and links its replacement. `DeprecatedAlias` mixed the two: `since` went into the warning, and `since` and `message` excluded each other, so an alias with a custom warning had no version left for `griffe-frequenz-core` to put in its notice. Now the standard warning is `<old> is deprecated. Use <new> instead.`, `since` is only documentation metadata, and `message` only replaces the warning, so an alias can give both, either or neither. At least one of `new_module` and `new_name` is still required, which is all the overloads have to check now, so the four collapse into two. Only the text of the standard warning changes, and the check that is dropped only refused calls that are now valid, so nothing that worked before breaks. The docs now say what `since` and `message` are for, and that a hand-written `Deprecated:` admonition on the alias declared for type checkers is how the notice is changed. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
A deprecated enum member only had its runtime message, so every one
needed a hand-written `Deprecated:` notice repeating the same
information, even for a plain rename. Client libraries can potentially
deprecate (rename) dozens of members in a release.
`deprecated_member()` and `DeprecatedMember` now take the same
structured information as `DeprecatedAlias`: a keyword-only `new_name`,
the member to use instead in the same enum, and `since`, the version it
is deprecated since, which is only documentation metadata for
`griffe-frequenz-core`. `message` gets a `None` default, and at least
one of `message` and `new_name` is required, which overloads let mypy
check.
PENDING = deprecated_member(1, new_name="OPEN", since="v1.2.0")
Without `message`, the warning is generated as `<Enum>.<NAME> is
deprecated. Use <Enum>.<new_name> instead.`, with fully qualified names,
as the deprecations guide asks. It can only be built when the enum class
is created, since only then are its module and qualified name known, so
the metaclass generates it then. It also checks that `new_name` is a
member of the same enum and is not deprecated itself, so a typo or a
chain of deprecations fails at import time instead of pointing users at
something that doesn't work.
`message` stays a literal message rather than an `{old}`/`{new}`
template like `DeprecatedAlias`'s, since existing messages may contain
braces, and it is still not checked, as before.
Existing calls keep working, since `value` and `message` keep their
position and names and the new parameters are keyword-only. The only
visible change is that `DeprecatedMember.message` is now `str | None`,
as a generated message is not known when the member is declared. The
class is documented as not meant to be used directly, so this is
acceptable in a minor release; storing the generated message back into
it would have kept the type but left it without a meaningful value
until the class is created.
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
The `Enum`, `unique()` and README examples still wrote messages like `PENDING is deprecated, use OPEN instead`, which the deprecations guide no longer recommends: a warning has to start with the fully qualified name, which the own-deprecations `pytest` filter relies on, and the version belongs in the documentation notice. They now use the structured `deprecated_member()` form for renames, and the `Enum` example also shows a member with no replacement, which gives its own fully qualified `message` and needs a hand-written notice. The text after it says what each one warns and how it is documented. The `Enum` example also claimed that `TaskStatus["DONE"]` and `TaskStatus(3)` were `TaskStatus.FINISHED`, which had a different value, and went unnoticed because the examples are only linted, not run. The new example asserts what actually happens. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
The `frequenz.core.warnings` module was added in v1.5.0 and the `part:warnings` label already exists in the repository, but neither the labeler, the key labeler nor the bug report template knew about it, so pull requests and issues touching the module were not labeled. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
There was a problem hiding this comment.
🤖 LGTM. The warning and the documentation metadata are now cleanly separated, and the upgrading notes cover the changed warning text.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
The deprecations guide now separates the runtime warning (plain text, fully qualified names, no version) from the Deprecated: notice in the API documentation (version and a link to the replacement), and griffe-frequenz-core generates the notice from the helpers' structured arguments. This makes both helpers fit that split:
Everything is additive except the text of the standard alias warning and DeprecatedMember.message becoming str | None; DeprecatedMember is documented as not for direct use, so this goes into v1.6.0.
griffe-frequenz-core reads the new arguments in frequenz-floss/griffe-frequenz-core#10. Its compat tests assert the version in the alias warning, so they need updating when it bumps its exact core pin.
Fixes #206.