Bump flask-admin to 2.1.0 (replaces dependabot #662)#665
Merged
Conversation
Dependabot PR #662 (flask-admin 2.0.2 → 2.1.0) failed typecheck with 10 errors in src/planexe_modelviews.py: - 6× "Cannot access attribute X for class None" on self.session (e.g. `self.session.query(...)`, `.commit()`, `.add()`, `.get()`). - 4× "Cannot access attribute X for class type[DeclarativeBase]" on self.model column attributes (PlanItem.generated_report_html, .run_zip_snapshot, .run_track_activity_jsonl, .id). Root cause: flask-admin 2.1.0 retyped ModelView's attributes. `session` is now stored via `_warn_session_deprecation(...)` whose overload pair pyright resolves to `None`. `model` is now typed as `type[T_SQLALCHEMY_MODEL]`, which pyright resolves to `type[Any] | type[DeclarativeBase]` — DeclarativeBase has no project-specific columns. Fix is static-analysis-only — runtime behaviour unchanged. Add TYPE_CHECKING-guarded imports of sqlalchemy.orm.Session and PlanItem, then narrow the inherited attribute annotations on the relevant subclasses: class AdminOnlyModelView(ModelView): if typing.TYPE_CHECKING: session: Session ... class PlanItemView(AdminOnlyModelView): if typing.TYPE_CHECKING: model: type[PlanItem] ... The session narrowing on the base class propagates to all subclasses (UserAccountView, etc.). The model narrowing only applies where project-specific columns are accessed. Local verification: pyright reports 0 errors on src/planexe_modelviews.py (was 10). The remaining 2 project-wide pyright errors (authlib, stripe import- resolution) are pre-existing and unrelated to this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces dependabot PR #662, which failed CI typecheck with 10 errors in
frontend_multi_user/src/planexe_modelviews.py. This branch bumps the dep AND fixes the typecheck breakage.Root cause
flask-admin 2.1.0 retyped
ModelViewattributes:sessionis now assigned via_warn_session_deprecation(...), whose overload pair pyright resolves toNone. So everyself.session.query/.add/.commit/.getaccess fails type-checking.modelis now typedtype[T_SQLALCHEMY_MODEL], which pyright resolves totype[Any] | type[DeclarativeBase].DeclarativeBasehas no project-specific columns, soself.model.id/.generated_report_htmletc fail.Fix
Static-analysis-only — runtime behaviour is unchanged. Add
TYPE_CHECKING-guarded imports ofsqlalchemy.orm.SessionandPlanItem, then narrow the inherited attribute annotations:Session narrowing propagates to all
AdminOnlyModelViewsubclasses. Model narrowing only applies where project-specific columns are accessed.Test plan
src/planexe_modelviews.py(was 10)Closes
🤖 Generated with Claude Code