Skip to content

Delete warn_at_caller's frame walk once the floor reaches Python 3.12 #203

Description

@lesnik512

lite_bootstrap/helpers/warn.py walks the stack to find the frame that built a config, because no literal stacklevel can name it (#197). Python 3.12 added warnings.warn(..., skip_file_prefixes=...), which expresses the same intent directly and replaces the walk with one argument.

The floor is 3.10 today, so it is not available yet.

When

Blocked on the floor moving. #174 tracks dropping 3.10; this also needs 3.11 gone, since skip_file_prefixes landed in 3.12.

What to check when it happens

skip_file_prefixes takes file path prefixes, and the current walk skips frames on two rules, not one:

  1. Frames whose module is under lite_bootstrap or is dataclasses. Path prefixes cover these, given the installed location of both.
  2. Any __init__ whose file is <string>, which is how a dataclass-generated __init__ reports itself. This one is not a path prefix, and it is load-bearing: tests/test_config_cascade.py::test_a_warning_from_a_subclassed_config_still_names_the_line_that_built_it fails without it, because dataclasses writes a subclass's __init__ into the subclass's own module rather than ours.

So the swap is only clean if skip_file_prefixes=("<string>",) is honoured, or if the generated __init__ reports a real path by then. Check both before deleting anything; the two invariant tests in tests/test_config_cascade.py are the gate.

If #202 is resolved by reusing warn_at_caller, this issue covers those call sites too.

Why this is filed rather than left as a comment

The reasoning lived only in the description of #200, which is merged. Nothing surfaces a merged PR description at the moment someone bumps requires-python, and AGENTS.md says real work not scheduled becomes an issue.

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions