From 963d50c717282c340fa7d397bdb0402a4e7f9434 Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Wed, 25 Sep 2019 02:20:23 +0300 Subject: [PATCH] add linting stubs with flake8-pyi and check for unused imports (#186) --- .travis.yml | 4 +++ dev-requirements.txt | 3 +- django-stubs/apps/registry.pyi | 6 ++-- django-stubs/contrib/admin/checks.pyi | 2 +- .../admin/templatetags/admin_modify.pyi | 3 +- .../admin/templatetags/admin_static.pyi | 2 +- django-stubs/contrib/admin/views/main.pyi | 6 +++- django-stubs/contrib/auth/decorators.pyi | 4 +-- .../contrib/auth/handlers/modwsgi.pyi | 2 +- .../management/commands/createsuperuser.pyi | 2 +- django-stubs/contrib/auth/mixins.pyi | 2 +- .../contrib/auth/password_validation.pyi | 1 - django-stubs/contrib/contenttypes/checks.pyi | 2 +- django-stubs/contrib/contenttypes/fields.pyi | 10 +++--- django-stubs/contrib/contenttypes/views.pyi | 2 +- django-stubs/contrib/flatpages/views.pyi | 2 -- .../contrib/messages/context_processors.pyi | 2 +- .../contrib/messages/storage/base.pyi | 2 +- django-stubs/contrib/messages/utils.pyi | 2 +- django-stubs/contrib/messages/views.pyi | 2 +- django-stubs/contrib/postgres/indexes.pyi | 5 +-- django-stubs/contrib/staticfiles/checks.pyi | 2 +- django-stubs/contrib/staticfiles/storage.pyi | 1 - .../staticfiles/templatetags/staticfiles.pyi | 2 +- django-stubs/contrib/staticfiles/utils.pyi | 2 +- django-stubs/contrib/staticfiles/views.pyi | 2 +- django-stubs/contrib/syndication/views.pyi | 2 +- django-stubs/core/checks/caches.pyi | 2 +- django-stubs/core/checks/database.pyi | 2 +- django-stubs/core/checks/security/base.pyi | 2 +- django-stubs/core/checks/security/csrf.pyi | 2 +- .../core/checks/security/sessions.pyi | 2 +- django-stubs/core/checks/templates.pyi | 2 +- django-stubs/core/checks/urls.pyi | 2 +- django-stubs/core/files/uploadhandler.pyi | 4 +-- django-stubs/core/management/color.pyi | 2 -- .../core/management/commands/makemessages.pyi | 9 +----- django-stubs/core/paginator.pyi | 2 +- django-stubs/core/servers/basehttp.pyi | 2 +- django-stubs/core/signing.pyi | 6 ++-- django-stubs/core/validators.pyi | 2 +- django-stubs/db/backends/base/client.pyi | 2 +- django-stubs/db/backends/base/features.pyi | 2 +- django-stubs/db/backends/base/operations.pyi | 7 ++-- django-stubs/db/backends/base/validation.pyi | 3 +- django-stubs/db/backends/mysql/client.pyi | 2 +- .../db/backends/postgresql/client.pyi | 2 +- django-stubs/db/backends/sqlite3/base.pyi | 3 +- django-stubs/db/backends/utils.pyi | 2 +- django-stubs/db/migrations/exceptions.pyi | 2 +- django-stubs/db/migrations/graph.pyi | 2 +- django-stubs/db/migrations/migration.pyi | 2 +- django-stubs/db/migrations/utils.pyi | 2 +- django-stubs/db/models/base.pyi | 6 ++-- django-stubs/db/models/fields/files.pyi | 3 +- django-stubs/db/models/fields/related.pyi | 32 +++++-------------- .../db/models/fields/reverse_related.pyi | 4 +-- django-stubs/db/models/lookups.pyi | 6 ++-- django-stubs/db/models/options.pyi | 6 ++-- django-stubs/db/models/query.pyi | 12 +++---- django-stubs/db/models/utils.pyi | 2 +- django-stubs/db/transaction.pyi | 2 +- django-stubs/dispatch/dispatcher.pyi | 5 +-- django-stubs/forms/fields.pyi | 3 +- django-stubs/forms/forms.pyi | 2 +- django-stubs/forms/renderers.pyi | 1 - django-stubs/http/request.pyi | 7 ++-- django-stubs/http/response.pyi | 4 +-- django-stubs/shortcuts.pyi | 3 +- django-stubs/template/backends/utils.pyi | 2 +- django-stubs/template/defaultfilters.pyi | 2 +- django-stubs/template/loader.pyi | 4 +-- django-stubs/template/response.pyi | 1 - django-stubs/test/runner.pyi | 4 +-- django-stubs/test/signals.pyi | 2 +- django-stubs/test/testcases.pyi | 2 +- django-stubs/urls/converters.pyi | 2 +- django-stubs/urls/exceptions.pyi | 7 ++-- django-stubs/utils/_os.pyi | 2 +- django-stubs/utils/crypto.pyi | 2 +- django-stubs/utils/datastructures.pyi | 3 +- django-stubs/utils/duration.pyi | 1 - django-stubs/utils/functional.pyi | 2 +- django-stubs/utils/http.pyi | 2 +- django-stubs/utils/ipv6.pyi | 2 +- django-stubs/utils/lorem_ipsum.pyi | 2 +- django-stubs/utils/module_loading.pyi | 2 +- django-stubs/utils/translation/template.pyi | 2 +- django-stubs/utils/translation/trans_null.pyi | 2 +- flake8-pyi.ini | 12 +++++++ setup.cfg | 8 ----- 91 files changed, 139 insertions(+), 176 deletions(-) create mode 100644 flake8-pyi.ini diff --git a/.travis.yml b/.travis.yml index 64bef9f..aca01d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,10 @@ jobs: python: 3.7 script: 'flake8' + - name: Lint stubs with flake8-pyi and check for unused imports + python: 3.7 + script: 'flake8 --config flake8-pyi.ini' + - name: Lint plugin code with isort python: 3.7 script: 'isort --check --diff' diff --git a/dev-requirements.txt b/dev-requirements.txt index afb5537..5a224c9 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,7 @@ black pytest-mypy-plugins==1.0.3 psycopg2 -flake8 +flake8==3.7.8 +flake8-pyi==19.3.0 isort==4.3.21 -e . diff --git a/django-stubs/apps/registry.pyi b/django-stubs/apps/registry.pyi index 15464f1..382535e 100644 --- a/django-stubs/apps/registry.pyi +++ b/django-stubs/apps/registry.pyi @@ -1,6 +1,6 @@ import threading from collections import OrderedDict -from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable, DefaultDict, Dict +from typing import Any, Callable, DefaultDict, Dict, Iterable, List, Optional, Tuple, Type, Union from django.db.migrations.state import AppConfigStub from django.db.models.base import Model @@ -8,8 +8,8 @@ from django.db.models.base import Model from .config import AppConfig class Apps: - all_models: "Dict[str, OrderedDict[str, Type[Model]]]" = ... - app_configs: "OrderedDict[str, AppConfig]" = ... + all_models: Dict[str, OrderedDict[str, Type[Model]]] = ... + app_configs: OrderedDict[str, AppConfig] = ... stored_app_configs: List[Any] = ... apps_ready: bool = ... ready_event: threading.Event = ... diff --git a/django-stubs/contrib/admin/checks.pyi b/django-stubs/contrib/admin/checks.pyi index c43e226..6bb0e36 100644 --- a/django-stubs/contrib/admin/checks.pyi +++ b/django-stubs/contrib/admin/checks.pyi @@ -1,6 +1,6 @@ from typing import Any, List, Union -from django.contrib.admin.options import BaseModelAdmin, InlineModelAdmin, ModelAdmin +from django.contrib.admin.options import BaseModelAdmin from django.core.checks.messages import Error _CheckError = Union[str, Error] diff --git a/django-stubs/contrib/admin/templatetags/admin_modify.pyi b/django-stubs/contrib/admin/templatetags/admin_modify.pyi index 606ae57..67ee4c6 100644 --- a/django-stubs/contrib/admin/templatetags/admin_modify.pyi +++ b/django-stubs/contrib/admin/templatetags/admin_modify.pyi @@ -1,7 +1,6 @@ -from typing import Any, Optional +from typing import Any from django.contrib.admin.helpers import InlineAdminForm -from django.contrib.admin.templatetags.base import InclusionAdminNode from django.template.base import Parser, Token from django.template.context import Context, RequestContext diff --git a/django-stubs/contrib/admin/templatetags/admin_static.pyi b/django-stubs/contrib/admin/templatetags/admin_static.pyi index f2fa188..1dbe942 100644 --- a/django-stubs/contrib/admin/templatetags/admin_static.pyi +++ b/django-stubs/contrib/admin/templatetags/admin_static.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any register: Any diff --git a/django-stubs/contrib/admin/views/main.pyi b/django-stubs/contrib/admin/views/main.pyi index 3893d8e..2c1fd60 100644 --- a/django-stubs/contrib/admin/views/main.pyi +++ b/django-stubs/contrib/admin/views/main.pyi @@ -2,7 +2,11 @@ from collections import OrderedDict from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union from django.contrib.admin.filters import ListFilter, SimpleListFilter -from django.contrib.admin.options import ModelAdmin, IS_POPUP_VAR as IS_POPUP_VAR, TO_FIELD_VAR as TO_FIELD_VAR +from django.contrib.admin.options import ( # noqa: F401 + ModelAdmin, + IS_POPUP_VAR as IS_POPUP_VAR, + TO_FIELD_VAR as TO_FIELD_VAR, +) from django.core.handlers.wsgi import WSGIRequest from django.db.models.base import Model from django.db.models.expressions import Combinable, CombinedExpression, OrderBy diff --git a/django-stubs/contrib/auth/decorators.pyi b/django-stubs/contrib/auth/decorators.pyi index e2cdd0f..954a6f9 100644 --- a/django-stubs/contrib/auth/decorators.pyi +++ b/django-stubs/contrib/auth/decorators.pyi @@ -1,6 +1,6 @@ -from typing import Any, Callable, List, Optional, Set, Union +from typing import Callable, List, Optional, Set, Union -from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME +from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401 def user_passes_test( test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ... diff --git a/django-stubs/contrib/auth/handlers/modwsgi.pyi b/django-stubs/contrib/auth/handlers/modwsgi.pyi index b20dcb8..47be491 100644 --- a/django-stubs/contrib/auth/handlers/modwsgi.pyi +++ b/django-stubs/contrib/auth/handlers/modwsgi.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict UserModel: Any diff --git a/django-stubs/contrib/auth/management/commands/createsuperuser.pyi b/django-stubs/contrib/auth/management/commands/createsuperuser.pyi index 57d205d..efc0752 100644 --- a/django-stubs/contrib/auth/management/commands/createsuperuser.pyi +++ b/django-stubs/contrib/auth/management/commands/createsuperuser.pyi @@ -1,4 +1,4 @@ -import getpass as getpass +import getpass as getpass # noqa: F401 from typing import Any from django.core.management.base import BaseCommand diff --git a/django-stubs/contrib/auth/mixins.pyi b/django-stubs/contrib/auth/mixins.pyi index 6fdc67b..e75f62f 100644 --- a/django-stubs/contrib/auth/mixins.pyi +++ b/django-stubs/contrib/auth/mixins.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional +from typing import Any, Callable, List from django import http from django.http.response import HttpResponse, HttpResponseRedirect diff --git a/django-stubs/contrib/auth/password_validation.pyi b/django-stubs/contrib/auth/password_validation.pyi index 7eb1079..95c07cd 100644 --- a/django-stubs/contrib/auth/password_validation.pyi +++ b/django-stubs/contrib/auth/password_validation.pyi @@ -1,7 +1,6 @@ from pathlib import Path, PosixPath from typing import Any, List, Mapping, Optional, Protocol, Sequence, Set, Union -from django.contrib.auth.base_user import AbstractBaseUser from django.db.models.base import Model _UserModel = Model diff --git a/django-stubs/contrib/contenttypes/checks.pyi b/django-stubs/contrib/contenttypes/checks.pyi index 862ad69..9d1e3e2 100644 --- a/django-stubs/contrib/contenttypes/checks.pyi +++ b/django-stubs/contrib/contenttypes/checks.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List def check_generic_foreign_keys(app_configs: None = ..., **kwargs: Any) -> List[Any]: ... def check_model_name_lengths(app_configs: None = ..., **kwargs: Any) -> List[Any]: ... diff --git a/django-stubs/contrib/contenttypes/fields.pyi b/django-stubs/contrib/contenttypes/fields.pyi index 0eba583..d8586ed 100644 --- a/django-stubs/contrib/contenttypes/fields.pyi +++ b/django-stubs/contrib/contenttypes/fields.pyi @@ -1,19 +1,19 @@ -from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union, Generic +from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union from django.contrib.contenttypes.models import ContentType from django.core.checks.messages import Error from django.db.models.base import Model +from django.db.models.expressions import Combinable +from django.db.models.fields.mixins import FieldCacheMixin from django.db.models.fields.related import ForeignObject from django.db.models.fields.related_descriptors import ReverseManyToOneDescriptor from django.db.models.fields.reverse_related import ForeignObjectRel - -from django.db.models.expressions import Combinable -from django.db.models.fields import Field, PositiveIntegerField -from django.db.models.fields.mixins import FieldCacheMixin from django.db.models.query import QuerySet from django.db.models.query_utils import FilteredRelation, PathInfo from django.db.models.sql.where import WhereNode +from django.db.models.fields import Field, PositiveIntegerField + class GenericForeignKey(FieldCacheMixin): # django-stubs implementation only fields _pyi_private_set_type: Union[Any, Combinable] diff --git a/django-stubs/contrib/contenttypes/views.pyi b/django-stubs/contrib/contenttypes/views.pyi index 5f92c09..05f7041 100644 --- a/django-stubs/contrib/contenttypes/views.pyi +++ b/django-stubs/contrib/contenttypes/views.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Union +from typing import Union from django.http.request import HttpRequest from django.http.response import HttpResponseRedirect diff --git a/django-stubs/contrib/flatpages/views.pyi b/django-stubs/contrib/flatpages/views.pyi index 356a518..1d7e2b8 100644 --- a/django-stubs/contrib/flatpages/views.pyi +++ b/django-stubs/contrib/flatpages/views.pyi @@ -1,5 +1,3 @@ -from typing import Any, Optional - from django.contrib.flatpages.models import FlatPage from django.core.handlers.wsgi import WSGIRequest from django.http.response import HttpResponse diff --git a/django-stubs/contrib/messages/context_processors.pyi b/django-stubs/contrib/messages/context_processors.pyi index 0089552..8652848 100644 --- a/django-stubs/contrib/messages/context_processors.pyi +++ b/django-stubs/contrib/messages/context_processors.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Union from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest diff --git a/django-stubs/contrib/messages/storage/base.pyi b/django-stubs/contrib/messages/storage/base.pyi index 3233e16..d6a7163 100644 --- a/django-stubs/contrib/messages/storage/base.pyi +++ b/django-stubs/contrib/messages/storage/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Union +from typing import Any, List, Optional from django.http.request import HttpRequest from django.http.response import HttpResponseBase diff --git a/django-stubs/contrib/messages/utils.pyi b/django-stubs/contrib/messages/utils.pyi index b17c6a9..1f29b13 100644 --- a/django-stubs/contrib/messages/utils.pyi +++ b/django-stubs/contrib/messages/utils.pyi @@ -1,3 +1,3 @@ -from typing import Dict, Optional +from typing import Dict def get_level_tags() -> Dict[int, str]: ... diff --git a/django-stubs/contrib/messages/views.pyi b/django-stubs/contrib/messages/views.pyi index 8f38ade..344a965 100644 --- a/django-stubs/contrib/messages/views.pyi +++ b/django-stubs/contrib/messages/views.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Dict from django.forms.forms import BaseForm from django.http.response import HttpResponse diff --git a/django-stubs/contrib/postgres/indexes.pyi b/django-stubs/contrib/postgres/indexes.pyi index c8fbcd8..c2410e0 100644 --- a/django-stubs/contrib/postgres/indexes.pyi +++ b/django-stubs/contrib/postgres/indexes.pyi @@ -1,7 +1,8 @@ -from typing import Any, Optional, Sequence +from typing import Optional, Sequence + +from django.db.models.query_utils import Q from django.db.models import Index -from django.db.models.query_utils import Q class PostgresIndex(Index): ... diff --git a/django-stubs/contrib/staticfiles/checks.pyi b/django-stubs/contrib/staticfiles/checks.pyi index 973ac0d..1ca1e96 100644 --- a/django-stubs/contrib/staticfiles/checks.pyi +++ b/django-stubs/contrib/staticfiles/checks.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.core.checks.messages import Error diff --git a/django-stubs/contrib/staticfiles/storage.pyi b/django-stubs/contrib/staticfiles/storage.pyi index 965a29d..da67f2a 100644 --- a/django-stubs/contrib/staticfiles/storage.pyi +++ b/django-stubs/contrib/staticfiles/storage.pyi @@ -4,7 +4,6 @@ from typing import Any, Callable, Iterator, Optional, Tuple from django.core.files.base import File from django.core.files.storage import FileSystemStorage from django.utils.functional import LazyObject -from django.utils.safestring import SafeText class StaticFilesStorage(FileSystemStorage): base_location: Any = ... diff --git a/django-stubs/contrib/staticfiles/templatetags/staticfiles.pyi b/django-stubs/contrib/staticfiles/templatetags/staticfiles.pyi index e02fc77..b2fdda3 100644 --- a/django-stubs/contrib/staticfiles/templatetags/staticfiles.pyi +++ b/django-stubs/contrib/staticfiles/templatetags/staticfiles.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.template.base import Parser, Token from django.templatetags.static import StaticNode diff --git a/django-stubs/contrib/staticfiles/utils.pyi b/django-stubs/contrib/staticfiles/utils.pyi index 727c39c..8d98d5f 100644 --- a/django-stubs/contrib/staticfiles/utils.pyi +++ b/django-stubs/contrib/staticfiles/utils.pyi @@ -1,5 +1,5 @@ from collections import OrderedDict -from typing import Any, Iterator, List, Optional, Tuple, Union +from typing import Iterator, List, Optional, Tuple, Union from django.core.files.storage import FileSystemStorage diff --git a/django-stubs/contrib/staticfiles/views.pyi b/django-stubs/contrib/staticfiles/views.pyi index 491346d..8d1ef04 100644 --- a/django-stubs/contrib/staticfiles/views.pyi +++ b/django-stubs/contrib/staticfiles/views.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.core.handlers.wsgi import WSGIRequest from django.http.response import FileResponse diff --git a/django-stubs/contrib/syndication/views.pyi b/django-stubs/contrib/syndication/views.pyi index d9f41a5..bf2b1b3 100644 --- a/django-stubs/contrib/syndication/views.pyi +++ b/django-stubs/contrib/syndication/views.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List from django.core.exceptions import ObjectDoesNotExist from django.core.handlers.wsgi import WSGIRequest diff --git a/django-stubs/core/checks/caches.pyi b/django-stubs/core/checks/caches.pyi index ddc5c91..25250c4 100644 --- a/django-stubs/core/checks/caches.pyi +++ b/django-stubs/core/checks/caches.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.core.checks.messages import Error diff --git a/django-stubs/core/checks/database.pyi b/django-stubs/core/checks/database.pyi index a3167ff..b4f6b05 100644 --- a/django-stubs/core/checks/database.pyi +++ b/django-stubs/core/checks/database.pyi @@ -1,3 +1,3 @@ -from typing import Any, List, Optional +from typing import Any, List def check_database_backends(*args: Any, **kwargs: Any) -> List[Any]: ... diff --git a/django-stubs/core/checks/security/base.pyi b/django-stubs/core/checks/security/base.pyi index d66c190..0eeba15 100644 --- a/django-stubs/core/checks/security/base.pyi +++ b/django-stubs/core/checks/security/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.core.checks.messages import Warning diff --git a/django-stubs/core/checks/security/csrf.pyi b/django-stubs/core/checks/security/csrf.pyi index b422356..0ea56fb 100644 --- a/django-stubs/core/checks/security/csrf.pyi +++ b/django-stubs/core/checks/security/csrf.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.core.checks.messages import Warning diff --git a/django-stubs/core/checks/security/sessions.pyi b/django-stubs/core/checks/security/sessions.pyi index bd9f8c7..9d6e294 100644 --- a/django-stubs/core/checks/security/sessions.pyi +++ b/django-stubs/core/checks/security/sessions.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.core.checks.messages import Warning diff --git a/django-stubs/core/checks/templates.pyi b/django-stubs/core/checks/templates.pyi index 3884dad..4b35473 100644 --- a/django-stubs/core/checks/templates.pyi +++ b/django-stubs/core/checks/templates.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List from django.core.checks.messages import Error diff --git a/django-stubs/core/checks/urls.pyi b/django-stubs/core/checks/urls.pyi index b432e17..1101a28 100644 --- a/django-stubs/core/checks/urls.pyi +++ b/django-stubs/core/checks/urls.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional, Tuple, Union +from typing import Any, Callable, List, Tuple, Union from django.core.checks.messages import CheckMessage, Error, Warning from django.urls.resolvers import URLPattern, URLResolver diff --git a/django-stubs/core/files/uploadhandler.pyi b/django-stubs/core/files/uploadhandler.pyi index 79df95f..164fe1c 100644 --- a/django-stubs/core/files/uploadhandler.pyi +++ b/django-stubs/core/files/uploadhandler.pyi @@ -8,8 +8,8 @@ from django.utils.datastructures import MultiValueDict class UploadFileException(Exception): ... class StopUpload(UploadFileException): - connection_reset = ... # type: bool - def __init__(self, connection_reset: bool = False) -> None: ... + connection_reset: bool = ... + def __init__(self, connection_reset: bool = ...) -> None: ... class SkipFile(UploadFileException): ... class StopFutureHandlers(UploadFileException): ... diff --git a/django-stubs/core/management/color.pyi b/django-stubs/core/management/color.pyi index c0823b1..0d71350 100644 --- a/django-stubs/core/management/color.pyi +++ b/django-stubs/core/management/color.pyi @@ -1,5 +1,3 @@ -from collections import Callable - def supports_color() -> bool: ... class Style: diff --git a/django-stubs/core/management/commands/makemessages.pyi b/django-stubs/core/management/commands/makemessages.pyi index 9da96a2..8f8e5fd 100644 --- a/django-stubs/core/management/commands/makemessages.pyi +++ b/django-stubs/core/management/commands/makemessages.pyi @@ -1,13 +1,6 @@ -import os -import re -from typing import Any, Pattern, Type, Optional +from typing import Any, Optional, Pattern, Type from django.core.management.base import BaseCommand -from django.utils.functional import cached_property -from django.utils.jslex import prepare_js_for_gettext - -from django.conf import settings -from django.utils.translation import templatize plural_forms_re: Pattern = ... STATUS_OK: int = ... diff --git a/django-stubs/core/paginator.pyi b/django-stubs/core/paginator.pyi index 3238255..3ad4794 100644 --- a/django-stubs/core/paginator.pyi +++ b/django-stubs/core/paginator.pyi @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional, Union, Iterable, Sequence, Protocol, Any +from typing import Dict, List, Optional, Protocol, Sequence, Union from django.db.models.base import Model from django.db.models.query import QuerySet diff --git a/django-stubs/core/servers/basehttp.pyi b/django-stubs/core/servers/basehttp.pyi index 6783cf9..e16d5b8 100644 --- a/django-stubs/core/servers/basehttp.pyi +++ b/django-stubs/core/servers/basehttp.pyi @@ -4,7 +4,7 @@ from typing import Any, Dict from wsgiref import simple_server from django.core.handlers.wsgi import WSGIRequest, WSGIHandler -from django.core.wsgi import get_wsgi_application as get_wsgi_application +from django.core.wsgi import get_wsgi_application as get_wsgi_application # noqa: F401 class WSGIServer(simple_server.WSGIServer): request_queue_size: int = ... diff --git a/django-stubs/core/signing.pyi b/django-stubs/core/signing.pyi index bd061a5..6a838d3 100644 --- a/django-stubs/core/signing.pyi +++ b/django-stubs/core/signing.pyi @@ -1,7 +1,5 @@ -from datetime import datetime, timedelta -from typing import Any, Dict, List, Optional, Type, Union, Protocol - -from django.contrib.sessions.serializers import PickleSerializer +from datetime import timedelta +from typing import Any, Dict, Optional, Protocol, Type, Union class BadSignature(Exception): ... class SignatureExpired(BadSignature): ... diff --git a/django-stubs/core/validators.pyi b/django-stubs/core/validators.pyi index 8dc870e..d540bd1 100644 --- a/django-stubs/core/validators.pyi +++ b/django-stubs/core/validators.pyi @@ -5,7 +5,7 @@ from typing import Any, Dict, List, Optional, Union, Pattern, Collection from uuid import UUID from django.core.files.base import File -from django.core.exceptions import ValidationError as ValidationError +from django.core.exceptions import ValidationError as ValidationError # noqa: F401 EMPTY_VALUES: Any diff --git a/django-stubs/db/backends/base/client.pyi b/django-stubs/db/backends/base/client.pyi index 19930c2..6fdf5ce 100644 --- a/django-stubs/db/backends/base/client.pyi +++ b/django-stubs/db/backends/base/client.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper diff --git a/django-stubs/db/backends/base/features.pyi b/django-stubs/db/backends/base/features.pyi index 7d4e76b..8d24f2a 100644 --- a/django-stubs/db/backends/base/features.pyi +++ b/django-stubs/db/backends/base/features.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper diff --git a/django-stubs/db/backends/base/operations.pyi b/django-stubs/db/backends/base/operations.pyi index cbe0581..a8d5575 100644 --- a/django-stubs/db/backends/base/operations.pyi +++ b/django-stubs/db/backends/base/operations.pyi @@ -1,17 +1,18 @@ from datetime import date, datetime, timedelta from decimal import Decimal -from typing import Any, List, Optional, Set, Tuple, Type, Union, Sequence +from typing import Any, List, Optional, Sequence, Tuple, Type, Union from django.core.management.color import Style -from django.db import DefaultConnectionProxy from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.backends.utils import CursorWrapper from django.db.models.base import Model from django.db.models.expressions import Case, Expression -from django.db.models.fields import Field from django.db.models.sql.compiler import SQLCompiler +from django.db import DefaultConnectionProxy +from django.db.models.fields import Field + class BaseDatabaseOperations: compiler_module: str = ... integer_field_ranges: Any = ... diff --git a/django-stubs/db/backends/base/validation.pyi b/django-stubs/db/backends/base/validation.pyi index d5d1b97..382f4c1 100644 --- a/django-stubs/db/backends/base/validation.pyi +++ b/django-stubs/db/backends/base/validation.pyi @@ -1,6 +1,7 @@ -from typing import Any, List, Optional +from typing import Any, List from django.db.backends.base.base import BaseDatabaseWrapper + from django.db.models.fields import Field class BaseDatabaseValidation: diff --git a/django-stubs/db/backends/mysql/client.pyi b/django-stubs/db/backends/mysql/client.pyi index f4bd38b..212f15d 100644 --- a/django-stubs/db/backends/mysql/client.pyi +++ b/django-stubs/db/backends/mysql/client.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Union +from typing import Dict, List, Optional, Union from django.db.backends.base.client import BaseDatabaseClient diff --git a/django-stubs/db/backends/postgresql/client.pyi b/django-stubs/db/backends/postgresql/client.pyi index 6b741ae..ab8f440 100644 --- a/django-stubs/db/backends/postgresql/client.pyi +++ b/django-stubs/db/backends/postgresql/client.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Dict from django.db.backends.base.client import BaseDatabaseClient diff --git a/django-stubs/db/backends/sqlite3/base.pyi b/django-stubs/db/backends/sqlite3/base.pyi index ce89f84..11535b6 100644 --- a/django-stubs/db/backends/sqlite3/base.pyi +++ b/django-stubs/db/backends/sqlite3/base.pyi @@ -1,6 +1,5 @@ from sqlite3 import dbapi2 as Database -from sqlite3 import dbapi2 as Database -from typing import Any, Callable, Iterator +from typing import Any, Callable from django.db.backends.base.base import BaseDatabaseWrapper diff --git a/django-stubs/db/backends/utils.pyi b/django-stubs/db/backends/utils.pyi index ffbcdfa..a867b51 100644 --- a/django-stubs/db/backends/utils.pyi +++ b/django-stubs/db/backends/utils.pyi @@ -1,7 +1,7 @@ import types from datetime import date, datetime, time from decimal import Decimal -from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple, Union, Type +from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Type, Union from uuid import UUID logger: Any diff --git a/django-stubs/db/migrations/exceptions.pyi b/django-stubs/db/migrations/exceptions.pyi index 4d9ef62..88941ea 100644 --- a/django-stubs/db/migrations/exceptions.pyi +++ b/django-stubs/db/migrations/exceptions.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Tuple +from typing import Optional, Tuple from django.db.migrations.migration import Migration from django.db.utils import DatabaseError diff --git a/django-stubs/db/migrations/graph.pyi b/django-stubs/db/migrations/graph.pyi index 1568eed..acee1f7 100644 --- a/django-stubs/db/migrations/graph.pyi +++ b/django-stubs/db/migrations/graph.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional, Tuple, Union, Set, Dict +from typing import Any, Dict, List, Optional, Set, Tuple, Union from django.db.migrations.migration import Migration, SwappableTuple from django.db.migrations.state import ProjectState diff --git a/django-stubs/db/migrations/migration.pyi b/django-stubs/db/migrations/migration.pyi index 57b20d6..d13f494 100644 --- a/django-stubs/db/migrations/migration.pyi +++ b/django-stubs/db/migrations/migration.pyi @@ -1,4 +1,4 @@ -from typing import Any, Tuple, Type, List +from typing import Any, List, Tuple from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.state import ProjectState diff --git a/django-stubs/db/migrations/utils.pyi b/django-stubs/db/migrations/utils.pyi index 9f372f3..fb98a1e 100644 --- a/django-stubs/db/migrations/utils.pyi +++ b/django-stubs/db/migrations/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Union, Optional, List +from typing import Any COMPILED_REGEX_TYPE: Any diff --git a/django-stubs/db/models/base.pyi b/django-stubs/db/models/base.pyi index 28e627a..19f8aa1 100644 --- a/django-stubs/db/models/base.pyi +++ b/django-stubs/db/models/base.pyi @@ -1,9 +1,7 @@ -from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, TypeVar, Union, ClassVar, Type - -from django.db.models.manager import Manager +from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, TypeVar, Union from django.core.checks.messages import CheckMessage - +from django.db.models.manager import Manager from django.db.models.options import Options _Self = TypeVar("_Self", bound="Model") diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index 311e601..49ec867 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional, Type, Union, Tuple, Iterable, overload, TypeVar +from typing import Any, Callable, Iterable, List, Optional, Tuple, Type, TypeVar, Union, overload from django.core.files.base import File from django.core.files.images import ImageFile @@ -6,7 +6,6 @@ from django.core.files.storage import FileSystemStorage, Storage from django.db.models.base import Model from django.db.models.fields import Field, _FieldChoices, _ValidatorCallable, _ErrorMessagesToOverride -from django.forms import fields as form_fields BLANK_CHOICE_DASH: List[Tuple[str, str]] = ... diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index 3aa70da..3e04894 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -1,43 +1,27 @@ -from typing import ( - Any, - Callable, - Dict, - Iterable, - List, - Optional, - Sequence, - TYPE_CHECKING, - Tuple, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Type, TypeVar, Union, overload from uuid import UUID +from django.db import models +from django.db.models.base import Model +from django.db.models.fields import Field +from django.db.models.query_utils import Q, PathInfo +from django.db.models.manager import RelatedManager from django.db.models.expressions import Combinable from django.db.models.fields.mixins import FieldCacheMixin -from django.db.models.query_utils import PathInfo, Q - -from django.db import models -from django.db.models import Field, Model -from django.db.models.fields.related_descriptors import ( +from django.db.models.fields.related_descriptors import ( # noqa: F401 ForwardOneToOneDescriptor as ForwardOneToOneDescriptor, ForwardManyToOneDescriptor as ForwardManyToOneDescriptor, ManyToManyDescriptor as ManyToManyDescriptor, ReverseOneToOneDescriptor as ReverseOneToOneDescriptor, ReverseManyToOneDescriptor as ReverseManyToOneDescriptor, ) -from django.db.models.fields.reverse_related import ( +from django.db.models.fields.reverse_related import ( # noqa: F401 ForeignObjectRel as ForeignObjectRel, OneToOneRel as OneToOneRel, ManyToOneRel as ManyToOneRel, ManyToManyRel as ManyToManyRel, ) -if TYPE_CHECKING: - from django.db.models.manager import RelatedManager - _T = TypeVar("_T", bound=models.Model) _F = TypeVar("_F", bound=models.Field) _Choice = Tuple[Any, str] diff --git a/django-stubs/db/models/fields/reverse_related.pyi b/django-stubs/db/models/fields/reverse_related.pyi index c220bee..606442e 100644 --- a/django-stubs/db/models/fields/reverse_related.pyi +++ b/django-stubs/db/models/fields/reverse_related.pyi @@ -1,12 +1,12 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union from django.db.models.base import Model -from django.db.models.fields import AutoField, Field from django.db.models.fields.related import ForeignKey, OneToOneField, RelatedField from django.db.models.lookups import BuiltinLookup, StartsWith -from django.db.models.query_utils import FilteredRelation, PathInfo, Q +from django.db.models.query_utils import FilteredRelation, PathInfo from django.db.models.sql.where import WhereNode +from django.db.models.fields import AutoField, Field from .mixins import FieldCacheMixin class ForeignObjectRel(FieldCacheMixin): diff --git a/django-stubs/db/models/lookups.pyi b/django-stubs/db/models/lookups.pyi index 2a7529a..d99a952 100644 --- a/django-stubs/db/models/lookups.pyi +++ b/django-stubs/db/models/lookups.pyi @@ -1,12 +1,10 @@ -from collections import OrderedDict from datetime import datetime -from typing import Any, Dict, Iterable, List, Optional, Tuple, Type, Union, Mapping +from typing import Any, Iterable, List, Mapping, Optional, Tuple, Type, Union from django.db.backends.sqlite3.base import DatabaseWrapper -from django.db.models.expressions import Combinable, Expression, Func +from django.db.models.expressions import Expression, Func from django.db.models.query_utils import RegisterLookupMixin from django.db.models.sql.compiler import SQLCompiler -from django.db.models.sql.query import Query from django.utils.datastructures import OrderedSet from django.utils.safestring import SafeText diff --git a/django-stubs/db/models/options.pyi b/django-stubs/db/models/options.pyi index 49e7488..d6e7d2f 100644 --- a/django-stubs/db/models/options.pyi +++ b/django-stubs/db/models/options.pyi @@ -1,5 +1,5 @@ import collections -from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, TypeVar, Generic, Sequence +from typing import Any, Callable, Dict, Generic, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union from django.apps.config import AppConfig from django.apps.registry import Apps @@ -9,13 +9,13 @@ from django.contrib.postgres.fields.citext import CIText from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.models.base import Model from django.db.models.fields.mixins import FieldCacheMixin -from django.db.models.fields.related import OneToOneField, ManyToManyField +from django.db.models.fields.related import ManyToManyField, OneToOneField from django.db.models.fields.reverse_related import ForeignObjectRel from django.db.models.manager import Manager from django.db.models.query_utils import PathInfo from django.utils.datastructures import ImmutableList -from django.db.models.fields import Field, mixins, AutoField +from django.db.models.fields import AutoField, Field PROXY_PARENTS: Any EMPTY_RELATION_TREE: Any diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index 5166c16..936413d 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -1,7 +1,9 @@ import datetime from typing import ( Any, + Collection, Dict, + Generic, Iterable, Iterator, List, @@ -14,18 +16,15 @@ from typing import ( TypeVar, Union, overload, - Generic, - NamedTuple, - Collection, ) from django.db.models.base import Model -from django.db.models.expressions import Combinable as Combinable, F as F +from django.db.models.expressions import Combinable as Combinable, F as F # noqa: F401 from django.db.models.sql.query import Query, RawQuery from django.db import models from django.db.models import Manager -from django.db.models.query_utils import Q as Q +from django.db.models.query_utils import Q as Q # noqa: F401 _T = TypeVar("_T", bound=models.Model, covariant=True) _QS = TypeVar("_QS", bound="_BaseQuerySet") @@ -43,8 +42,7 @@ class _BaseQuerySet(Generic[_T], Sized): def as_manager(cls) -> Manager[Any]: ... def __len__(self) -> int: ... def __bool__(self) -> bool: ... - def __class_getitem__(cls, item: Type[_T]): - pass + def __class_getitem__(cls, item: Type[_T]): ... def __getstate__(self) -> Dict[str, Any]: ... # Technically, the other QuerySet must be of the same type _T, but _T is covariant def __and__(self: _QS, other: _BaseQuerySet[_T]) -> _QS: ... diff --git a/django-stubs/db/models/utils.pyi b/django-stubs/db/models/utils.pyi index 806d980..a1af698 100644 --- a/django-stubs/db/models/utils.pyi +++ b/django-stubs/db/models/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Tuple, Type, Union +from typing import Tuple, Type, Union from django.db.models.base import Model diff --git a/django-stubs/db/transaction.pyi b/django-stubs/db/transaction.pyi index 755c6d8..7fd05a0 100644 --- a/django-stubs/db/transaction.pyi +++ b/django-stubs/db/transaction.pyi @@ -38,5 +38,5 @@ def atomic(using: _C) -> _C: ... # Decorator or context-manager with parameters @overload -def atomic(using: Optional[str] = ..., savepoint: bool = True) -> Atomic: ... +def atomic(using: Optional[str] = ..., savepoint: bool = ...) -> Atomic: ... def non_atomic_requests(using: Callable = ...) -> Callable: ... diff --git a/django-stubs/dispatch/dispatcher.pyi b/django-stubs/dispatch/dispatcher.pyi index 5058459..8ae53ce 100644 --- a/django-stubs/dispatch/dispatcher.pyi +++ b/django-stubs/dispatch/dispatcher.pyi @@ -1,7 +1,4 @@ -from typing import Any, Callable, List, Optional, Tuple, Type, Union - -from django.apps.config import AppConfig -from django.db.models.base import Model +from typing import Any, Callable, List, Optional, Tuple, Union NONE_ID: Any NO_RECEIVERS: Any diff --git a/django-stubs/forms/fields.pyi b/django-stubs/forms/fields.pyi index 06aefa9..fc73fa9 100644 --- a/django-stubs/forms/fields.pyi +++ b/django-stubs/forms/fields.pyi @@ -1,6 +1,5 @@ from datetime import datetime, timedelta -from decimal import Decimal -from typing import Any, Callable, List, Optional, Pattern, Sequence, Type, Union, Tuple, Iterable +from typing import Any, Callable, Iterable, List, Optional, Pattern, Sequence, Tuple, Type, Union from django.core.validators import BaseValidator from django.forms.boundfield import BoundField diff --git a/django-stubs/forms/forms.pyi b/django-stubs/forms/forms.pyi index afd6c2d..24cab6e 100644 --- a/django-stubs/forms/forms.pyi +++ b/django-stubs/forms/forms.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Type, Union, Tuple +from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Type, Union from django.core.exceptions import ValidationError as ValidationError from django.forms.boundfield import BoundField diff --git a/django-stubs/forms/renderers.pyi b/django-stubs/forms/renderers.pyi index 89749f9..ffdf34f 100644 --- a/django-stubs/forms/renderers.pyi +++ b/django-stubs/forms/renderers.pyi @@ -1,7 +1,6 @@ from typing import Any, Dict from django.template.backends.base import BaseEngine -from django.template.engine import Engine from django.template import Template diff --git a/django-stubs/http/request.pyi b/django-stubs/http/request.pyi index eae05c3..8f8a7aa 100644 --- a/django-stubs/http/request.pyi +++ b/django-stubs/http/request.pyi @@ -10,17 +10,16 @@ from typing import ( Pattern, Set, Tuple, + Type, + TypeVar, Union, overload, - TypeVar, - Type, ) +from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.sessions.backends.base import SessionBase -from django.db.models.base import Model from django.utils.datastructures import CaseInsensitiveMapping, ImmutableList, MultiValueDict -from django.contrib.auth.base_user import AbstractBaseUser from django.core.files import uploadedfile, uploadhandler from django.urls import ResolverMatch diff --git a/django-stubs/http/response.pyi b/django-stubs/http/response.pyi index edd26dc..1804fed 100644 --- a/django-stubs/http/response.pyi +++ b/django-stubs/http/response.pyi @@ -48,8 +48,8 @@ class HttpResponseBase(Iterable[Any]): samesite: str = ..., ) -> None: ... def setdefault(self, key: str, value: str) -> None: ... - def set_signed_cookie(self, key: str, value: str, salt: str = "", **kwargs: Any) -> None: ... - def delete_cookie(self, key: str, path: str = "", domain: Optional[str] = ...) -> None: ... + def set_signed_cookie(self, key: str, value: str, salt: str = ..., **kwargs: Any) -> None: ... + def delete_cookie(self, key: str, path: str = ..., domain: Optional[str] = ...) -> None: ... def make_bytes(self, value: object) -> bytes: ... def close(self) -> None: ... def write(self, content: Union[str, bytes]) -> None: ... diff --git a/django-stubs/shortcuts.pyi b/django-stubs/shortcuts.pyi index 7cd19a9..c9c49be 100644 --- a/django-stubs/shortcuts.pyi +++ b/django-stubs/shortcuts.pyi @@ -22,8 +22,7 @@ def render( using: Optional[str] = ..., ) -> HttpResponse: ... -class SupportsGetAbsoluteUrl(Protocol): - pass +class SupportsGetAbsoluteUrl(Protocol): ... def redirect( to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: bool = ..., **kwargs: Any diff --git a/django-stubs/template/backends/utils.pyi b/django-stubs/template/backends/utils.pyi index c6240f6..c715278 100644 --- a/django-stubs/template/backends/utils.pyi +++ b/django-stubs/template/backends/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.http.request import HttpRequest from django.utils.safestring import SafeText diff --git a/django-stubs/template/defaultfilters.pyi b/django-stubs/template/defaultfilters.pyi index d4cbabb..a66e1de 100644 --- a/django-stubs/template/defaultfilters.pyi +++ b/django-stubs/template/defaultfilters.pyi @@ -2,7 +2,7 @@ from datetime import date as _date, datetime, time as _time from typing import Any, Callable, Dict, List, Optional, Union from django.utils.safestring import SafeText -from django.utils.html import escape as escape +from django.utils.html import escape as escape # noqa: F401 register: Any diff --git a/django-stubs/template/loader.pyi b/django-stubs/template/loader.pyi index b79861d..0cd3214 100644 --- a/django-stubs/template/loader.pyi +++ b/django-stubs/template/loader.pyi @@ -1,8 +1,8 @@ from typing import Any, Dict, List, Optional, Union -from . import engines as engines +from . import engines as engines # noqa: F401 from django.http.request import HttpRequest -from django.template.exceptions import TemplateDoesNotExist as TemplateDoesNotExist +from django.template.exceptions import TemplateDoesNotExist as TemplateDoesNotExist # noqa: F401 def get_template(template_name: str, using: Optional[str] = ...) -> Any: ... def select_template(template_name_list: Union[List[str], str], using: Optional[str] = ...) -> Any: ... diff --git a/django-stubs/template/response.pyi b/django-stubs/template/response.pyi index 69aee5d..9974c24 100644 --- a/django-stubs/template/response.pyi +++ b/django-stubs/template/response.pyi @@ -7,7 +7,6 @@ from django.http.request import HttpRequest from django.template.base import Template from django.template.context import RequestContext from django.test.client import Client -from django.utils.functional import SimpleLazyObject from django.http import HttpResponse diff --git a/django-stubs/test/runner.pyi b/django-stubs/test/runner.pyi index 98a18bd..2d6042a 100644 --- a/django-stubs/test/runner.pyi +++ b/django-stubs/test/runner.pyi @@ -1,8 +1,8 @@ import logging from argparse import ArgumentParser from io import StringIO -from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union, Sequence -from unittest import TestCase, TextTestResult, TestSuite +from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Type +from unittest import TestCase, TestSuite, TextTestResult from django.db.backends.base.base import BaseDatabaseWrapper from django.test.testcases import SimpleTestCase, TestCase diff --git a/django-stubs/test/signals.pyi b/django-stubs/test/signals.pyi index 885f318..72c02df 100644 --- a/django-stubs/test/signals.pyi +++ b/django-stubs/test/signals.pyi @@ -1,5 +1,5 @@ from typing import Any -from django.core.signals import setting_changed as setting_changed +from django.core.signals import setting_changed as setting_changed # noqa: F401 template_rendered: Any COMPLEX_OVERRIDE_SETTINGS: Any diff --git a/django-stubs/test/testcases.pyi b/django-stubs/test/testcases.pyi index 8769a95..73ae5b5 100644 --- a/django-stubs/test/testcases.pyi +++ b/django-stubs/test/testcases.pyi @@ -15,7 +15,7 @@ from django.template.base import Template from django.test.client import Client from django.test.utils import CaptureQueriesContext, ContextList from django.utils.safestring import SafeText -from django.db import connections as connections +from django.db import connections as connections # noqa: F401 class _AssertNumQueriesContext(CaptureQueriesContext): test_case: SimpleTestCase = ... diff --git a/django-stubs/urls/converters.pyi b/django-stubs/urls/converters.pyi index cf09f0b..fd5d6e1 100644 --- a/django-stubs/urls/converters.pyi +++ b/django-stubs/urls/converters.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Type, Union, Protocol +from typing import Any, Dict, Type, Union from uuid import UUID class IntConverter: diff --git a/django-stubs/urls/exceptions.pyi b/django-stubs/urls/exceptions.pyi index 7856f54..f3ad4c6 100644 --- a/django-stubs/urls/exceptions.pyi +++ b/django-stubs/urls/exceptions.pyi @@ -1,7 +1,4 @@ from django.http import Http404 -class Resolver404(Http404): - pass - -class NoReverseMatch(Exception): - pass +class Resolver404(Http404): ... +class NoReverseMatch(Exception): ... diff --git a/django-stubs/utils/_os.pyi b/django-stubs/utils/_os.pyi index 1cf9d58..725f65a 100644 --- a/django-stubs/utils/_os.pyi +++ b/django-stubs/utils/_os.pyi @@ -1,5 +1,5 @@ from os.path import abspath -from typing import Any, Optional, Union +from typing import Any, Union abspathu = abspath diff --git a/django-stubs/utils/crypto.pyi b/django-stubs/utils/crypto.pyi index f73cb4a..9b41ab7 100644 --- a/django-stubs/utils/crypto.pyi +++ b/django-stubs/utils/crypto.pyi @@ -1,5 +1,5 @@ from hmac import HMAC -from typing import Any, Callable, Optional, Union +from typing import Callable, Optional, Union using_sysrandom: bool diff --git a/django-stubs/utils/datastructures.pyi b/django-stubs/utils/datastructures.pyi index 738ee88..e9778cf 100644 --- a/django-stubs/utils/datastructures.pyi +++ b/django-stubs/utils/datastructures.pyi @@ -71,5 +71,4 @@ class CaseInsensitiveMapping(Mapping): def __getitem__(self, key: str) -> Any: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[str]: ... - def copy(self: _T) -> _T: - return self + def copy(self: _T) -> _T: ... diff --git a/django-stubs/utils/duration.pyi b/django-stubs/utils/duration.pyi index e2617ba..4d49555 100644 --- a/django-stubs/utils/duration.pyi +++ b/django-stubs/utils/duration.pyi @@ -1,5 +1,4 @@ from datetime import timedelta -from typing import Any, Optional def duration_string(duration: timedelta) -> str: ... def duration_iso_string(duration: timedelta) -> str: ... diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index d5695fd..d70f30e 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -1,5 +1,5 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union -from functools import wraps as wraps +from functools import wraps as wraps # noqa: F401 from django.db.models.base import Model diff --git a/django-stubs/utils/http.pyi b/django-stubs/utils/http.pyi index 7a96588..39b2059 100644 --- a/django-stubs/utils/http.pyi +++ b/django-stubs/utils/http.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Set, Tuple, Union, Iterable +from typing import Any, Iterable, List, Optional, Tuple, Union ETAG_MATCH: Any MONTHS: Any diff --git a/django-stubs/utils/ipv6.pyi b/django-stubs/utils/ipv6.pyi index 8f6d7c9..e3669c5 100644 --- a/django-stubs/utils/ipv6.pyi +++ b/django-stubs/utils/ipv6.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any def clean_ipv6_address(ip_str: Any, unpack_ipv4: bool = ..., error_message: Any = ...): ... def is_valid_ipv6_address(ip_str: str) -> bool: ... diff --git a/django-stubs/utils/lorem_ipsum.pyi b/django-stubs/utils/lorem_ipsum.pyi index 6904ac9..1f9d9b3 100644 --- a/django-stubs/utils/lorem_ipsum.pyi +++ b/django-stubs/utils/lorem_ipsum.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List COMMON_P: str WORDS: Any diff --git a/django-stubs/utils/module_loading.pyi b/django-stubs/utils/module_loading.pyi index 92fbece..2a2138d 100644 --- a/django-stubs/utils/module_loading.pyi +++ b/django-stubs/utils/module_loading.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any def import_string(dotted_path: str) -> Any: ... def autodiscover_modules(*args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/utils/translation/template.pyi b/django-stubs/utils/translation/template.pyi index 61f4ee3..90588a4 100644 --- a/django-stubs/utils/translation/template.pyi +++ b/django-stubs/utils/translation/template.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any dot_re: Any diff --git a/django-stubs/utils/translation/trans_null.pyi b/django-stubs/utils/translation/trans_null.pyi index 105812d..3d8418f 100644 --- a/django-stubs/utils/translation/trans_null.pyi +++ b/django-stubs/utils/translation/trans_null.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any def gettext(message: Any): ... diff --git a/flake8-pyi.ini b/flake8-pyi.ini new file mode 100644 index 0000000..568f91c --- /dev/null +++ b/flake8-pyi.ini @@ -0,0 +1,12 @@ +[flake8] +filename = + *.pyi +exclude = + django-sources + test-data + mypy_django_plugin + scripts +select = F401, Y +max_line_length = 120 +per-file-ignores = + *__init__.pyi: F401 diff --git a/setup.cfg b/setup.cfg index 0eb7616..5e7cd6d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,14 +14,6 @@ exclude = django-stubs test-data max_line_length = 120 -per-file-ignores = - # E301: expected 1 blank line - # E302: expected 2 blank lines - # E305: expected 2 blank lines after class or function definition - # E701: multiple statements on one line (colon) - # E743: ambiguous function definition 'X' - # F821: undefined name 'X' - *.pyi: E301, E302, E305, E701, E743, F821 [metadata] license_file = LICENSE.txt