* DatabaseClient: add missing class method `settings_to_cmd_args_env` and add missing arg to `runshell`
The `DatabaseClient.runshell()` was refactored in Django 3.2 to be more standardized
across the different database backends.
* DatabaseClient: make `settings_dict` dict type better by specifying key/value types
* tests: add missing db backend client files to `import_all_modules`
* _default_manager has more specific type for TypeVars
* remove unnecessary # type: ignore
* add test for _base_manager
* add overloads for classproperty.__get__
* readd # type: ignore for WSGIRequestHandler.connection, fails in github's pipeline
* fix _base_manager test: mypy reveals an inferred type
Co-authored-by: Michael Pöhle <michael.poehle@polyteia.de>
While `object_list` isn't defined at construction, `BaseListView.get()`
sets it when handling a request, so in practice it is defined whenever
a list view is doing its work.
The Django documentation describes `object_list` as "the list of
objects (usually, but not necessarily a queryset)", so I picked
`Sequence` as the type.
Closes#790
* Refactor to more easily support additional config options
* Notify when Manager.from_queryset happens inside model class body
- A warning will be emitted whenever `Manager.from_queryset` happens
inside of a model class body
* Resolve generated default manager types before final iteration
A default manager on a model should always exist, eventually. Although,
we extend to look through dynamically generated managers on each
iteration instead of deferring until the final iteration.
Instead of copying methods over from a QuerySet passed to a basemanager
when invoking '<BaseManager>.from_queryset', any QuerySet methods are
declared as attributes on the manager.
This allows us to properly lookup any QuerySet method types via a
'get_attribute_hook' and will thus remove disorienting phantom errors
occuring from mypy trying to resolve types only existing in the module
where the _original_ (and real) queryset method was declared.
The `extra_context` argument to `ModelAdmin.changeform_view`,
`add_view`, `change_view`, `changelist_view`, `delete_view`, and
`history_view` is used to pass extra context variables to a template, so
all of these arguments should have type `Optional[Dict[str, Any]]`.
Instead, these are currently typed as `Optional[Dict[str, bool]]`,
`Optional[Dict[str, str]]`, or `None`.
* Allow List[Tuple[Any]] as args_generator argument to format_html_join
format_html_join's args_generator argument can be anything that contains
tuples of things that can be coerced to strings or that have a
`__html__` method.
Fixes#721.
* Use `Iterable[Iterable[Any]]` as `args_generator` type
* Run linter
* Fix annotation of ModelAdmin.get_object
The type annotation in django-stubs indicated that the type of the
`from_field` argument to `ModelAdmin.get_object` should be `None`. In
fact, `None` is the default value of that argument. If the argument is
not `None`, [it is passed to a model's `_meta.get_field` method][impl], which
takes an argument of type `Union[Callable[..., Any], str`.
[impl]: ac5cc6cf01/django/contrib/admin/options.py (L767)
* Fix formatting
get_object's default implementation returns None but subclasses
are allowed to override this method and make it return anything.
The returned object would then be passed to other methods
to publish different data for different URL parameters.
https://docs.djangoproject.com/en/4.0/ref/contrib/syndication/