Skip to content

Commit b81b1bf

Browse files
authored
Introduce flake8-pyi in pre-commit checks (#1253)
* only allow redirect_chain attribute in response when client sets the follow flag Signed-off-by: Oleg Hoefling <[email protected]> * compat for py3.7 Signed-off-by: Oleg Hoefling <[email protected]> * compat for py3.7, fixed Signed-off-by: Oleg Hoefling <[email protected]> * address review comments, extract follow flag checks in a separate test case Signed-off-by: Oleg Hoefling <[email protected]> * configure flake8-pyi plugin in pre-commit Signed-off-by: Oleg Hoefling <[email protected]> * use pep 604 union types where possible Signed-off-by: Oleg Hoefling <[email protected]> * fix Y015 Signed-off-by: Oleg Hoefling <[email protected]> * use PEP 585 container types where possible, replace obsolete typing types with collections.abc Signed-off-by: Oleg Hoefling <[email protected]> * allow isort to reorder non-top imports Signed-off-by: Oleg Hoefling <[email protected]> * finish PEP 585 changes, use PEP 613 where possible Signed-off-by: Oleg Hoefling <[email protected]> * fix remaining flake8-pyi warnings, silence warnings in question Signed-off-by: Oleg Hoefling <[email protected]> * fix Y023 Signed-off-by: Oleg Hoefling <[email protected]> * fix Y029 Signed-off-by: Oleg Hoefling <[email protected]> Signed-off-by: Oleg Hoefling <[email protected]>
1 parent 1b8c1b5 commit b81b1bf

File tree

489 files changed

+7690
-7698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

489 files changed

+7690
-7698
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ repos:
3333
rev: 5.0.4
3434
hooks:
3535
- id: flake8
36+
additional_dependencies:
37+
- flake8-pyi
38+
types: []
39+
files: ^.*.pyi?$
3640

3741
ci:
3842
autofix_commit_msg: '[pre-commit.ci] auto fixes from pre-commit.com hooks'

django-stubs/apps/config.pyi

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import types
2-
from typing import Dict, Iterator, Optional, Type
2+
from collections.abc import Iterator
33

44
from django.apps.registry import Apps
55
from django.db.models.base import Model
@@ -8,18 +8,18 @@ from django.utils.functional import _StrOrPromise
88
MODELS_MODULE_NAME: str
99

1010
class AppConfig:
11-
name: str = ...
12-
module: Optional[types.ModuleType] = ...
13-
apps: Optional[Apps] = ...
14-
label: str = ...
15-
verbose_name: _StrOrPromise = ...
16-
path: str = ...
17-
models_module: Optional[str] = ...
18-
models: Dict[str, Type[Model]] = ...
19-
def __init__(self, app_name: str, app_module: Optional[types.ModuleType]) -> None: ...
11+
name: str
12+
module: types.ModuleType | None
13+
apps: Apps | None
14+
label: str
15+
verbose_name: _StrOrPromise
16+
path: str
17+
models_module: str | None
18+
models: dict[str, type[Model]]
19+
def __init__(self, app_name: str, app_module: types.ModuleType | None) -> None: ...
2020
@classmethod
2121
def create(cls, entry: str) -> AppConfig: ...
22-
def get_model(self, model_name: str, require_ready: bool = ...) -> Type[Model]: ...
23-
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> Iterator[Type[Model]]: ...
22+
def get_model(self, model_name: str, require_ready: bool = ...) -> type[Model]: ...
23+
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> Iterator[type[Model]]: ...
2424
def import_models(self) -> None: ...
2525
def ready(self) -> None: ...

django-stubs/apps/registry.pyi

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
11
import threading
2-
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
2+
from collections.abc import Callable, Iterable
3+
from typing import Any
34

45
from django.db.models.base import Model
56

67
from .config import AppConfig
78

89
class Apps:
9-
all_models: Dict[str, Dict[str, Type[Model]]] = ...
10-
app_configs: Dict[str, AppConfig] = ...
11-
stored_app_configs: List[Any] = ...
12-
apps_ready: bool = ...
13-
ready_event: threading.Event = ...
14-
loading: bool = ...
15-
_pending_operations: Dict[Tuple[str, str], List]
16-
models_ready: bool = ...
17-
ready: bool = ...
18-
def __init__(self, installed_apps: Optional[Iterable[Union[AppConfig, str]]] = ...) -> None: ...
19-
def populate(self, installed_apps: Iterable[Union[AppConfig, str]] = ...) -> None: ...
10+
all_models: dict[str, dict[str, type[Model]]]
11+
app_configs: dict[str, AppConfig]
12+
stored_app_configs: list[Any]
13+
apps_ready: bool
14+
ready_event: threading.Event
15+
loading: bool
16+
_pending_operations: dict[tuple[str, str], list]
17+
models_ready: bool
18+
ready: bool
19+
def __init__(self, installed_apps: Iterable[AppConfig | str] | None = ...) -> None: ...
20+
def populate(self, installed_apps: Iterable[AppConfig | str] = ...) -> None: ...
2021
def check_apps_ready(self) -> None: ...
2122
def check_models_ready(self) -> None: ...
2223
def get_app_configs(self) -> Iterable[AppConfig]: ...
2324
def get_app_config(self, app_label: str) -> AppConfig: ...
2425
# it's not possible to support it in plugin properly now
25-
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> List[Type[Model]]: ...
26-
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Any]: ...
27-
def register_model(self, app_label: str, model: Type[Model]) -> None: ...
26+
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> list[type[Model]]: ...
27+
def get_model(self, app_label: str, model_name: str | None = ..., require_ready: bool = ...) -> type[Any]: ...
28+
def register_model(self, app_label: str, model: type[Model]) -> None: ...
2829
def is_installed(self, app_name: str) -> bool: ...
29-
def get_containing_app_config(self, object_name: str) -> Optional[AppConfig]: ...
30-
def get_registered_model(self, app_label: str, model_name: str) -> Type[Model]: ...
31-
def get_swappable_settings_name(self, to_string: str) -> Optional[str]: ...
30+
def get_containing_app_config(self, object_name: str) -> AppConfig | None: ...
31+
def get_registered_model(self, app_label: str, model_name: str) -> type[Model]: ...
32+
def get_swappable_settings_name(self, to_string: str) -> str | None: ...
3233
def set_available_apps(self, available: Iterable[str]) -> None: ...
3334
def unset_available_apps(self) -> None: ...
3435
def set_installed_apps(self, installed: Iterable[str]) -> None: ...
3536
def unset_installed_apps(self) -> None: ...
3637
def clear_cache(self) -> None: ...
3738
def lazy_model_operation(self, function: Callable, *model_keys: Any) -> None: ...
38-
def do_pending_operations(self, model: Type[Model]) -> None: ...
39+
def do_pending_operations(self, model: type[Model]) -> None: ...
3940

