Skip to content

Conversation

lutostag
Copy link
Contributor

@lutostag lutostag commented Dec 8, 2019

As None is typically used for the default value, it is not usually
encoded on its own into schemas. Issue #1087 , where using None
not as the top-level value, but rather inside other objects (e.g.
[None]) will throw a Traceback.

Original issue found downstream at fastapi/fastapi#776

Change Summary

Handle the None case in pydantic.schema.encode_default

Related issue number

#1087

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)

Not sure if any documentation is needed here. If you are looking for anything different or this doesnt work for some case, please let me know, and I will be more than happy to follow any suggestions!

Thanks!

As None is typically used for the default value, it is not usually
encoded on its own into schemas. There was an issue, where using None
not as the top-level value, but rather inside other objects (e.g.
[None]) will throw a Traceback.
@codecov
Copy link

codecov bot commented Dec 8, 2019

Codecov Report

Merging #1088 into master will not change coverage.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #1088   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          20      20           
  Lines        3365    3367    +2     
  Branches      663     664    +1     
======================================
+ Hits         3365    3367    +2
Impacted Files Coverage Δ
pydantic/schema.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe0be5f...0f49bf0. Read the comment docs.

@samuelcolvin samuelcolvin merged commit 34a64ef into pydantic:master Dec 9, 2019
@samuelcolvin
Copy link
Member

awesome, thank you very much.

andreshndz pushed a commit to cuenca-mx/pydantic that referenced this pull request Jan 17, 2020
fix pydantic#1087

As None is typically used for the default value, it is not usually
encoded on its own into schemas. There was an issue, where using None
not as the top-level value, but rather inside other objects (e.g.
[None]) will throw a Traceback.
alexdrydew pushed a commit to alexdrydew/pydantic that referenced this pull request Dec 23, 2023
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.

3 participants