Skip to content
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

✨ Add codemod and rule to add type annotations or TODO comment for fields with a default and no type annotations #163

Merged
merged 7 commits into from
Apr 18, 2024

Conversation

tiangolo
Copy link
Member

@tiangolo tiangolo commented Apr 18, 2024

✨ Add codemod and rule to add type annotations or TODO comment for fields with a default and no type annotations

This would fix #149

" a = 'a'",
" b = 'b'",
"",
"class A(BaseModel):",
" a: Literal[A.a] = A.a",
" a: Literal[E.a] = E.a",
Copy link
Member Author

Choose a reason for hiding this comment

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

These tests were failing because both classes had the same name, one would override the other.

And then the new "add type annotations" codemod would modify the enum, just because the name is the same. But as it's not really valid to have the same name for two classes in the same file, I just updated it. 🤓

@tiangolo tiangolo marked this pull request as ready for review April 18, 2024 06:29
@Kludex
Copy link
Member

Kludex commented Apr 18, 2024

Gracias!

@Kludex Kludex merged commit 5e4a43b into pydantic:main Apr 18, 2024
8 checks passed
@tiangolo tiangolo deleted the add-annotations branch April 18, 2024 17:29
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.

Add support for handling unannotated fields
2 participants