Skip to content

Remove unnecessary type conversions#7526

Merged
lovelydinosaur merged 1 commit intoencode:masterfrom
franciscouzo:remove-unnecessary-conversions
Sep 8, 2020
Merged

Remove unnecessary type conversions#7526
lovelydinosaur merged 1 commit intoencode:masterfrom
franciscouzo:remove-unnecessary-conversions

Conversation

@franciscouzo
Copy link
Copy Markdown
Contributor

Since 3.5, it's possible to merge dictionaries with the ** syntax.
When Python 3.9 is the minimum supported version (2024), we'll be able to do validated_data = self.validated_data | kwargs .

@lovelydinosaur
Copy link
Copy Markdown
Contributor

These look neater, yup. Thank you!

@lovelydinosaur lovelydinosaur merged commit 6b632c1 into encode:master Sep 8, 2020
@franciscouzo franciscouzo deleted the remove-unnecessary-conversions branch September 8, 2020 17:27
@jgrewal1991
Copy link
Copy Markdown

jgrewal1991 commented Nov 3, 2020

@tomchristie @franciscouzo
After this change, look like formData posted is getting little messed up. In my case, validated_data in previous versions was coming up as :
{'name': '2020.pdf', 'type': 1, 'creator': 'asdfga69-cdgaba-46e5-bfdge-da2fgdsfac77', 'additional_data': {'designation': 2, 'date': '2020-11-01', 'number': 'dafsda'}}

but now, it is becoming:

{'name': ['2020.pdf'], 'type': [1], 'creator': ['asdfga69-cdgaba-46e5-bfdge-da2fgdsfac77'], 'additional_data': [{'designation': 2, 'date': '2020-11-01', 'number': 'dafsda'}]}

Due to which validations are failing.
https://github.com/encode/django-rest-framework/pull/7526/files#diff-c33f1f011c9f5cf3ed1357b809ebf2b4ed0b808b227c6c007291bf9b259422ecR197

@carltongibson
Copy link
Copy Markdown
Collaborator

@jgrewal1991 Can you open a new issue with this please? Ideally if you could provide a test case that demonstrates the regression that would help. Thanks.

@jgrewal1991
Copy link
Copy Markdown

@carltongibson #7623

sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
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.

4 participants