Skip to content

Fix Pydantic V1 required field has default=None - #45

Open
dolfinus wants to merge 1 commit into
pyapp-kit:mainfrom
dolfinus:bugfix/pydantic-v1-default
Open

Fix Pydantic V1 required field has default=None#45
dolfinus wants to merge 1 commit into
pyapp-kit:mainfrom
dolfinus:bugfix/pydantic-v1-default

Conversation

@dolfinus

@dolfinus dolfinus commented Jul 7, 2026

Copy link
Copy Markdown

I've faced a difference in result of the code below between Pydantic versions:

from pydantic import BaseModel

class MyModel(BaseModel):
  field: int

from fieldz import fields

field = fields(MyModel)[0]
assert field.default is field.MISSING

It works on Pydantic v2 but fails with assertion on Pydantic v1. This is because v1 returns ModelField(name='a', type=int, required=True) with default=None.

@dolfinus
dolfinus force-pushed the bugfix/pydantic-v1-default branch from 1e13d4f to 627b3e7 Compare July 7, 2026 15:56
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.33%. Comparing base (7bae0f3) to head (627b3e7).

Files with missing lines Patch % Lines
src/fieldz/adapters/_pydantic.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #45      +/-   ##
==========================================
- Coverage   96.52%   96.33%   -0.20%     
==========================================
  Files          13       13              
  Lines         403      409       +6     
==========================================
+ Hits          389      394       +5     
- Misses         14       15       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant