Title: docs(skills): add dataclass-over-NamedTuple guideline to usethis-python-functions skill by Copilot · Pull Request #1882 · usethis-python/usethis-python · GitHub
Open Graph Title: docs(skills): add dataclass-over-NamedTuple guideline to usethis-python-functions skill by Copilot · Pull Request #1882 · usethis-python/usethis-python
X Title: docs(skills): add dataclass-over-NamedTuple guideline to usethis-python-functions skill by Copilot · Pull Request #1882 · usethis-python/usethis-python
Description: Agents defaulted to NamedTuple for structured return types despite it leaking unintended tuple semantics (positional indexing, iteration, unpacking, positional equality). @dataclass is the correct default for grouping named fields. Changes usethis-python-functions skill (v1.3 → v1.4): adds a new "Prefer dataclasses over NamedTuples for structured types" section covering: Why NamedTuple is the wrong default (tuple semantics leak implementation details) When NamedTuple is genuinely appropriate (positional comparison, iteration, interop with tuple-expecting code) Canonical example contrasting the two approaches Common mistakes (choosing NamedTuple for brevity or speculative future unpacking) # Bad: positional indexing silently works; fragile on field reorder class Result(NamedTuple): stdout: str stderr: str result[0] # compiles and runs; wrong if fields ever reorder # Good: only named access available @dataclass class Result: stdout: str stderr: str result.stdout # explicit and refactor-safe Placed in usethis-python-functions alongside the existing "Avoid returning tuples" section, which already recommends dataclasses as the structured alternative.
Open Graph Description: Agents defaulted to NamedTuple for structured return types despite it leaking unintended tuple semantics (positional indexing, iteration, unpacking, positional equality). @dataclass is the correct ...
X Description: Agents defaulted to NamedTuple for structured return types despite it leaking unintended tuple semantics (positional indexing, iteration, unpacking, positional equality). @dataclass is the correct ...
Opengraph URL: https://github.com/usethis-python/usethis-python/pull/1882
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0a88199b-3245-6b2f-ab50-9a581db2f583 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9D4C:4950B:171FFB4:1F5C52A:6A4F0A4E |
| html-safe-nonce | 806ee0a626825a2cc73ca58594ce15a1f177506255f2a677f80de0826a795f52 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDRDOjQ5NTBCOjE3MUZGQjQ6MUY1QzUyQTo2QTRGMEE0RSIsInZpc2l0b3JfaWQiOiIzMzkyMjUxODgzMjU5MTAzODIyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d647bb8b380a71b6586ded4f96d62b264f004e6365cefe5177bf8915fbe55276 |
| hovercard-subject-tag | pull_request:3500625460 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/usethis-python/usethis-python/pull/1882/files |
| twitter:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| og:image:alt | Agents defaulted to NamedTuple for structured return types despite it leaking unintended tuple semantics (positional indexing, iteration, unpacking, positional equality). @dataclass is the correct ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width