jazzband / jazzband/django-model-utils
Add type annotations
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.8k
- Forks
- 375
- PR merge metrics
- No merged PRs in 30d
Description
Problem
When type-checking a model that uses InheritanceManager using mypy, the following error is displayed:
app/models.py:39: error: Could not resolve manager type for
"app.models.MyModel.objects" [django-manager-missing]
objects = InheritanceManager()
^
According to this Stack Overflow post, the origin of this problem is the django-stubs mypy plugin being unable to find InheritanceManager because django-model-utils does not provide type annotations.
According to the linked post, no actual annotations are required, just a marker that the package is annotated. But I think real annotations would be good to have anyway, both for users and developers of django-model-utils.
I am working on adding annotations to django-model-utils. I don't know if I'll have enough time to completely annotate it, but I'll share what I have in any case, probably tomorrow.
Environment
- Django Model Utils version: 4.3.1
- Django version: 3.2
- Python version: 3.9
- Other libraries used, if any:
django-stubs1.16.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files or tests beyond the example app/models.py and InheritanceManager entry point. Start by reproducing the django-stubs mypy error with that model, then inspect django-model-utils' public utilities and existing test coverage. Done means the package is recognized as typed and the agreed annotation scope is covered without breaking supported Django and Python versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100