Skip to content

Fix: plain-admin view URL methods duplicated 5x instead of declared on AdminView base - #122

Open
pullapprove5[bot] wants to merge 1 commit into
masterfrom
pullapprove/pa-20-d482d1
Open

Fix: plain-admin view URL methods duplicated 5x instead of declared on AdminView base#122
pullapprove5[bot] wants to merge 1 commit into
masterfrom
pullapprove/pa-20-d482d1

Conversation

@pullapprove5

@pullapprove5 pullapprove5 Bot commented Sep 5, 2026

Copy link
Copy Markdown

Finding confirmed and fixed. plain-admin/plain/admin/views/objects.py duplicated identical get_list_url/get_create_url/get_detail_url/get_update_url/get_delete_url return "" stubs across 5 AdminView subclasses (25 copies of 5 methods), and viewsets.py/registry.py carried 7 # ty: ignore comments only because AdminViewset.get_views() was typed to return list[type[View]] (the framework base View) instead of list[type[AdminView]], and registry.py's register_view TypeVar T was unbound.

Reproduced by stripping the 7 # ty: ignore comments from viewsets.py/registry.py and running uv run ty check plain-admin (had to pip install --user uv first since it wasn't on PATH in this sandbox) — got exactly 7 diagnostics: 6 unresolved-attribute in viewsets.py (viewset, get_list_url, get_create_url, get_detail_url, get_update_url, get_delete_url on type[View[Response]]) plus 1 invalid-argument-type in registry.py:44 (set.add expecting type[AdminView], got type[T@register_view]). Restored the ignores and confirmed baseline is clean, masking the issue.

Fix: declared the five get_*_url methods directly on AdminView (base.py), deleted all 25 duplicate stubs from objects.py, changed AdminViewset.get_views() to iterate/return list[type[AdminView]] (checking issubclass(attr, AdminView) instead of the framework's View), and bound registry.py's TypeVar("T") to AdminView (needed for the 7th ignore — register_view's generic T was unbound, so even after fixing get_views()'s return type, self.registered_views.add(view) still failed under ty until T had an upper bound). Removed all 7 # ty: ignore comments; none remain in the touched files (one pre-existing, unrelated ignore remains in models.py, out of scope).

Verified the flip: same uv run ty check plain-admin command that produced 7 diagnostics on the pre-fix tree (with ignores stripped) now reports "All checks passed!" on the fixed tree with real ignores permanently removed (not just re-added). Also ran ./scripts/fix plain-admin (ruff, oxlint/oxfmt, prettier) and uv run plain-code check plain-admin (ruff, ty, oxlint, annotation coverage) — all clean.

Could not run ./scripts/test plain-admin or ./scripts/test: the suite requires a Postgres database via scripts/start-postgres, which falls back to Docker or a local Postgres on 5432, and neither is available in this sandbox (docker info fails, port 5432 refuses connections, and apt-get install postgresql 404s on the mirror for the required packages). No behavioral/runtime test coverage could be exercised for this change; static analysis (ty/ruff/oxlint) is what's verified here. The change is a pure type/structure refactor (moving identical method bodies up the class hierarchy) with no behavioral change, so this risk is low, but it's an honest gap in verification.


Opened by a PullApprove implementation run (implement-finding v4) for:

  • PA-20 — plain-admin view URL methods duplicated 5x instead of declared on AdminView base

Merging this is what closes them as fixed.

…n AdminView base

Finding confirmed and fixed. plain-admin/plain/admin/views/objects.py duplicated identical `get_list_url`/`get_create_url`/`get_detail_url`/`get_update_url`/`get_delete_url` `return ""` stubs across 5 AdminView subclasses (25 copies of 5 methods), and viewsets.py/registry.py carried 7 `# ty: ignore` comments only because AdminViewset.get_views() was typed to return `list[type[View]]` (the framework base View) instead of `list[type[AdminView]]`, and registry.py's `register_view` TypeVar `T` was unbound.

Reproduced by stripping the 7 `# ty: ignore` comments from viewsets.py/registry.py and running `uv run ty check plain-admin` (had to `pip install --user uv` first since it wasn't on PATH in this sandbox) — got exactly 7 diagnostics: 6 `unresolved-attribute` in viewsets.py (`viewset`, `get_list_url`, `get_create_url`, `get_detail_url`, `get_update_url`, `get_delete_url` on `type[View[Response]]`) plus 1 `invalid-argument-type` in registry.py:44 (`set.add` expecting `type[AdminView]`, got `type[T@register_view]`). Restored the ignores and confirmed baseline is clean, masking the issue.

Fix: declared the five `get_*_url` methods directly on `AdminView` (base.py), deleted all 25 duplicate stubs from objects.py, changed `AdminViewset.get_views()` to iterate/return `list[type[AdminView]]` (checking `issubclass(attr, AdminView)` instead of the framework's `View`), and bound registry.py's `TypeVar("T")` to `AdminView` (needed for the 7th ignore — `register_view`'s generic `T` was unbound, so even after fixing `get_views()`'s return type, `self.registered_views.add(view)` still failed under `ty` until `T` had an upper bound). Removed all 7 `# ty: ignore` comments; none remain in the touched files (one pre-existing, unrelated ignore remains in models.py, out of scope).

Verified the flip: same `uv run ty check plain-admin` command that produced 7 diagnostics on the pre-fix tree (with ignores stripped) now reports "All checks passed!" on the fixed tree with real ignores permanently removed (not just re-added). Also ran `./scripts/fix plain-admin` (ruff, oxlint/oxfmt, prettier) and `uv run plain-code check plain-admin` (ruff, ty, oxlint, annotation coverage) — all clean.

Could not run `./scripts/test plain-admin` or `./scripts/test`: the suite requires a Postgres database via `scripts/start-postgres`, which falls back to Docker or a local Postgres on 5432, and neither is available in this sandbox (`docker info` fails, port 5432 refuses connections, and `apt-get install postgresql` 404s on the mirror for the required packages). No behavioral/runtime test coverage could be exercised for this change; static analysis (ty/ruff/oxlint) is what's verified here. The change is a pure type/structure refactor (moving identical method bodies up the class hierarchy) with no behavioral change, so this risk is low, but it's an honest gap in verification.
@pullapprove5

pullapprove5 Bot commented Sep 5, 2026

Copy link
Copy Markdown
Author
PENDING: 1 review scope pending, 1 agent approved
Scope Progress Pending
code 0/1 davegaeddert

codex approved

View in PullApprove

Next steps:

  • pullapprove5[bot]: Waiting for reviews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants