Title: agent: use @final instead of prose to enforce non-override constraints on methods · Issue #1907 · usethis-python/usethis-python · GitHub
Open Graph Title: agent: use @final instead of prose to enforce non-override constraints on methods · Issue #1907 · usethis-python/usethis-python
X Title: agent: use @final instead of prose to enforce non-override constraints on methods · Issue #1907 · usethis-python/usethis-python
Description: What happened When introducing derived methods that should not be overridden in subclasses (because a separate method is the designated override point), prose text was added to the docstrings — e.g. "tools should override deps_by_group i...
Open Graph Description: What happened When introducing derived methods that should not be overridden in subclasses (because a separate method is the designated override point), prose text was added to the docstrings — e.g...
X Description: What happened When introducing derived methods that should not be overridden in subclasses (because a separate method is the designated override point), prose text was added to the docstrings — e.g...
Opengraph URL: https://github.com/usethis-python/usethis-python/issues/1907
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"agent: use @final instead of prose to enforce non-override constraints on methods","articleBody":"## What happened\n\nWhen introducing derived methods that should not be overridden in subclasses (because a separate method is the designated override point), prose text was added to the docstrings — e.g. \"tools should override `deps_by_group` instead of this method\". A reviewer rejected this and asked to use `@final` instead.\n\n## Root cause\n\nProse documentation was chosen as the communication mechanism when Python's `@final` decorator was the correct tool. This happened because the instinct was to communicate the constraint descriptively (via docs) rather than prescriptively (via the type system).\n\n## Generalised principle\n\nWhen a method in a base class must not be overridden by subclasses, always mark it with `@final` rather than (or in addition to) documenting the constraint in prose. `@final` is enforced by type checkers and IDEs at the point of violation; prose is merely advisory and silently ignored. If a method is purely derived from another override point, `@final` makes that structural intent machine-checkable and removes the need for \"do not override\" comments entirely.\n\n## Resolution\n\nAdded `@final` to the four derived methods (`dev_deps`, `test_deps`, `doc_deps`, `get_dep_group_deps`) in `src/usethis/_tool/spec.py` and removed the prose warning from their docstrings (commit `cfef8e6`).\n\n## Follow-up\n\nNone — the fix is already applied. This lesson is filed so future agent sessions default to `@final` when enforcing non-override constraints.","author":{"url":"https://github.com/nathanjmcdougall","@type":"Person","name":"nathanjmcdougall"},"datePublished":"2026-04-09T20:23:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1907/usethis-python/issues/1907"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cb4619d8-4240-59dc-7ffd-1879cbad38d5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B28:16DD22:E16636:13679CF:6A4DD024 |
| html-safe-nonce | 55d215621f0740de241c84d06cab3e7826aa03fc5bd2973df8ab7811c15402dc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjI4OjE2REQyMjpFMTY2MzY6MTM2NzlDRjo2QTRERDAyNCIsInZpc2l0b3JfaWQiOiI0ODU3NzAxNzUxMjIwNzE5NjUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b4215f8dba6338f40da263a1e0a672e74032dead8a38d00735ac250446c34194 |
| hovercard-subject-tag | issue:4234716706 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/usethis-python/usethis-python/1907/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8dee865acdb7a0e4bccfc0c1d8d9f5ef54961d4068805f1f8be6210adc27bcda/usethis-python/usethis-python/issues/1907 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8dee865acdb7a0e4bccfc0c1d8d9f5ef54961d4068805f1f8be6210adc27bcda/usethis-python/usethis-python/issues/1907 |
| og:image:alt | What happened When introducing derived methods that should not be overridden in subclasses (because a separate method is the designated override point), prose text was added to the docstrings — e.g... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nathanjmcdougall |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/usethis-python/usethis-python git https://github.com/usethis-python/usethis-python.git |
| octolytics-dimension-user_id | 216362695 |
| octolytics-dimension-user_login | usethis-python |
| octolytics-dimension-repository_id | 842189705 |
| octolytics-dimension-repository_nwo | usethis-python/usethis-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 842189705 |
| octolytics-dimension-repository_network_root_nwo | usethis-python/usethis-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width