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 djangorestframework-stubs for better typing #1090

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

tdrivas
Copy link
Contributor

@tdrivas tdrivas commented Dec 21, 2024

This PR introduces the following updates to enhance type checking in our project:

  • Integrate mypy by adding mypy_drf_plugin to mypy.ini for better Django REST Framework type-checking.
  • Integrate pre-commit by updating .pre-commit-config.yaml to ensure mypy runs with pre-commit using the new plugin and settings.
  • Add djangorestframework-stubs to the requirements.in file in order to regenerate the appropriate requirements.txt
  • Fix various typing issues such as type mismatches in exception, and incorrect annonations

Examples of issues:

  1. from rest_framework.views import View --> The mypy-drf-plugin is strict about ensuring attributes or classes explicitly exported by a module. In simply words, mypy complains because it’s not officially listed in the all attribute of the rest_framework.views module.

@duke-nyuki
Copy link
Collaborator

.mypy.ini Show resolved Hide resolved
@tdrivas tdrivas requested a review from suricactus December 22, 2024 00:27
docker-app/qfieldcloud/core/exceptions.py Outdated Show resolved Hide resolved
docker-app/qfieldcloud/core/drf_utils.py Outdated Show resolved Hide resolved
docker-app/qfieldcloud/core/drf_utils.py Show resolved Hide resolved
docker-app/qfieldcloud/core/drf_utils.py Outdated Show resolved Hide resolved
@tdrivas tdrivas requested a review from suricactus December 22, 2024 08:55
Copy link
Collaborator

@suricactus suricactus left a comment

Choose a reason for hiding this comment

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

Thanks! Please squash all the commits into a single one and rebase on latest master. Then I will merge after second check.

Update classic

Upating docstring and fix noise

Fix wrong type of request
@tdrivas tdrivas force-pushed the QF-4916-add-djangorestframework-stubs branch from 8bd716c to 0564c50 Compare December 22, 2024 18:29
@tdrivas tdrivas requested a review from suricactus December 22, 2024 18:30
Copy link
Collaborator

@suricactus suricactus left a comment

Choose a reason for hiding this comment

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

Thanks!

@suricactus suricactus merged commit 2d3012c into master Dec 22, 2024
13 checks passed
@suricactus suricactus deleted the QF-4916-add-djangorestframework-stubs branch December 22, 2024 22:01
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.

3 participants