Title: Fix KeyError in fancy_model_dump for pydantic models with extra fields by Copilot · Pull Request #1689 · usethis-python/usethis-python · GitHub
Open Graph Title: Fix KeyError in fancy_model_dump for pydantic models with extra fields by Copilot · Pull Request #1689 · usethis-python/usethis-python
X Title: Fix KeyError in fancy_model_dump for pydantic models with extra fields by Copilot · Pull Request #1689 · usethis-python/usethis-python
Description: Pre-commit config files using prek syntax contain extra fields like priority: 0 on hooks and minimum_prek_version at the top level. These are accepted by our pydantic models (extra="allow"), but _fancy_model_dump_base_model crashes because for key, value in model: yields extra fields while model.model_fields[key] only contains declared fields. Fix In _fancy_model_dump_base_model, use model_fields.get(key) instead of model_fields[key] and branch: field_info = model.__class__.model_fields.get(key) if field_info is not None: # declared field: check defaults, aliases, reference diffing ... else: # extra field: always include, use raw key display_key = key Tests Unit tests (TestExtraFields): extra field inclusion, interaction with defaults/references, nested models Integration tests: add_repo against YAML with priority, minimum_prek_version, and arbitrary extra keys at top-level/repo/hook levels, verified via parsed YAML structure
Open Graph Description: Pre-commit config files using prek syntax contain extra fields like priority: 0 on hooks and minimum_prek_version at the top level. These are accepted by our pydantic models (extra="allow"...
X Description: Pre-commit config files using prek syntax contain extra fields like priority: 0 on hooks and minimum_prek_version at the top level. These are accepted by our pydantic models (extra="allow&...
Opengraph URL: https://github.com/usethis-python/usethis-python/pull/1689
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3155d22f-5188-dd1b-b704-fa808693aef4 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9AB4:13DDC4:8DB81CD:C608290:6A5087BC |
| html-safe-nonce | 02d2004227c1a04b9a0ba612f190904736ab1ce50804de47243eed8c27621e8a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUI0OjEzRERDNDo4REI4MUNEOkM2MDgyOTA6NkE1MDg3QkMiLCJ2aXNpdG9yX2lkIjoiODMzMTQ2MzgzNTU3MjUzNzI3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | be271895fdd1989b0899be2c160ab369c9465728d850d381c54f1f572a50da2f |
| hovercard-subject-tag | pull_request:3475126462 |
| 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/1689/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 | Pre-commit config files using prek syntax contain extra fields like priority: 0 on hooks and minimum_prek_version at the top level. These are accepted by our pydantic models (extra="allow"... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width