-
-
Notifications
You must be signed in to change notification settings - Fork 485
Fix incorrect and add missing annotations for loaddata command #536
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
Conversation
- Added some of the instance attributes from command arguments: ignore, using, app_label, verbosity, format. - Added class attribute: help. - Fixed return type of find_fixtures.
CI appears to have failed booting without actually running the tests. If the maintainers are interested in this patch, would they please re-start CI? I don't think I can do it myself. |
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Please, double check that all new attrs are not duplicating ones from BaseCommand
👍
This incorporates all type information I could glean from loaddata at django/django@adb40d2. - Remove `help` per review comment: typeddjango#536 (comment) - Add `exclude_models` and `exclude_apps` based on the return type of `..utils.parse_apps_and_model_labels`. - Change `loaddata`'s `fixture_labels` to `Sequence` of `str` instead of `Iterable` because in practice it's a tuple, but at a type level, the important thing is that `loaddata` iterates over `fixture_labels` more than once. General iterables (which include iterators) need not support iteration more than once. - Correct the return type of `parse_name` to account for the possibility that the data and compression formats are `None`. - Correct the return type of `find_fixtures` to be a list of the same type that `parse_name` returns. - Add a type annotation for `SingleZipReader.read`. Django implements the method in a way that actually conflicts with `zipfile.ZipFile.read`'s type. This necessitates a `type: ignore[override]` to keep the tests passing. Mypy is correct that there is an override error, but Django's code is what it is. (And that method's signature was introduced way back in Django version 1.1, commit django/django@089ab18.)
CI seems ill.
All tests and lints pass locally for me with Python 3.7 set up per https://github.com/typeddjango/django-stubs/blob/master/CONTRIBUTING.md |
This incorporates all type information I could glean from loaddata at django/django@adb40d2. - Remove `help` per review comment: typeddjango#536 (comment) - Add `exclude_models` and `exclude_apps` based on the return type of `..utils.parse_apps_and_model_labels`. - Change `loaddata`'s `fixture_labels` to `Sequence` of `str` instead of `Iterable` because in practice it's a tuple, but at a type level, the important thing is that `loaddata` iterates over `fixture_labels` more than once. General iterables (which include iterators) need not support iteration more than once. - Correct the return type of `parse_name` to account for the possibility that the data and compression formats are `None`. - Correct the return type of `find_fixtures` to be a list of the same type that `parse_name` returns. - Add a type annotation for `SingleZipReader.read`. Django implements the method in a way that actually conflicts with `zipfile.ZipFile.read`'s type. This necessitates a `type: ignore[override]` to keep the tests passing. Mypy is correct that there is an override error, but Django's code is what it is. (And that method's signature was introduced way back in Django version 1.1, commit django/django@089ab18.)
ignore
,using
,app_label
,verbosity
,format
.help
.find_fixtures
.