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

Fixed Collector.data and NestedObjects.data types #1366

Merged
merged 4 commits into from
Feb 20, 2023

Conversation

RyanWalker277
Copy link
Contributor

@RyanWalker277 RyanWalker277 commented Feb 16, 2023

Fixed Collector.data and NestedObjects.data types

Related issues

Fixes #1271

Code changes

Specified dict[type[Model], set[Model] | list[Model]] type for Collecor.data attribute

@RyanWalker277 RyanWalker277 requested a review from intgr February 17, 2023 04:54
Copy link
Collaborator

@intgr intgr left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@intgr
Copy link
Collaborator

intgr commented Feb 17, 2023

Take a look at the CI failures

@RyanWalker277
Copy link
Contributor Author

As suggested by kezabelle, I have made the changes to the code and used the type match Dict[Type[Model], Set[Model] | List[Model]] instead of typing the values as Any in the dictionary. Would appreciate it if you could review the changes and let me know if there is anything else that needs to be done.

Copy link
Collaborator

@intgr intgr left a comment

Choose a reason for hiding this comment

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

Thanks.

FWIW the downside of using Model instead of Any is that when you want to access the fields and methods of a particular model subclass (e.g. auth.models.User), mypy won't let you do that without an explicit cast() or isinstance() check. But either is fine by me.

@intgr intgr merged commit d1a1c81 into typeddjango:master Feb 20, 2023
@RyanWalker277 RyanWalker277 deleted the Fix#1271 branch February 21, 2023 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Collector.data and NestedObjects.data have different types, and are incorrect
3 participants