Skip to content

Commit

Permalink
Add a bunch of 'pyright: ignore' for django-stubs/
Browse files Browse the repository at this point in the history
  • Loading branch information
minmax committed Aug 30, 2024
1 parent 66d7ad1 commit 8f2dccb
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 41 deletions.
2 changes: 1 addition & 1 deletion django-stubs/contrib/admin/templatetags/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class InclusionAdminNode(InclusionNode):
args: list[Any]
func: Callable[..., Any]
kwargs: dict[Any, Any]
takes_context: bool
takes_context: bool # pyright: ignore[reportIncompatibleVariableOverride]
template_name: str = ...
def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/contrib/contenttypes/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class GenericForeignKey(FieldCacheMixin):
def __set__(self, instance: Model, value: Any | None) -> None: ...

class GenericRel(ForeignObjectRel):
field: GenericRelation
field: GenericRelation # pyright: ignore[reportIncompatibleVariableOverride]
def __init__(
self,
field: GenericRelation,
Expand Down
4 changes: 3 additions & 1 deletion django-stubs/contrib/contenttypes/models.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class ContentType(models.Model):
id: int
app_label: models.CharField[Any] = ...
model: models.CharField[Any] = ...
objects: ClassVar[ContentTypeManager] = ...
objects: ClassVar[ # pyright: ignore[reportIncompatibleVariableOverride]
ContentTypeManager
] = ...
permission_set: Manager[Permission]
@property
def name(self) -> str: ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/core/files/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class File(FileProxyMixin, IO[Any]):
def close(self) -> None: ...

class ContentFile(File):
file: StringIO
file: StringIO # pyright: ignore[reportIncompatibleVariableOverride]
size: Any = ...
def __init__(self, content: bytes | str, name: str | None = ...) -> None: ...
def write(self, data: str) -> int: ... # type: ignore[override]
Expand Down
12 changes: 6 additions & 6 deletions django-stubs/core/mail/message.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ class MIMEMixin: ...

class SafeMIMEMessage(MIMEMixin, MIMEMessage):
defects: list[Any]
epilogue: None
epilogue: None # pyright: ignore[reportIncompatibleVariableOverride]
policy: Policy # type: ignore [no-any-unimported]
preamble: None
preamble: None # pyright: ignore[reportIncompatibleVariableOverride]

class SafeMIMEText(MIMEMixin, MIMEText):
defects: list[Any]
epilogue: None
epilogue: None # pyright: ignore[reportIncompatibleVariableOverride]
policy: Policy # type: ignore [no-any-unimported]
preamble: None
preamble: None # pyright: ignore[reportIncompatibleVariableOverride]
encoding: str = ...
def __init__(
self, _text: str, _subtype: str = ..., _charset: str = ...
) -> None: ...

class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
defects: list[Any]
epilogue: None
epilogue: None # pyright: ignore[reportIncompatibleVariableOverride]
policy: Policy # type: ignore [no-any-unimported]
preamble: None
preamble: None # pyright: ignore[reportIncompatibleVariableOverride]
encoding: str = ...
def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/core/serializers/json.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class DjangoJSONEncoder(json.JSONEncoder):
allow_nan: bool
check_circular: bool
ensure_ascii: bool
indent: int
indent: int # pyright: ignore[reportIncompatibleVariableOverride]
skipkeys: bool
sort_keys: bool
4 changes: 2 additions & 2 deletions django-stubs/core/servers/basehttp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class WSGIRequestHandler(simple_server.WSGIRequestHandler):
close_connection: bool
connection: WSGIRequest
request: WSGIRequest
rfile: BytesIO
wfile: BytesIO
rfile: BytesIO # pyright: ignore[reportIncompatibleVariableOverride]
wfile: BytesIO # pyright: ignore[reportIncompatibleVariableOverride]
protocol_version: str = ...
def address_string(self) -> str: ...
def log_message(self, format: str, *args: Any) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/db/models/fields/files.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class FileField(Field[FileDescriptor, FileDescriptor]):
def generate_filename(self, instance: Model | None, filename: str) -> str: ...

class ImageFileDescriptor(FileDescriptor):
field: ImageField
field: ImageField # pyright: ignore[reportIncompatibleVariableOverride]
def __set__(self, instance: Model, value: str | None) -> None: ...

class ImageFieldFile(ImageFile, FieldFile):
field: ImageField
field: ImageField # pyright: ignore[reportIncompatibleVariableOverride]
def delete(self, save: bool = ...) -> None: ...

class ImageField(FileField):
Expand Down
40 changes: 28 additions & 12 deletions django-stubs/db/models/fields/related.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ _ErrorMessagesToOverride = dict[str, Any]
RECURSIVE_RELATIONSHIP_CONSTANT: str = ...

class RelatedField(FieldCacheMixin, Generic[_ST, _GT], Field[_ST, _GT]):
one_to_many: bool = ...
one_to_one: bool = ...
many_to_many: bool = ...
many_to_one: bool = ...
one_to_many: bool = ... # pyright: ignore[reportIncompatibleVariableOverride]
one_to_one: bool = ... # pyright: ignore[reportIncompatibleVariableOverride]
many_to_many: bool = ... # pyright: ignore[reportIncompatibleVariableOverride]
many_to_one: bool = ... # pyright: ignore[reportIncompatibleVariableOverride]
related_model: type[_GT] = ...
opts: Any = ...
def get_forward_related_filter(self, obj: Model) -> dict[str, int | UUID]: ...
Expand All @@ -74,10 +74,18 @@ class RelatedField(FieldCacheMixin, Generic[_ST, _GT], Field[_ST, _GT]):
_M = TypeVar("_M", bound=Model | None)

class ForeignObject(Generic[_M], RelatedField[_M, _M]):
one_to_many: Literal[False] = ...
one_to_one: Literal[False] = ...
many_to_many: Literal[False] = ...
many_to_one: Literal[True] = ...
one_to_many: Literal[ # pyright: ignore[reportIncompatibleVariableOverride]
False
] = ...
one_to_one: Literal[ # pyright: ignore[reportIncompatibleVariableOverride]
False
] = ...
many_to_many: Literal[ # pyright: ignore[reportIncompatibleVariableOverride]
False
] = ...
many_to_one: Literal[ # pyright: ignore[reportIncompatibleVariableOverride]
True
] = ...
related_model: type[_M] = ...
@overload
def __new__(
Expand Down Expand Up @@ -332,10 +340,18 @@ _MN = TypeVar("_MN", bound=Model)
class ManyToManyField(
Generic[_MM, _MN], RelatedField[Sequence[_MN], ManyToManyRelatedManager[_MM, _MN]]
):
one_to_many: Literal[False] = ...
one_to_one: Literal[False] = ...
many_to_many: Literal[True] = ...
many_to_one: Literal[False] = ...
one_to_many: Literal[ # pyright: ignore[reportIncompatibleVariableOverride]
False
] = ...
one_to_one: Literal[ # pyright: ignore[reportIncompatibleVariableOverride]
False
] = ...
many_to_many: Literal[ # pyright: ignore[reportIncompatibleVariableOverride]
True
] = ...
many_to_one: Literal[ # pyright: ignore[reportIncompatibleVariableOverride]
False
] = ...
rel_class: Any = ...
description: Any = ...
has_null_arg: Any = ...
Expand Down
6 changes: 3 additions & 3 deletions django-stubs/db/models/fields/related_descriptors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ForwardManyToOneDescriptor:

class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor):
RelatedObjectDoesNotExist: type[ObjectDoesNotExist]
field: OneToOneField[Any]
field: OneToOneField[Any] # pyright: ignore[reportIncompatibleVariableOverride]
def get_object(self, instance: Model) -> Model: ...

class ReverseOneToOneDescriptor:
Expand Down Expand Up @@ -64,8 +64,8 @@ class ReverseManyToOneDescriptor:
def create_reverse_many_to_one_manager(superclass: Any, rel: Any) -> Any: ...

class ManyToManyDescriptor(ReverseManyToOneDescriptor):
field: RelatedField[Any, Any]
rel: ManyToManyRel
field: RelatedField[Any, Any] # pyright: ignore[reportIncompatibleVariableOverride]
rel: ManyToManyRel # pyright: ignore[reportIncompatibleVariableOverride]
reverse: bool = ...
def __init__(self, rel: ManyToManyRel, reverse: bool = ...) -> None: ...
@property
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/http/cookie.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import cookies

SimpleCookie = cookies.SimpleCookie[str]
SimpleCookie = cookies.SimpleCookie

def parse_cookie(cookie: str) -> dict[str, str]: ...
2 changes: 1 addition & 1 deletion django-stubs/http/response.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ResponseHeaders(CaseInsensitiveMapping[str]):
class BadHeaderError(ValueError): ...

class HttpResponseBase:
cookies: SimpleCookie
cookies: SimpleCookie # type: ignore [type-arg]
headers: ResponseHeaders
status_code: int
closed: bool
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/template/context.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class RequestContext(Context):
dicts: list[dict[str, str]]
render_context: RenderContext
template_name: str | None
use_l10n: None
use_tz: None
use_l10n: None # pyright: ignore[reportIncompatibleVariableOverride]
use_tz: None # pyright: ignore[reportIncompatibleVariableOverride]
request: HttpRequest = ...
def __init__(
self,
Expand Down
6 changes: 3 additions & 3 deletions django-stubs/template/response.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ContentNotRenderedError(Exception): ...
class SimpleTemplateResponse(HttpResponse):
content: Any = ...
closed: bool
cookies: SimpleCookie[Any]
cookies: SimpleCookie # type: ignore [type-arg]
status_code: int
rendering_attrs: Any = ...
template_name: list[str] | Template | str = ...
Expand Down Expand Up @@ -47,9 +47,9 @@ class SimpleTemplateResponse(HttpResponse):
class TemplateResponse(SimpleTemplateResponse):
client: Client
closed: bool
context: RequestContext
context: RequestContext # pyright: ignore[reportIncompatibleVariableOverride]
context_data: dict[str, Any] | None
cookies: SimpleCookie[Any]
cookies: SimpleCookie # type: ignore [type-arg]
csrf_cookie_set: bool
json: functools.partial[Any]
redirect_chain: list[tuple[str, int]]
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/test/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ _RequestData = Any | None
class RequestFactory:
json_encoder: type[JSONEncoder]
defaults: dict[str, str]
cookies: SimpleCookie
cookies: SimpleCookie # type: ignore [type-arg]
errors: BytesIO
def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/utils/log.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RequireDebugTrue(logging.Filter):
def filter(self, record: str | LogRecord) -> bool: ...

class ServerFormatter(logging.Formatter):
datefmt: None
datefmt: None # pyright: ignore[reportIncompatibleVariableOverride]
style: Style = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def uses_server_time(self) -> bool: ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/utils/six.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_method_function(meth: types.MethodType) -> types.FunctionType: ...
def get_method_self(meth: types.MethodType) -> object | None: ...
def get_function_closure(
fun: types.FunctionType,
) -> tuple[types._Cell, ...] | None: ...
) -> tuple[types._Cell, ...] | None: ... # pyright: ignore[reportAttributeAccessIssue]
def get_function_code(fun: types.FunctionType) -> types.CodeType: ...
def get_function_defaults(fun: types.FunctionType) -> tuple[Any, ...] | None: ...
def get_function_globals(fun: types.FunctionType) -> dict[str, Any]: ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/views/decorators/csrf.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class _EnsureCsrfToken(CsrfViewMiddleware): ...
def requires_csrf_token(__view: _F) -> _F: ...

class _EnsureCsrfCookie(CsrfViewMiddleware):
get_response: None
get_response: None # pyright: ignore[reportIncompatibleVariableOverride]
def process_view(
self, request: Any, callback: Any, callback_args: Any, callback_kwargs: Any
) -> Any: ...
Expand Down

0 comments on commit 8f2dccb

Please sign in to comment.