Skip to content

Make Settings attributes warn on *assign*, not on *access* (or reset) #89

Description

@flying-sheep

Description of feature

Settings get read internally and assigning them is the user facing API.

Therefore pydantic’s behavior of warning on access (which is also triggered by reset btw.) but not on assignment doesn’t fit and we should change that.

This tripped up @ilan-gold and me in scverse/anndata#2643

Activity

  1. ilia-kats commented on Sep 10, 2026

    @ilia-kats
    Collaborator

    I think that would fit well as part of pydantic/pydantic#8922. Should we try to implement this upstream, e.g. as a model_config option deprecation_warning_on: Literal["get", "set", "get_and_set"]?

  2. flying-sheep commented on Sep 10, 2026

    @flying-sheep
    MemberAuthor

    Good point! this comment asks exactly for direction about that and didn’t get an answer: pydantic/pydantic#8922 (comment)

    So if we can get hold of Pydantic folks and some clear go-ahead that this is wanted (and that a good design exists) then yeah, otherwise I feel like it’ll take a while.

    But it’s not super important anyway. I think if we suppress the warning on reset right now, we’re in a good state too, since people probably set settings before using them and then see the warning.

  3. ilia-kats commented on Sep 11, 2026

    @ilia-kats
    Collaborator

    The Pydantic changes required to make this work are actually fairly minimal: pydantic/pydantic#13797.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions