Skip to content

fix: keep old behaviour of json() by default#3542

Merged
samuelcolvin merged 3 commits intopydantic:masterfrom
PrettyWood:fallback-encoder
Dec 24, 2021
Merged

fix: keep old behaviour of json() by default#3542
samuelcolvin merged 3 commits intopydantic:masterfrom
PrettyWood:fallback-encoder

Conversation

@PrettyWood
Copy link
Copy Markdown
Contributor

@PrettyWood PrettyWood commented Dec 19, 2021

Change Summary

fix regression on 1.9 introduced in #2650 (see #3538 (reply in thread))

Related issue number

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 (I didn't add a change file since it's due to a new feature of 1.9)
    (see changes/README.md for details)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@PrettyWood
Copy link
Copy Markdown
Contributor Author

please review

@layday
Copy link
Copy Markdown
Contributor

layday commented Dec 19, 2021

I'm not sure if this is a good workaround. IIUC the (broader) issue with #2650 is that the transformation is no longer recursive. This will manifest in other ways (and it already has: #3544 :) It'd probably make more sense to expose to_dict in json, but adding more options always comes at a cost.

@layday
Copy link
Copy Markdown
Contributor

layday commented Dec 19, 2021

If you don't want to delay v1.9 then reverting #2650 might be the best course of action for the time being?

@PrettyWood
Copy link
Copy Markdown
Contributor Author

Yeah I saw new issues pop up. I will take some time tomorrow to check properly. But if no easy workaround is possible, I'll revert #2650

@PrettyWood PrettyWood changed the title fix: handle basemodel fallback for custom encoders fix: keep old behaviour of json() by default Dec 20, 2021
@PrettyWood PrettyWood added the bug V1 Bug related to Pydantic V1.X label Dec 20, 2021
Comment thread pydantic/main.py Outdated
Co-authored-by: Christian Bundy <christianbundy@fraction.io>
@samuelcolvin
Copy link
Copy Markdown
Member

@PrettyWood did you have time to think about this?

I've haven't dug into it in detail, but I will try to find time soon.

@christianbundy
Copy link
Copy Markdown
Contributor

FWIW after the force-push this seems to solve the problem (and adds a test from #3544). At least from my perspective, this looks Fine™️.

@PrettyWood
Copy link
Copy Markdown
Contributor Author

This should solve everything yes

@samuelcolvin samuelcolvin merged commit edad0db into pydantic:master Dec 24, 2021
@samuelcolvin
Copy link
Copy Markdown
Member

awesome, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug V1 Bug related to Pydantic V1.X ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants