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

Inherit from faked classes in tests to satisfy mypy #8859

Merged
merged 3 commits into from
Jan 28, 2023

Conversation

piotrszyma
Copy link
Contributor

After adding typing of APIClient.get method to drf stubs project typeddjango/djangorestframework-stubs#330 mypy started complaining about these classes in tests:

drf_source/tests/test_reverse.py:43: error: Incompatible types in assignment (expression has type "MockVersioningScheme", variable has type "Optional[BaseVersioning]")
drf_source/tests/test_reverse.py:50: error: Incompatible types in assignment (expression has type "MockVersioningScheme", variable has type "Optional[BaseVersioning]")
drf_source/tests/test_versioning.py:136: error: Incompatible types in assignment (expression has type "Type[FakeResolverMatch]", variable has type "Optional[ResolverMatch]")
drf_source/tests/test_versioning.py:209: error: Incompatible types in assignment (expression has type "Type[FakeResolverMatch]", variable has type "Optional[ResolverMatch]")
drf_source/tests/test_versioning.py:260: error: Incompatible types in assignment (expression has type "Type[FakeResolverMatch]", variable has type "Optional[ResolverMatch]")

This PR fixes these errors:

  • FakeResolverMatch now inherits ResolverMatch,
  • MockVersioningScheme now inherits from BaseVersioning

what satisfies the type system.

@piotrszyma piotrszyma changed the title Pszyma/subclass in tests Inherit from faked classes in tests to satisfy mypy Jan 27, 2023
@auvipy auvipy merged commit 22d206c into encode:master Jan 28, 2023
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.

2 participants