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

Create regression test for related managers 2022 #967

Closed
wants to merge 1 commit into from

Conversation

aleksanb
Copy link
Contributor

RelatedManagers do not get set up for me anymore with the latest plugin rewrites.
I took another stab at making a test case.

#902 (comment)


def process_user(user: User):
reveal_type(user.bookingowner_set) # N: Revealed type is 'django.db.models.manager.RelatedManager[myapp.models.Booking]'
reveal_type(user.booking_set) # N: Revealed type is 'django.db.models.manager.RelatedManager[myapp.models.Booking]'
Copy link
Collaborator

@intgr intgr May 25, 2022

Choose a reason for hiding this comment

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

We could consider using typing_extensions.assert_type() instead of reveal_type(), which is less verbose.

But would need to ensure that testing dependencies are typing-extensions>=4.2.0 and mypy>=0.950 then.

Copy link
Member

Choose a reason for hiding this comment

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

I think that it won't work with our pytest-mypy-plugin lib 🤔

ordering = ['-created_at']

def process_user(user: User):
reveal_type(user.bookingowner_set) # N: Revealed type is 'django.db.models.manager.RelatedManager[myapp.models.Booking]'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
reveal_type(user.bookingowner_set) # N: Revealed type is 'django.db.models.manager.RelatedManager[myapp.models.Booking]'
reveal_type(user.bookingowner_set) # N: Revealed type is "django.db.models.manager.RelatedManager[myapp.models.Booking]"


def process_user(user: User):
reveal_type(user.bookingowner_set) # N: Revealed type is 'django.db.models.manager.RelatedManager[myapp.models.Booking]'
reveal_type(user.booking_set) # N: Revealed type is 'django.db.models.manager.RelatedManager[myapp.models.Booking]'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
reveal_type(user.booking_set) # N: Revealed type is 'django.db.models.manager.RelatedManager[myapp.models.Booking]'
reveal_type(user.booking_set) # N: Revealed type is "django.db.models.manager.RelatedManager[myapp.models.Booking]"

@aleksanb
Copy link
Contributor Author

Closed in favor of #993.

@aleksanb aleksanb closed this Jun 14, 2022
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.

None yet

3 participants