10000 Fix :: Signature generation with `extra: allow` never uses a field name by PrettyWood · Pull Request #1420 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

Fix :: Signature generation with extra: allow never uses a field name #1420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2020

Conversation

PrettyWood
Copy link
Collaborator
@PrettyWood PrettyWood commented Apr 22, 2020

Change Summary

When a model was created with extra: allow, the generate_model_signature would add the kwargs parameter with name data coming from BaseModel.__init__.
This fix makes the name a bit more explicit (extra_data by default) and adds as many trailing _ as needed to be sure the name is available.

Related issue number

fix #1418

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)

@codecov
Copy link
codecov bot commented Apr 22, 2020

Codecov Report

Merging #1420 into master will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #1420   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         3741      3747    +6     
  Branches       740       742    +2     
=========================================
+ Hits          3741      3747    +6     
Impacted Files Coverage Δ
pydantic/utils.py 100.00% <100.00%> (ø)

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 3cd8b1e...55a9bb0. Read the comment docs.

PrettyWood and others added 2 commits April 23, 2020 01:26
`extra_data: Dict[str, str]` would generate `extra_data: str` in the signature
@samuelcolvin samuelcolvin merged commit b287146 into pydantic:master Apr 23, 2020
@samuelcolvin
Copy link
Member

thanks so much. I made some tweaks to keep the kwarg name from the actual signature if it's provided.

@PrettyWood
Copy link
Collaborator Author
PrettyWood commented Apr 23, 2020

@samuelcolvin Oh yes right my bad... Thanks!
Btw why did you remove the test with Dict[str, str] to make sure the signature was correct with it? No big deal but it was useful to avoid a regression on 2nd commit wasn't it?

@PrettyWood PrettyWood deleted the fix/data-signature branch April 23, 2020 13:47
PrettyWood added a commit to PrettyWood/pydantic that referenced this pull request Apr 24, 2020
`data` has been renamed into `extra_data` to be more explicit in pydantic#1420
PrettyWood added a commit to PrettyWood/pydantic that referenced this pull request Apr 24, 2020
`data` has been renamed into `extra_data` to be more explicit in pydantic#1420
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.

Model signature generation makes incorrect signature for models with extras allowed and data attribute in spec
2 participants
0