4041
apps: Apps

django-stubs/conf/__init__.pyi

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
from typing import Any, Optional
1+
from typing import Any
22

3+
from _typeshed import Self
34
from django.utils.functional import LazyObject
45

56
# explicit dependency on standard settings to make it loaded
67
from . import global_settings
78

8-
ENVIRONMENT_VARIABLE: str = ...
9-
PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG: str = ...
10-
DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSG: str = ...
9+
ENVIRONMENT_VARIABLE: str
10+
PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG: str
11+
DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSG: str
1112

1213
# required for plugin to be able to distinguish this specific instance of LazySettings from others
1314
class _DjangoConfLazyObject(LazyObject):
@@ -19,21 +20,21 @@ class LazySettings(_DjangoConfLazyObject):
1920
def configured(self) -> bool: ...
2021
def configure(self, default_settings: Any = ..., **options: Any) -> None: ...
2122

22-
settings: LazySettings = ...
23+
settings: LazySettings
2324

2425
class Settings:
2526
SETTINGS_MODULE: str
2627
def __init__(self, settings_module: str) -> None: ...
2728
def is_overridden(self, setting: str) -> bool: ...
2829

2930
class UserSettingsHolder:
30-
SETTINGS_MODULE: None = ...
31+
SETTINGS_MODULE: None
3132
def __init__(self, default_settings: Any) -> None: ...
3233
def __getattr__(self, name: str) -> Any: ...
3334
def __setattr__(self, name: str, value: Any) -> None: ...
3435
def __delattr__(self, name: str) -> None: ...
3536
def is_overridden(self, setting: str) -> bool: ...
3637

3738
class SettingsReference(str):
38-
def __new__(self, value: Any, setting_name: str) -> SettingsReference: ...
39+
def __new__(self: type[Self], value: Any, setting_name: str) -> Self: ...
3940
def __init__(self, value: str, setting_name: str) -> None: ...

0 commit comments

Comments
 (0)