KEMBAR78
Add a check on the existence of `__qualname__` by anci3ntr0ck · Pull Request #8642 · pydantic/pydantic · GitHub
Skip to content

Conversation

@anci3ntr0ck
Copy link
Contributor

@anci3ntr0ck anci3ntr0ck commented Jan 26, 2024

Change Summary

Add a check on the existence of __qualname__ in the namespace in function inspect_namespace, to avoid unexpected KeyError when setting a type-type default value in create_model, which type is defined in the same module.

Related issue number

Fix #8633

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @sydney-runkle

Selected Reviewer: @Kludex

@anci3ntr0ck
Copy link
Contributor Author

please review

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 26, 2024

CodSpeed Performance Report

Merging #8642 will not alter performance

Comparing anci3ntr0ck:fix-qualname-existence-check (e73cccb) with main (2792775)

Summary

✅ 10 untouched benchmarks

@anci3ntr0ck
Copy link
Contributor Author

anci3ntr0ck commented Jan 26, 2024

sry, just forget to add labels🙃 or labels should be added by maintainers🤔?

@sydney-runkle sydney-runkle added the relnotes-fix Used for bugfixes. label Jan 26, 2024
Copy link
Contributor

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall - just added one slight modification to the test to verify that the default is assigned as expected :).

Thanks for your contribution - we're super excited to have you as a contributor to the pydantic repo! 🚀

@sydney-runkle sydney-runkle merged commit 57922ba into pydantic:main Jan 26, 2024
@anci3ntr0ck anci3ntr0ck deleted the fix-qualname-existence-check branch January 26, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected KeyError occured when calling create_model with a type-type field which is defined in the same module

3 participants