Flet deprecation

From flet-dev/flet · View interactive version

Flet deprecation is an AI agent skill from the GitHub repository flet-dev/flet. Use when adding or changing deprecations for Python controls/APIs in sdk/python/packages/, including V.deprecated fields, deprecated decorators, version lifecycle, and docs admonitions/labels.

How to use this skill

Skill file

When To Use

Use this skill when you:

Do not use this skill for non-deprecation validation logic; use

CODE0.

Source Of Truth

Deprecation Decision Order

Use this order and stop at the first option that fits:

  1. Property/field deprecation: Annotated[..., V.deprecated(...)].
  2. Function/method deprecation: @deprecated(...).
  3. Class/control deprecation: @deprecated_class(...).

Do not add parallel custom warning logic in before_update() when V.deprecated

already covers the field.

Runtime Contract For Property Renames

Follow the non-copying model:

Removal phase:

Dart fallback in the same migration.

Removal Version Policy

Target Release Audit

When working on a release for {new_version}, treat deprecations with

delete_version == {new_version} as mandatory audit items.

and V.deprecated(...) entries whose delete_version equals {new_version}.

rg -n 'delete_version\\s*=\\s*"{new_version}"|delete_version\\s*=\\s*\\x27{new_version}\\x27' -S sdk/python/packages

before editing files or making removals.

whether a prior removal was missed, or whether the deprecation timeline is incorrect.

for approval before creating a commit.

edits into one grouped commit instead of splitting them across multiple commits.

Use commit message format: release: remove deprecated APIs for {new_version}

Authoring Rules

  1. Always set version.
  2. Set delete_version using the 3-minor policy by default.
  3. Keep reason plain text for runtime warnings.
  4. Use docs_reason for docs-only markdown text.
  5. When a replacement exists, name that replacement API explicitly in reason and docs_reason.

Field Pattern

from typing import Annotated, Optional
from flet.utils.validation import V

class ExampleControl:
    old_prop: Annotated[
        Optional[str],
        V.deprecated(
            "new_prop",
            version="0.17.0",
            delete_version="0.20.0",
            reason="Use new_prop instead.",
            docs_reason="Use :attr:`new_prop` or [`new_prop`](../controls/examplecontrol.md#flet.ExampleControl.new_prop) instead.",
        ),
    ] = None

Function/Method Pattern

from flet.utils.deprecated import deprecated

class ExampleControl:
    @deprecated(
        reason="Use new_func instead.",
        docs_reason="Use :meth:`new_func` or [`new_func()`](../controls/examplecontrol.md#flet.ExampleControl.new_func) instead.",
        version="0.17.0",
        delete_version="0.20.0",
    )
    def old_func(self):
        ...

Class/Control Pattern

from flet.utils.deprecated import deprecated_class

@deprecated_class(
    reason="Use NewControl instead.",
    docs_reason="Use :class:`~flet.NewControl` or [`NewControl`](../controls/newcontrol.md)  instead.",
    version="0.17.0",
    delete_version="0.20.0",
)
class OldControl:
    ...

Deprecated Property Pattern

from flet.utils.deprecated import deprecated

class ExampleControl:
    @property
    @deprecated(
        reason="Use new_value instead.",
        docs_reason="Use :attr:`new_value` or [`new_value`](../controls/examplecontrol.md#flet.ExampleControl.new_value) instead.",
        version="0.17.0",
        delete_version="0.20.0",
    )
    def value(self):
        ...

`reason` vs `docs_reason`

Cross-reference Rule Inside `docs_reason`

In docs_reason, use reST roles for simple references when the auto-derived label is

sufficient, and use Markdown links when you need more control over the displayed text.

See CODE0 for details on supported cross-ref patterns and their syntax.

Docs Behavior Expectations

For supported patterns, docs should auto-render:

Do not duplicate with manual deprecation admonitions in docstrings unless there

is a special case not covered by the extension.

Release Docs Updates

When adding a user-visible deprecation, also update the release docs in the

same change. These pages are the canonical upgrade path, not a separate

Deprecations page.

  1. Create or update a migration guide under

website/docs/updates/breaking-changes/vX-Y-Z/.

same class/control or the same PR. For example, DragTargetEvent.x,

DragTargetEvent.y, and DragTargetEvent.offset belong in one

coordinate-fields guide.

Summary, Context, Migration guide, Timeline, and References.

many removed/deprecated APIs to replacements.

and release notes entry for that release.

  1. Add the guide to

website/docs/updates/breaking-changes/index.md under the release's

Deprecations subsection.

  1. Add the guide to website/sidebars.yml under:

Stay up to date -> Breaking changes and deprecations -> vX.Y.Z.

This keeps individual guide pages in the docs sidebar while grouping them by

release.

  1. Update website/docs/updates/release-notes.md so the release links to the

combined Breaking changes and deprecations section.

  1. Run cd website && yarn crocodocs:generate after sidebar

edits, then run cd website && yarn build.

Testing Guidance

Do not add one-off tests for every API that gets deprecated when it uses an

existing, already-tested pattern (V.deprecated, @deprecated, or

@deprecated_class). For routine deprecation metadata updates, rely on the

shared helper and docs extraction tests.

Add or update tests only when the change affects deprecation infrastructure or

introduces meaningful new behavior, for example:

Prefer these locations for infrastructure tests:

Common Pitfalls

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.