Skip to content

Commit a365ecc

Browse files
[gunicorn] Add @overload decorators to validate_bool, validate_string, validate_file_exists
1 parent 1d41e83 commit a365ecc

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

stubs/gunicorn/gunicorn/config.pyi

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import argparse
22
from _typeshed import ConvertibleToInt
33
from collections.abc import Callable, Container
44
from ssl import SSLContext, _SSLMethod
5-
from typing import Any, ClassVar, overload
6-
from typing_extensions import TypeAlias, override
5+
from typing import Annotated, Any, ClassVar
6+
from typing_extensions import TypeAlias, overload, override
77

88
from gunicorn.arbiter import Arbiter
99
from gunicorn.glogging import Logger as GLogger
@@ -131,7 +131,7 @@ class Setting(metaclass=SettingMeta):
131131
value: _ConfigValueType
132132
section: ClassVar[str | None]
133133
cli: ClassVar[list[str] | None]
134-
validator: ClassVar[Callable[..., Any] | None] # See `_ValidatorType`
134+
validator: ClassVar[Callable[..., Any] | None] # See `_ValidatorType`
135135
type: ClassVar[argparse._ActionType | None]
136136
meta: ClassVar[str | None]
137137
action: ClassVar[str | None]
@@ -154,15 +154,23 @@ class Setting(metaclass=SettingMeta):
154154
@overload
155155
def validate_bool(val: bool) -> bool: ...
156156
@overload
157-
def validate_bool(val: str | None) -> bool | None: ...
157+
def validate_bool(val: None) -> None: ...
158+
@overload
159+
def validate_bool(val: Annotated[str, "Case-insensitive boolean string ('true'/'false' in any case)"]) -> bool: ...
158160
def validate_dict(val: dict[str, Any]) -> dict[str, Any]: ...
159161
@overload
160162
def validate_pos_int(val: int) -> int: ...
161163
@overload
162164
def validate_pos_int(val: ConvertibleToInt) -> int: ...
163165
def validate_ssl_version(val: _SSLMethod) -> _SSLMethod: ...
164-
def validate_string(val: str | None) -> str | None: ...
165-
def validate_file_exists(val: str | None) -> str | None: ...
166+
@overload
167+
def validate_string(val: str) -> str: ...
168+
@overload
169+
def validate_string(val: None) -> None: ...
170+
@overload
171+
def validate_file_exists(val: str) -> str: ...
172+
@overload
173+
def validate_file_exists(val: None) -> None: ...
166174
@overload
167175
def validate_list_string(val: str) -> list[str]: ...
168176
@overload
@@ -743,7 +751,7 @@ class Paste(Setting):
743751
class OnStarting(Setting):
744752
name: ClassVar[str]
745753
section: ClassVar[str]
746-
validator: ClassVar[_CallableValidatorType]
754+
validator: ClassVar[_CallableValidatorType] = ...
747755
type: ClassVar[Callable[..., Any]]
748756
default: ClassVar[_OnStartingHookType]
749757
desc: ClassVar[str]

0 commit comments

Comments
 (0)