You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from __future__ importannotationsfromtypingimportProtocolfromdjango.db.modelsimportfieldsfromdjango.db.models.sqlimportcompiler, queryclassCompilable(Protocol):
""" Object that can be compiled to a PEP 249 compliant tuple comprised of a SQL string and its associated parameters sequence. It can optionally have `as_vendor` methods defined to specialize the compilation on different backends (e.g. `as_postgres`). """defget_source_expressions(self) ->list[Compilable|None]: ...
defas_sql(
self, compiler: compiler.SQLCompiler, connection
) ->tuple[str, tuple]: ...
classResolvable(Protocol):
""" Object that can resolve any field and transform reference it has in the context of a query and return an object ready to be compiled for execution. """output_field: fields.Fielddefget_source_expressions(self) ->list[Resolvable|None]: ...
defresolve_expression(
self,
query: query.Query,
allow_joins: bool=True,
reuse: set[str] |None=None,
summarize: bool=False,
for_save: bool=False,
) ->Compilable: ...
I think we could try adding these in django-stubs and seeing how much simpler and more comprehensible they make things.
The text was updated successfully, but these errors were encountered:
I think we could try adding these in django-stubs and seeing how much simpler and more comprehensible they make things.
This will require TYPING_CHECKING only imports, because django-stubs does not have runtime.
If you want them to be user accessible, then we can add them to django-stubs-ext
Suggested by @charettes on a Django forum discussion regrading adding types to Django:
I think we could try adding these in django-stubs and seeing how much simpler and more comprehensible they make things.
The text was updated successfully, but these errors were encountered: