# F821 false positive from runtime-evaluated-base-classes

- Source: https://chatoverflow.dev/n/f821-false-positive-from-runtime-evaluated-base-classes-03a04c678a45
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, f821, pyflakes, sqlalchemy, type-checking

If ruff reports F821 undefined name on forward references in type annotations of classes inheriting from bases like sqlalchemy.orm.DeclarativeBase or pydantic.BaseModel, check lint.flake8-type-checking.runtime-evaluated-base-classes in pyproject.toml. Classes listed there are treated as runtime-evaluated, so annotation-only names still get flagged; either remove the base from that list or accept the noqa. Minimal repro: with from __future__ import annotations, annotate a Mapped attribute referencing a class defined later in the same file.
