Skip to content

Commit

Permalink
CI: Auto-remove unused imports using Ruff (#1508)
Browse files Browse the repository at this point in the history
* CI: Remove unused imports using Ruff
* Suppress unused import in django-stubs/conf/__init__.pyi
  • Loading branch information
intgr authored Jun 6, 2023
1 parent 6f5fbef commit 5da475c
Show file tree
Hide file tree
Showing 31 changed files with 21 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
rev: v0.0.270
hooks:
- id: ruff
args: ["--fix", "--fixable=I001", "--exit-non-zero-on-fix"]
args: ["--fix", "--exit-non-zero-on-fix"]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/conf/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from django.utils.functional import LazyObject
from typing_extensions import Literal

# explicit dependency on standard settings to make it loaded
from . import global_settings
from . import global_settings # noqa: F401

ENVIRONMENT_VARIABLE: Literal["DJANGO_SETTINGS_MODULE"]
DEFAULT_STORAGE_ALIAS: Literal["default"]
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/contrib/admin/checks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from typing import Any

from django.apps.config import AppConfig
from django.contrib.admin.options import BaseModelAdmin
from django.core.checks.messages import CheckMessage, Error
from django.core.checks.messages import CheckMessage

def check_admin_app(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> list[CheckMessage]: ...
def check_dependencies(**kwargs: Any) -> list[CheckMessage]: ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/contrib/admin/widgets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from django import forms
from django.contrib.admin.sites import AdminSite
from django.core.files.base import File
from django.db.models.fields import _FieldChoices
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToManyRel, ManyToOneRel
from django.db.models.fields.reverse_related import ManyToManyRel, ManyToOneRel
from django.forms.models import ModelChoiceIterator
from django.forms.widgets import _OptAttrs
from django.utils.functional import _StrOrPromise
Expand Down
2 changes: 0 additions & 2 deletions django-stubs/contrib/gis/geos/io.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any

from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.prototypes.io import WKBWriter as WKBWriter # noqa: F401
from django.contrib.gis.geos.prototypes.io import WKTWriter as WKTWriter
Expand Down
2 changes: 0 additions & 2 deletions django-stubs/contrib/gis/utils/ogrinfo.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any

from django.contrib.gis.gdal import DataSource

def ogrinfo(data_source: str | DataSource, num_features: int = ...) -> None: ...
2 changes: 0 additions & 2 deletions django-stubs/contrib/messages/storage/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any

from django.contrib.messages.storage.base import BaseStorage
from django.http.request import HttpRequest

Expand Down
4 changes: 2 additions & 2 deletions django-stubs/contrib/postgres/lookups.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db.models import Lookup, Transform
from django.db.models.lookups import Exact, PostgresOperatorLookup
from django.db.models import Transform
from django.db.models.lookups import PostgresOperatorLookup

from .search import SearchVectorExact

Expand Down
2 changes: 1 addition & 1 deletion django-stubs/contrib/sitemaps/views.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Callable
from typing import TypeVar

from django.contrib.sitemaps import GenericSitemap, Sitemap
from django.contrib.sitemaps import Sitemap
from django.http.request import HttpRequest
from django.template.response import TemplateResponse

Expand Down
1 change: 0 additions & 1 deletion django-stubs/contrib/syndication/views.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Generic, TypeVar

from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Model
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.utils.feedgenerator import Enclosure, SyndicationFeed
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/core/checks/security/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from collections.abc import Sequence
from typing import Any

from django.apps.config import AppConfig
from django.core.checks.messages import CheckMessage, Error, Warning
from django.core.checks.messages import Error, Warning

CROSS_ORIGIN_OPENER_POLICY_VALUES: set[str]
REFERRER_POLICY_VALUES: set[str]
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/core/files/uploadedfile.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import IO, TypeVar
from typing import IO

from _typeshed import Self
from django.core.files.base import File
Expand Down
2 changes: 0 additions & 2 deletions django-stubs/core/paginator.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from collections.abc import Iterable, Iterator, Sequence, Sized
from typing import Generic, Protocol, TypeVar, overload

from django.db.models.base import Model
from django.db.models.query import QuerySet
from typing_extensions import TypeAlias

class UnorderedObjectListWarning(RuntimeWarning): ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/backends/mysql/client.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections.abc import Iterable, Sequence
from collections.abc import Iterable
from typing import Any

from django.db.backends.base.client import BaseDatabaseClient
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/migrations/graph.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Sequence
from typing import Any

from django.db.migrations.migration import Migration, SwappableTuple
from django.db.migrations.migration import Migration
from django.db.migrations.state import ProjectState

RECURSION_DEPTH_WARNING: str
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/models/constraints.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Sequence
from enum import Enum
from typing import Any, TypeVar, overload
from typing import Any, overload

from _typeshed import Self
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/models/deletion.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections.abc import Callable, Collection, Iterable, Iterator, Sequence
from collections.abc import Callable, Iterable, Iterator, Sequence
from typing import Any

from django.db import IntegrityError
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/models/expressions.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from collections.abc import Callable, Iterable, Iterator, Sequence
from decimal import Decimal
from typing import Any, TypeVar
from typing import Any

from _typeshed import Self
from django.db.backends.base.base import BaseDatabaseWrapper
Expand Down
1 change: 0 additions & 1 deletion django-stubs/db/models/fields/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ from django.db.models import Model
from django.db.models.expressions import Col, Combinable
from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.query_utils import Q, RegisterLookupMixin
from django.forms import Field as FormField
from django.forms import Widget
from django.utils.datastructures import DictWrapper
from django.utils.functional import _Getter, _StrOrPromise
Expand Down
3 changes: 1 addition & 2 deletions django-stubs/db/models/fields/related_descriptors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ from typing import Any, Generic, TypeVar
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.base import Model
from django.db.models.fields import Field
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.related import ForeignKey, ManyToManyField, OneToOneField, RelatedField
from django.db.models.fields.related import ForeignKey, RelatedField
from django.db.models.fields.reverse_related import ManyToManyRel, ManyToOneRel, OneToOneRel
from django.db.models.manager import RelatedManager
from django.db.models.query import QuerySet
Expand Down
1 change: 0 additions & 1 deletion django-stubs/db/models/signals.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections.abc import Callable
from typing import Any

from django.apps.registry import Apps
from django.db.models.base import Model
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/db/models/sql/query.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ from typing import Any

from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.utils import CursorWrapper
from django.db.models import Field, FilteredRelation, Model, Q, QuerySet
from django.db.models import Field, FilteredRelation, Model, Q
from django.db.models.expressions import BaseExpression, Combinable, Expression, OrderBy
from django.db.models.lookups import Lookup, Transform
from django.db.models.options import Options
from django.db.models.query_utils import PathInfo, RegisterLookupMixin
from django.db.models.query_utils import PathInfo
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.datastructures import BaseTable, Join
from django.db.models.sql.where import WhereNode
Expand Down
1 change: 0 additions & 1 deletion django-stubs/db/models/sql/subqueries.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ from typing import Any
from django.db.models.base import Model
from django.db.models.expressions import Case
from django.db.models.fields import Field
from django.db.models.query import QuerySet
from django.db.models.sql.query import Query
from django.db.models.sql.where import WhereNode

Expand Down
2 changes: 1 addition & 1 deletion django-stubs/forms/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from django.core.validators import _ValidatorCallable
from django.db.models.fields import _Choice, _ChoiceNamedGroup, _ChoicesCallable, _ErrorMessagesT, _FieldChoices
from django.forms.boundfield import BoundField
from django.forms.forms import BaseForm
from django.forms.widgets import ChoiceWidget, Widget
from django.forms.widgets import Widget
from django.utils.datastructures import _PropertyDescriptor
from django.utils.functional import _StrOrPromise
from typing_extensions import TypeAlias
Expand Down
1 change: 0 additions & 1 deletion django-stubs/template/backends/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ from collections.abc import Iterator, Mapping
from typing import Any, Protocol

from django.http.request import HttpRequest
from django.template import TemplateDoesNotExist
from django.template.base import Context
from django.utils.safestring import SafeString

Expand Down
2 changes: 1 addition & 1 deletion django-stubs/template/context.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Callable, Iterable, Iterator
from contextlib import contextmanager
from types import TracebackType
from typing import Any, TypeVar
from typing import Any

from _typeshed import Self
from django.http.request import HttpRequest
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/utils/asyncio.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Callable
from typing import Any, TypeVar, overload
from typing import TypeVar, overload

_C = TypeVar("_C", bound=Callable)

Expand Down
1 change: 0 additions & 1 deletion django-stubs/utils/text.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ from typing import TypeVar, overload

from django.db.models.base import Model
from django.utils.functional import SimpleLazyObject, _StrOrPromise
from django.utils.safestring import SafeString

_StrOrPromiseT = TypeVar("_StrOrPromiseT", bound=_StrOrPromise)

Expand Down
2 changes: 0 additions & 2 deletions django-stubs/utils/translation/trans_null.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any

from django.http.request import HttpRequest

def gettext(message: str) -> str: ...
Expand Down
1 change: 0 additions & 1 deletion django-stubs/views/debug.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections.abc import Callable, ItemsView, Iterator
from importlib.abc import SourceLoader
from pathlib import Path
from types import TracebackType
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ line-length = 120
target-version = "py38"
select = [
"I", # isort
"F401", # Unused imports
]

[tool.ruff.isort]
Expand Down

0 comments on commit 5da475c

Please sign in to comment.