From e5171a07db94f5ff07199e8bf94597a6f5684275 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 14:48:00 +0300 Subject: [PATCH 001/102] [gunicorn] Initial commit: create_baseline_stubs --- pyrightconfig.stricter.json | 1 + stubs/gunicorn/gunicorn/__init__.pyi | 6 + stubs/gunicorn/gunicorn/app/__init__.pyi | 0 stubs/gunicorn/gunicorn/app/base.pyi | 26 + stubs/gunicorn/gunicorn/app/pasterapp.pyi | 3 + stubs/gunicorn/gunicorn/app/wsgiapp.pyi | 13 + stubs/gunicorn/gunicorn/arbiter.pyi | 57 ++ stubs/gunicorn/gunicorn/config.pyi | 934 ++++++++++++++++++ stubs/gunicorn/gunicorn/debug.pyi | 12 + stubs/gunicorn/gunicorn/errors.pyi | 9 + stubs/gunicorn/gunicorn/glogging.pyi | 42 + stubs/gunicorn/gunicorn/http/__init__.pyi | 4 + stubs/gunicorn/gunicorn/http/body.pyi | 38 + stubs/gunicorn/gunicorn/http/errors.pyi | 72 ++ stubs/gunicorn/gunicorn/http/message.pyi | 53 + stubs/gunicorn/gunicorn/http/parser.pyi | 18 + stubs/gunicorn/gunicorn/http/unreader.pyi | 19 + stubs/gunicorn/gunicorn/http/wsgi.pyi | 51 + .../gunicorn/gunicorn/instrument/__init__.pyi | 0 stubs/gunicorn/gunicorn/instrument/statsd.pyi | 28 + stubs/gunicorn/gunicorn/pidfile.pyi | 10 + stubs/gunicorn/gunicorn/reloader.pyi | 27 + stubs/gunicorn/gunicorn/sock.pyi | 29 + stubs/gunicorn/gunicorn/systemd.pyi | 4 + stubs/gunicorn/gunicorn/util.pyi | 39 + stubs/gunicorn/gunicorn/workers/__init__.pyi | 3 + stubs/gunicorn/gunicorn/workers/base.pyi | 34 + .../gunicorn/gunicorn/workers/base_async.pyi | 14 + stubs/gunicorn/gunicorn/workers/geventlet.pyi | 18 + stubs/gunicorn/gunicorn/workers/ggevent.pyi | 36 + stubs/gunicorn/gunicorn/workers/gthread.pyi | 40 + stubs/gunicorn/gunicorn/workers/gtornado.pyi | 20 + stubs/gunicorn/gunicorn/workers/sync.pyi | 14 + stubs/gunicorn/gunicorn/workers/workertmp.pyi | 11 + 34 files changed, 1685 insertions(+) create mode 100644 stubs/gunicorn/gunicorn/__init__.pyi create mode 100644 stubs/gunicorn/gunicorn/app/__init__.pyi create mode 100644 stubs/gunicorn/gunicorn/app/base.pyi create mode 100644 stubs/gunicorn/gunicorn/app/pasterapp.pyi create mode 100644 stubs/gunicorn/gunicorn/app/wsgiapp.pyi create mode 100644 stubs/gunicorn/gunicorn/arbiter.pyi create mode 100644 stubs/gunicorn/gunicorn/config.pyi create mode 100644 stubs/gunicorn/gunicorn/debug.pyi create mode 100644 stubs/gunicorn/gunicorn/errors.pyi create mode 100644 stubs/gunicorn/gunicorn/glogging.pyi create mode 100644 stubs/gunicorn/gunicorn/http/__init__.pyi create mode 100644 stubs/gunicorn/gunicorn/http/body.pyi create mode 100644 stubs/gunicorn/gunicorn/http/errors.pyi create mode 100644 stubs/gunicorn/gunicorn/http/message.pyi create mode 100644 stubs/gunicorn/gunicorn/http/parser.pyi create mode 100644 stubs/gunicorn/gunicorn/http/unreader.pyi create mode 100644 stubs/gunicorn/gunicorn/http/wsgi.pyi create mode 100644 stubs/gunicorn/gunicorn/instrument/__init__.pyi create mode 100644 stubs/gunicorn/gunicorn/instrument/statsd.pyi create mode 100644 stubs/gunicorn/gunicorn/pidfile.pyi create mode 100644 stubs/gunicorn/gunicorn/reloader.pyi create mode 100644 stubs/gunicorn/gunicorn/sock.pyi create mode 100644 stubs/gunicorn/gunicorn/systemd.pyi create mode 100644 stubs/gunicorn/gunicorn/util.pyi create mode 100644 stubs/gunicorn/gunicorn/workers/__init__.pyi create mode 100644 stubs/gunicorn/gunicorn/workers/base.pyi create mode 100644 stubs/gunicorn/gunicorn/workers/base_async.pyi create mode 100644 stubs/gunicorn/gunicorn/workers/geventlet.pyi create mode 100644 stubs/gunicorn/gunicorn/workers/ggevent.pyi create mode 100644 stubs/gunicorn/gunicorn/workers/gthread.pyi create mode 100644 stubs/gunicorn/gunicorn/workers/gtornado.pyi create mode 100644 stubs/gunicorn/gunicorn/workers/sync.pyi create mode 100644 stubs/gunicorn/gunicorn/workers/workertmp.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 99c3312723cc..416af935762d 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -44,6 +44,7 @@ "stubs/grpcio-reflection/grpc_reflection/v1alpha", "stubs/grpcio-status/grpc_status", "stubs/grpcio/grpc/__init__.pyi", + "stubs/gunicorn", "stubs/hdbcli/hdbcli/dbapi.pyi", "stubs/html5lib", "stubs/httplib2", diff --git a/stubs/gunicorn/gunicorn/__init__.pyi b/stubs/gunicorn/gunicorn/__init__.pyi new file mode 100644 index 000000000000..234233d984f3 --- /dev/null +++ b/stubs/gunicorn/gunicorn/__init__.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +version_info: Incomplete +__version__: Incomplete +SERVER: str +SERVER_SOFTWARE: Incomplete diff --git a/stubs/gunicorn/gunicorn/app/__init__.pyi b/stubs/gunicorn/gunicorn/app/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/gunicorn/gunicorn/app/base.pyi b/stubs/gunicorn/gunicorn/app/base.pyi new file mode 100644 index 000000000000..51618342e8da --- /dev/null +++ b/stubs/gunicorn/gunicorn/app/base.pyi @@ -0,0 +1,26 @@ +from _typeshed import Incomplete + +class BaseApplication: + usage: Incomplete + cfg: Incomplete + callable: Incomplete + prog: Incomplete + logger: Incomplete + def __init__(self, usage=None, prog=None) -> None: ... + def do_load_config(self) -> None: ... + def load_default_config(self) -> None: ... + def init(self, parser, opts, args) -> None: ... + def load(self) -> None: ... + def load_config(self) -> None: ... + def reload(self) -> None: ... + def wsgi(self): ... + def run(self) -> None: ... + +class Application(BaseApplication): + def chdir(self) -> None: ... + def get_config_from_filename(self, filename): ... + def get_config_from_module_name(self, module_name): ... + def load_config_from_module_name_or_filename(self, location): ... + def load_config_from_file(self, filename): ... + def load_config(self) -> None: ... + def run(self) -> None: ... diff --git a/stubs/gunicorn/gunicorn/app/pasterapp.pyi b/stubs/gunicorn/gunicorn/app/pasterapp.pyi new file mode 100644 index 000000000000..d0a2876277e1 --- /dev/null +++ b/stubs/gunicorn/gunicorn/app/pasterapp.pyi @@ -0,0 +1,3 @@ +def get_wsgi_app(config_uri, name=None, defaults=None): ... +def has_logging_config(config_file): ... +def serve(app, global_conf, **local_conf): ... diff --git a/stubs/gunicorn/gunicorn/app/wsgiapp.pyi b/stubs/gunicorn/gunicorn/app/wsgiapp.pyi new file mode 100644 index 000000000000..9d8b7a06f9e2 --- /dev/null +++ b/stubs/gunicorn/gunicorn/app/wsgiapp.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete + +from gunicorn.app.base import Application + +class WSGIApplication(Application): + app_uri: Incomplete + def init(self, parser, opts, args) -> None: ... + def load_config(self) -> None: ... + def load_wsgiapp(self): ... + def load_pasteapp(self): ... + def load(self): ... + +def run(prog=None) -> None: ... diff --git a/stubs/gunicorn/gunicorn/arbiter.pyi b/stubs/gunicorn/gunicorn/arbiter.pyi new file mode 100644 index 000000000000..a263d7344dec --- /dev/null +++ b/stubs/gunicorn/gunicorn/arbiter.pyi @@ -0,0 +1,57 @@ +from _typeshed import Incomplete + +class Arbiter: + WORKER_BOOT_ERROR: int + APP_LOAD_ERROR: int + START_CTX: Incomplete + LISTENERS: Incomplete + WORKERS: Incomplete + PIPE: Incomplete + SIG_QUEUE: Incomplete + SIGNALS: Incomplete + SIG_NAMES: Incomplete + log: Incomplete + pidfile: Incomplete + systemd: bool + worker_age: int + reexec_pid: int + master_pid: int + master_name: str + def __init__(self, app) -> None: ... + num_workers: Incomplete + app: Incomplete + cfg: Incomplete + worker_class: Incomplete + address: Incomplete + timeout: Incomplete + proc_name: Incomplete + def setup(self, app): ... + pid: Incomplete + def start(self) -> None: ... + def init_signals(self) -> None: ... + def signal(self, sig, frame) -> None: ... + def run(self) -> None: ... + def handle_chld(self, sig, frame) -> None: ... + def handle_hup(self) -> None: ... + def handle_term(self) -> None: ... + def handle_int(self) -> None: ... + def handle_quit(self) -> None: ... + def handle_ttin(self) -> None: ... + def handle_ttou(self) -> None: ... + def handle_usr1(self) -> None: ... + def handle_usr2(self) -> None: ... + def handle_winch(self) -> None: ... + def maybe_promote_master(self) -> None: ... + def wakeup(self) -> None: ... + def halt(self, reason=None, exit_status: int = 0) -> None: ... + def sleep(self) -> None: ... + def stop(self, graceful: bool = True) -> None: ... + def reexec(self) -> None: ... + def reload(self) -> None: ... + def murder_workers(self) -> None: ... + def reap_workers(self) -> None: ... + def manage_workers(self): ... + def spawn_worker(self): ... + def spawn_workers(self) -> None: ... + def kill_workers(self, sig) -> None: ... + def kill_worker(self, pid, sig) -> None: ... diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi new file mode 100644 index 000000000000..bafb2f2df2cf --- /dev/null +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -0,0 +1,934 @@ +from _typeshed import Incomplete + +KNOWN_SETTINGS: Incomplete +PLATFORM: Incomplete + +def make_settings(ignore=None): ... +def auto_int(_, x): ... + +class Config: + settings: Incomplete + usage: Incomplete + prog: Incomplete + env_orig: Incomplete + def __init__(self, usage=None, prog=None) -> None: ... + def __getattr__(self, name): ... + def __setattr__(self, name, value) -> None: ... + def set(self, name, value) -> None: ... + def get_cmd_args_from_env(self): ... + def parser(self): ... + @property + def worker_class_str(self): ... + @property + def worker_class(self): ... + @property + def address(self): ... + @property + def uid(self): ... + @property + def gid(self): ... + @property + def proc_name(self): ... + @property + def logger_class(self): ... + @property + def is_ssl(self): ... + @property + def ssl_options(self): ... + @property + def env(self): ... + @property + def sendfile(self): ... + @property + def reuse_port(self): ... + @property + def paste_global_conf(self): ... + +class SettingMeta(type): + def __new__(cls, name, bases, attrs): ... + def fmt_desc(cls, desc) -> None: ... + +class Setting: + name: Incomplete + value: Incomplete + section: Incomplete + cli: Incomplete + validator: Incomplete + type: Incomplete + meta: Incomplete + action: Incomplete + default: Incomplete + short: Incomplete + desc: Incomplete + nargs: Incomplete + const: Incomplete + def __init__(self) -> None: ... + def add_option(self, parser) -> None: ... + def copy(self): ... + def get(self): ... + def set(self, val) -> None: ... + def __lt__(self, other): ... + __cmp__ = __lt__ + +def validate_bool(val): ... +def validate_dict(val): ... +def validate_pos_int(val): ... +def validate_ssl_version(val): ... +def validate_string(val): ... +def validate_file_exists(val): ... +def validate_list_string(val): ... +def validate_list_of_existing_files(val): ... +def validate_string_to_addr_list(val): ... +def validate_string_to_list(val): ... +def validate_class(val): ... +def validate_callable(arity): ... +def validate_user(val): ... +def validate_group(val): ... +def validate_post_request(val): ... +def validate_chdir(val): ... +def validate_statsd_address(val): ... +def validate_reload_engine(val): ... +def get_default_config_file(): ... + +class ConfigFile(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: str + desc: str + +class WSGIApp(Setting): + name: str + section: str + meta: str + validator = validate_string + default: Incomplete + desc: str + +class Bind(Setting): + name: str + action: str + section: str + cli: Incomplete + meta: str + validator = validate_list_string + default: Incomplete + desc: str + +class Backlog(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class Workers(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: Incomplete + desc: str + +class WorkerClass(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_class + default: str + desc: str + +class WorkerThreads(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class WorkerConnections(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class MaxRequests(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class MaxRequestsJitter(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class Timeout(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class GracefulTimeout(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class Keepalive(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class LimitRequestLine(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class LimitRequestFields(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class LimitRequestFieldSize(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = int + default: int + desc: str + +class Reload(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class ReloadEngine(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_reload_engine + default: str + desc: str + +class ReloadExtraFiles(Setting): + name: str + action: str + section: str + cli: Incomplete + meta: str + validator = validate_list_of_existing_files + default: Incomplete + desc: str + +class Spew(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class ConfigCheck(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class PrintConfig(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class PreloadApp(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class Sendfile(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + const: bool + desc: str + +class ReusePort(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class Chdir(Setting): + name: str + section: str + cli: Incomplete + validator = validate_chdir + default: Incomplete + default_doc: str + desc: str + +class Daemon(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class Env(Setting): + name: str + action: str + section: str + cli: Incomplete + meta: str + validator = validate_list_string + default: Incomplete + desc: str + +class Pidfile(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class WorkerTmpDir(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class User(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_user + default: Incomplete + default_doc: str + desc: str + +class Group(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_group + default: Incomplete + default_doc: str + desc: str + +class Umask(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_pos_int + type = auto_int + default: int + desc: str + +class Initgroups(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class TmpUploadDir(Setting): + name: str + section: str + meta: str + validator = validate_string + default: Incomplete + desc: str + +class SecureSchemeHeader(Setting): + name: str + section: str + validator = validate_dict + default: Incomplete + desc: str + +class ForwardedAllowIPS(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string_to_addr_list + default: Incomplete + desc: str + +class AccessLog(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class DisableRedirectAccessToSyslog(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class AccessLogFormat(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: str + desc: str + +class ErrorLog(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: str + desc: str + +class Loglevel(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: str + desc: str + +class CaptureOutput(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class LoggerClass(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_class + default: str + desc: str + +class LogConfig(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class LogConfigDict(Setting): + name: str + section: str + validator = validate_dict + default: Incomplete + desc: str + +class LogConfigJson(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class SyslogTo(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: str + desc: str + +class Syslog(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class SyslogPrefix(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class SyslogFacility(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: str + desc: str + +class EnableStdioInheritance(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + default: bool + action: str + desc: str + +class StatsdHost(Setting): + name: str + section: str + cli: Incomplete + meta: str + default: Incomplete + validator = validate_statsd_address + desc: str + +class DogstatsdTags(Setting): + name: str + section: str + cli: Incomplete + meta: str + default: str + validator = validate_string + desc: str + +class StatsdPrefix(Setting): + name: str + section: str + cli: Incomplete + meta: str + default: str + validator = validate_string + desc: str + +class Procname(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class DefaultProcName(Setting): + name: str + section: str + validator = validate_string + default: str + desc: str + +class PythonPath(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class Paste(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class OnStarting(Setting): + name: str + section: str + validator: Incomplete + type = callable + def on_starting(server) -> None: ... + default: Incomplete + desc: str + +class OnReload(Setting): + name: str + section: str + validator: Incomplete + type = callable + def on_reload(server) -> None: ... + default: Incomplete + desc: str + +class WhenReady(Setting): + name: str + section: str + validator: Incomplete + type = callable + def when_ready(server) -> None: ... + default: Incomplete + desc: str + +class Prefork(Setting): + name: str + section: str + validator: Incomplete + type = callable + def pre_fork(server, worker) -> None: ... + default: Incomplete + desc: str + +class Postfork(Setting): + name: str + section: str + validator: Incomplete + type = callable + def post_fork(server, worker) -> None: ... + default: Incomplete + desc: str + +class PostWorkerInit(Setting): + name: str + section: str + validator: Incomplete + type = callable + def post_worker_init(worker) -> None: ... + default: Incomplete + desc: str + +class WorkerInt(Setting): + name: str + section: str + validator: Incomplete + type = callable + def worker_int(worker) -> None: ... + default: Incomplete + desc: str + +class WorkerAbort(Setting): + name: str + section: str + validator: Incomplete + type = callable + def worker_abort(worker) -> None: ... + default: Incomplete + desc: str + +class PreExec(Setting): + name: str + section: str + validator: Incomplete + type = callable + def pre_exec(server) -> None: ... + default: Incomplete + desc: str + +class PreRequest(Setting): + name: str + section: str + validator: Incomplete + type = callable + def pre_request(worker, req) -> None: ... + default: Incomplete + desc: str + +class PostRequest(Setting): + name: str + section: str + validator = validate_post_request + type = callable + def post_request(worker, req, environ, resp) -> None: ... + default: Incomplete + desc: str + +class ChildExit(Setting): + name: str + section: str + validator: Incomplete + type = callable + def child_exit(server, worker) -> None: ... + default: Incomplete + desc: str + +class WorkerExit(Setting): + name: str + section: str + validator: Incomplete + type = callable + def worker_exit(server, worker) -> None: ... + default: Incomplete + desc: str + +class NumWorkersChanged(Setting): + name: str + section: str + validator: Incomplete + type = callable + def nworkers_changed(server, new_value, old_value) -> None: ... + default: Incomplete + desc: str + +class OnExit(Setting): + name: str + section: str + validator: Incomplete + def on_exit(server) -> None: ... + default: Incomplete + desc: str + +class NewSSLContext(Setting): + name: str + section: str + validator: Incomplete + type = callable + def ssl_context(config, default_ssl_context_factory): ... + default: Incomplete + desc: str + +class ProxyProtocol(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + default: bool + action: str + desc: str + +class ProxyAllowFrom(Setting): + name: str + section: str + cli: Incomplete + validator = validate_string_to_addr_list + default: str + desc: str + +class KeyFile(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class CertFile(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class SSLVersion(Setting): + name: str + section: str + cli: Incomplete + validator = validate_ssl_version + default: Incomplete + desc: str + +class CertReqs(Setting): + name: str + section: str + cli: Incomplete + validator = validate_pos_int + default: Incomplete + desc: str + +class CACerts(Setting): + name: str + section: str + cli: Incomplete + meta: str + validator = validate_string + default: Incomplete + desc: str + +class SuppressRaggedEOFs(Setting): + name: str + section: str + cli: Incomplete + action: str + default: bool + validator = validate_bool + desc: str + +class DoHandshakeOnConnect(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class Ciphers(Setting): + name: str + section: str + cli: Incomplete + validator = validate_string + default: Incomplete + desc: str + +class PasteGlobalConf(Setting): + name: str + action: str + section: str + cli: Incomplete + meta: str + validator = validate_list_string + default: Incomplete + desc: str + +class PermitObsoleteFolding(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class StripHeaderSpaces(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class PermitUnconventionalHTTPMethod(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class PermitUnconventionalHTTPVersion(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +class CasefoldHTTPMethod(Setting): + name: str + section: str + cli: Incomplete + validator = validate_bool + action: str + default: bool + desc: str + +def validate_header_map_behaviour(val): ... + +class ForwarderHeaders(Setting): + name: str + section: str + cli: Incomplete + validator = validate_string_to_list + default: str + desc: str + +class HeaderMap(Setting): + name: str + section: str + cli: Incomplete + validator = validate_header_map_behaviour + default: str + desc: str diff --git a/stubs/gunicorn/gunicorn/debug.pyi b/stubs/gunicorn/gunicorn/debug.pyi new file mode 100644 index 000000000000..663c77d93850 --- /dev/null +++ b/stubs/gunicorn/gunicorn/debug.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +__all__ = ["spew", "unspew"] + +class Spew: + trace_names: Incomplete + show_values: Incomplete + def __init__(self, trace_names=None, show_values: bool = True) -> None: ... + def __call__(self, frame, event, arg): ... + +def spew(trace_names=None, show_values: bool = False) -> None: ... +def unspew() -> None: ... diff --git a/stubs/gunicorn/gunicorn/errors.pyi b/stubs/gunicorn/gunicorn/errors.pyi new file mode 100644 index 000000000000..40d585e44b45 --- /dev/null +++ b/stubs/gunicorn/gunicorn/errors.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +class HaltServer(BaseException): + reason: Incomplete + exit_status: Incomplete + def __init__(self, reason, exit_status: int = 1) -> None: ... + +class ConfigError(Exception): ... +class AppImportError(Exception): ... diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi new file mode 100644 index 000000000000..8aca6591dca9 --- /dev/null +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -0,0 +1,42 @@ +from _typeshed import Incomplete + +SYSLOG_FACILITIES: Incomplete +CONFIG_DEFAULTS: Incomplete + +def loggers(): ... + +class SafeAtoms(dict): + def __init__(self, atoms) -> None: ... + def __getitem__(self, k): ... + +def parse_syslog_address(addr): ... + +class Logger: + LOG_LEVELS: Incomplete + loglevel: Incomplete + error_fmt: str + datefmt: str + access_fmt: str + syslog_fmt: str + atoms_wrapper_class = SafeAtoms + error_log: Incomplete + access_log: Incomplete + error_handlers: Incomplete + access_handlers: Incomplete + logfile: Incomplete + lock: Incomplete + cfg: Incomplete + def __init__(self, cfg) -> None: ... + def setup(self, cfg) -> None: ... + def critical(self, msg, *args, **kwargs) -> None: ... + def error(self, msg, *args, **kwargs) -> None: ... + def warning(self, msg, *args, **kwargs) -> None: ... + def info(self, msg, *args, **kwargs) -> None: ... + def debug(self, msg, *args, **kwargs) -> None: ... + def exception(self, msg, *args, **kwargs) -> None: ... + def log(self, lvl, msg, *args, **kwargs) -> None: ... + def atoms(self, resp, req, environ, request_time): ... + def access(self, resp, req, environ, request_time) -> None: ... + def now(self): ... + def reopen_files(self) -> None: ... + def close_on_exec(self) -> None: ... diff --git a/stubs/gunicorn/gunicorn/http/__init__.pyi b/stubs/gunicorn/gunicorn/http/__init__.pyi new file mode 100644 index 000000000000..4fb87e5feebc --- /dev/null +++ b/stubs/gunicorn/gunicorn/http/__init__.pyi @@ -0,0 +1,4 @@ +from gunicorn.http.message import Message as Message, Request as Request +from gunicorn.http.parser import RequestParser as RequestParser + +__all__ = ["Message", "Request", "RequestParser"] diff --git a/stubs/gunicorn/gunicorn/http/body.pyi b/stubs/gunicorn/gunicorn/http/body.pyi new file mode 100644 index 000000000000..be377e01638d --- /dev/null +++ b/stubs/gunicorn/gunicorn/http/body.pyi @@ -0,0 +1,38 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +class ChunkedReader: + req: Incomplete + parser: Incomplete + buf: Incomplete + def __init__(self, req, unreader) -> None: ... + def read(self, size): ... + def parse_trailers(self, unreader, data): ... + def parse_chunked(self, unreader) -> Generator[Incomplete]: ... + def parse_chunk_size(self, unreader, data=None): ... + def get_data(self, unreader, buf) -> None: ... + +class LengthReader: + unreader: Incomplete + length: Incomplete + def __init__(self, unreader, length) -> None: ... + def read(self, size): ... + +class EOFReader: + unreader: Incomplete + buf: Incomplete + finished: bool + def __init__(self, unreader) -> None: ... + def read(self, size): ... + +class Body: + reader: Incomplete + buf: Incomplete + def __init__(self, reader) -> None: ... + def __iter__(self): ... + def __next__(self): ... + next = __next__ + def getsize(self, size): ... + def read(self, size=None): ... + def readline(self, size=None): ... + def readlines(self, size=None): ... diff --git a/stubs/gunicorn/gunicorn/http/errors.pyi b/stubs/gunicorn/gunicorn/http/errors.pyi new file mode 100644 index 000000000000..2530c678292b --- /dev/null +++ b/stubs/gunicorn/gunicorn/http/errors.pyi @@ -0,0 +1,72 @@ +from _typeshed import Incomplete + +class ParseException(Exception): ... + +class NoMoreData(IOError): + buf: Incomplete + def __init__(self, buf=None) -> None: ... + +class ConfigurationProblem(ParseException): + info: Incomplete + code: int + def __init__(self, info) -> None: ... + +class InvalidRequestLine(ParseException): + req: Incomplete + code: int + def __init__(self, req) -> None: ... + +class InvalidRequestMethod(ParseException): + method: Incomplete + def __init__(self, method) -> None: ... + +class InvalidHTTPVersion(ParseException): + version: Incomplete + def __init__(self, version) -> None: ... + +class InvalidHeader(ParseException): + hdr: Incomplete + req: Incomplete + def __init__(self, hdr, req=None) -> None: ... + +class ObsoleteFolding(ParseException): + hdr: Incomplete + def __init__(self, hdr) -> None: ... + +class InvalidHeaderName(ParseException): + hdr: Incomplete + def __init__(self, hdr) -> None: ... + +class UnsupportedTransferCoding(ParseException): + hdr: Incomplete + code: int + def __init__(self, hdr) -> None: ... + +class InvalidChunkSize(IOError): + data: Incomplete + def __init__(self, data) -> None: ... + +class ChunkMissingTerminator(IOError): + term: Incomplete + def __init__(self, term) -> None: ... + +class LimitRequestLine(ParseException): + size: Incomplete + max_size: Incomplete + def __init__(self, size, max_size) -> None: ... + +class LimitRequestHeaders(ParseException): + msg: Incomplete + def __init__(self, msg) -> None: ... + +class InvalidProxyLine(ParseException): + line: Incomplete + code: int + def __init__(self, line) -> None: ... + +class ForbiddenProxyRequest(ParseException): + host: Incomplete + code: int + def __init__(self, host) -> None: ... + +class InvalidSchemeHeaders(ParseException): ... diff --git a/stubs/gunicorn/gunicorn/http/message.pyi b/stubs/gunicorn/gunicorn/http/message.pyi new file mode 100644 index 000000000000..af3d14c1335a --- /dev/null +++ b/stubs/gunicorn/gunicorn/http/message.pyi @@ -0,0 +1,53 @@ +from _typeshed import Incomplete + +MAX_REQUEST_LINE: int +MAX_HEADERS: int +DEFAULT_MAX_HEADERFIELD_SIZE: int +RFC9110_5_6_2_TOKEN_SPECIALS: str +TOKEN_RE: Incomplete +METHOD_BADCHAR_RE: Incomplete +VERSION_RE: Incomplete +RFC9110_5_5_INVALID_AND_DANGEROUS: Incomplete + +class Message: + cfg: Incomplete + unreader: Incomplete + peer_addr: Incomplete + remote_addr: Incomplete + version: Incomplete + headers: Incomplete + trailers: Incomplete + body: Incomplete + scheme: Incomplete + must_close: bool + limit_request_fields: Incomplete + limit_request_field_size: Incomplete + max_buffer_headers: Incomplete + def __init__(self, cfg, unreader, peer_addr) -> None: ... + def force_close(self) -> None: ... + def parse(self, unreader) -> None: ... + def parse_headers(self, data, from_trailer: bool = False): ... + def set_body_reader(self) -> None: ... + def should_close(self): ... + +class Request(Message): + method: Incomplete + uri: Incomplete + path: Incomplete + query: Incomplete + fragment: Incomplete + limit_request_line: Incomplete + req_number: Incomplete + proxy_protocol_info: Incomplete + def __init__(self, cfg, unreader, peer_addr, req_number: int = 1) -> None: ... + def get_data(self, unreader, buf, stop: bool = False) -> None: ... + headers: Incomplete + def parse(self, unreader): ... + def read_line(self, unreader, buf, limit: int = 0): ... + def proxy_protocol(self, line): ... + def proxy_protocol_access_check(self) -> None: ... + def parse_proxy_protocol(self, line) -> None: ... + version: Incomplete + def parse_request_line(self, line_bytes) -> None: ... + body: Incomplete + def set_body_reader(self) -> None: ... diff --git a/stubs/gunicorn/gunicorn/http/parser.pyi b/stubs/gunicorn/gunicorn/http/parser.pyi new file mode 100644 index 000000000000..7e5293d4200a --- /dev/null +++ b/stubs/gunicorn/gunicorn/http/parser.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete + +from gunicorn.http.message import Request + +class Parser: + mesg_class: Incomplete + cfg: Incomplete + unreader: Incomplete + mesg: Incomplete + source_addr: Incomplete + req_count: int + def __init__(self, cfg, source, source_addr) -> None: ... + def __iter__(self): ... + def __next__(self): ... + next = __next__ + +class RequestParser(Parser): + mesg_class = Request diff --git a/stubs/gunicorn/gunicorn/http/unreader.pyi b/stubs/gunicorn/gunicorn/http/unreader.pyi new file mode 100644 index 000000000000..3a3af3b495d0 --- /dev/null +++ b/stubs/gunicorn/gunicorn/http/unreader.pyi @@ -0,0 +1,19 @@ +from _typeshed import Incomplete + +class Unreader: + buf: Incomplete + def __init__(self) -> None: ... + def chunk(self) -> None: ... + def read(self, size=None): ... + def unread(self, data) -> None: ... + +class SocketUnreader(Unreader): + sock: Incomplete + mxchunk: Incomplete + def __init__(self, sock, max_chunk: int = 8192) -> None: ... + def chunk(self): ... + +class IterUnreader(Unreader): + iter: Incomplete + def __init__(self, iterable) -> None: ... + def chunk(self): ... diff --git a/stubs/gunicorn/gunicorn/http/wsgi.pyi b/stubs/gunicorn/gunicorn/http/wsgi.pyi new file mode 100644 index 000000000000..7464a3735bdf --- /dev/null +++ b/stubs/gunicorn/gunicorn/http/wsgi.pyi @@ -0,0 +1,51 @@ +import io +from _typeshed import Incomplete + +BLKSIZE: int +HEADER_VALUE_RE: Incomplete +log: Incomplete + +class FileWrapper: + filelike: Incomplete + blksize: Incomplete + close: Incomplete + def __init__(self, filelike, blksize: int = 8192) -> None: ... + def __getitem__(self, key): ... + +class WSGIErrorsWrapper(io.RawIOBase): + streams: Incomplete + def __init__(self, cfg) -> None: ... + def write(self, data) -> None: ... + +def base_environ(cfg): ... +def default_environ(req, sock, cfg): ... +def proxy_environ(req): ... +def create(req, sock, client, server, cfg): ... + +class Response: + req: Incomplete + sock: Incomplete + version: Incomplete + status: Incomplete + chunked: bool + must_close: bool + headers: Incomplete + headers_sent: bool + response_length: Incomplete + sent: int + upgrade: bool + cfg: Incomplete + def __init__(self, req, sock, cfg) -> None: ... + def force_close(self) -> None: ... + def should_close(self): ... + status_code: Incomplete + def start_response(self, status, headers, exc_info=None): ... + def process_headers(self, headers) -> None: ... + def is_chunked(self): ... + def default_headers(self): ... + def send_headers(self) -> None: ... + def write(self, arg) -> None: ... + def can_sendfile(self): ... + def sendfile(self, respiter): ... + def write_file(self, respiter) -> None: ... + def close(self) -> None: ... diff --git a/stubs/gunicorn/gunicorn/instrument/__init__.pyi b/stubs/gunicorn/gunicorn/instrument/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/gunicorn/gunicorn/instrument/statsd.pyi b/stubs/gunicorn/gunicorn/instrument/statsd.pyi new file mode 100644 index 000000000000..75bebebd055f --- /dev/null +++ b/stubs/gunicorn/gunicorn/instrument/statsd.pyi @@ -0,0 +1,28 @@ +from _typeshed import Incomplete + +from gunicorn.glogging import Logger + +METRIC_VAR: str +VALUE_VAR: str +MTYPE_VAR: str +GAUGE_TYPE: str +COUNTER_TYPE: str +HISTOGRAM_TYPE: str + +class Statsd(Logger): + prefix: Incomplete + sock: Incomplete + dogstatsd_tags: Incomplete + def __init__(self, cfg) -> None: ... + def critical(self, msg, *args, **kwargs) -> None: ... + def error(self, msg, *args, **kwargs) -> None: ... + def warning(self, msg, *args, **kwargs) -> None: ... + def exception(self, msg, *args, **kwargs) -> None: ... + def info(self, msg, *args, **kwargs) -> None: ... + def debug(self, msg, *args, **kwargs) -> None: ... + def log(self, lvl, msg, *args, **kwargs) -> None: ... + def access(self, resp, req, environ, request_time) -> None: ... + def gauge(self, name, value) -> None: ... + def increment(self, name, value, sampling_rate: float = 1.0) -> None: ... + def decrement(self, name, value, sampling_rate: float = 1.0) -> None: ... + def histogram(self, name, value) -> None: ... diff --git a/stubs/gunicorn/gunicorn/pidfile.pyi b/stubs/gunicorn/gunicorn/pidfile.pyi new file mode 100644 index 000000000000..1176f9b4335d --- /dev/null +++ b/stubs/gunicorn/gunicorn/pidfile.pyi @@ -0,0 +1,10 @@ +from _typeshed import Incomplete + +class Pidfile: + fname: Incomplete + pid: Incomplete + def __init__(self, fname) -> None: ... + def create(self, pid) -> None: ... + def rename(self, path) -> None: ... + def unlink(self) -> None: ... + def validate(self): ... diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi new file mode 100644 index 000000000000..7ab754fcfe37 --- /dev/null +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -0,0 +1,27 @@ +import threading +from _typeshed import Incomplete + +COMPILED_EXT_RE: Incomplete + +class Reloader(threading.Thread): + daemon: bool + def __init__(self, extra_files=None, interval: int = 1, callback=None) -> None: ... + def add_extra_file(self, filename) -> None: ... + def get_files(self): ... + def run(self) -> None: ... + +has_inotify: bool + +class InotifyReloader(threading.Thread): + event_mask: Incomplete + daemon: bool + def __init__(self, extra_files=None, callback=None) -> None: ... + def add_extra_file(self, filename) -> None: ... + def get_dirs(self): ... + def run(self) -> None: ... + +class InotifyReloader: + def __init__(self, extra_files=None, callback=None) -> None: ... + +preferred_reloader: Incomplete +reloader_engines: Incomplete diff --git a/stubs/gunicorn/gunicorn/sock.pyi b/stubs/gunicorn/gunicorn/sock.pyi new file mode 100644 index 000000000000..bfda2acdf7ba --- /dev/null +++ b/stubs/gunicorn/gunicorn/sock.pyi @@ -0,0 +1,29 @@ +from _typeshed import Incomplete + +class BaseSocket: + log: Incomplete + conf: Incomplete + cfg_addr: Incomplete + sock: Incomplete + def __init__(self, address, conf, log, fd=None) -> None: ... + def __getattr__(self, name): ... + def set_options(self, sock, bound: bool = False): ... + def bind(self, sock) -> None: ... + def close(self) -> None: ... + +class TCPSocket(BaseSocket): + FAMILY: Incomplete + def set_options(self, sock, bound: bool = False): ... + +class TCP6Socket(TCPSocket): + FAMILY: Incomplete + +class UnixSocket(BaseSocket): + FAMILY: Incomplete + def __init__(self, addr, conf, log, fd=None) -> None: ... + def bind(self, sock) -> None: ... + +def create_sockets(conf, log, fds=None): ... +def close_sockets(listeners, unlink: bool = True) -> None: ... +def ssl_context(conf): ... +def ssl_wrap_socket(sock, conf): ... diff --git a/stubs/gunicorn/gunicorn/systemd.pyi b/stubs/gunicorn/gunicorn/systemd.pyi new file mode 100644 index 000000000000..930244980064 --- /dev/null +++ b/stubs/gunicorn/gunicorn/systemd.pyi @@ -0,0 +1,4 @@ +SD_LISTEN_FDS_START: int + +def listen_fds(unset_environment: bool = True): ... +def sd_notify(state, logger, unset_environment: bool = False) -> None: ... diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi new file mode 100644 index 000000000000..3b840cdd0fe5 --- /dev/null +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -0,0 +1,39 @@ +from _typeshed import Incomplete + +REDIRECT_TO: Incomplete +hop_headers: Incomplete + +def load_entry_point(distribution, group, name): ... +def load_class(uri, default: str = "gunicorn.workers.sync.SyncWorker", section: str = "gunicorn.workers"): ... + +positionals: Incomplete + +def get_arity(f): ... +def get_username(uid): ... +def set_owner_process(uid, gid, initgroups: bool = False) -> None: ... +def chown(path, uid, gid) -> None: ... +def unlink(filename) -> None: ... +def is_ipv6(addr): ... +def parse_address(netloc, default_port: str = "8000"): ... +def close_on_exec(fd) -> None: ... +def set_non_blocking(fd) -> None: ... +def close(sock) -> None: ... +def write_chunk(sock, data) -> None: ... +def write(sock, data, chunked: bool = False): ... +def write_nonblock(sock, data, chunked: bool = False): ... +def write_error(sock, status_int, reason, mesg) -> None: ... +def import_app(module): ... +def getcwd(): ... +def http_date(timestamp=None): ... +def is_hoppish(header): ... +def daemonize(enable_stdio_inheritance: bool = False) -> None: ... +def seed() -> None: ... +def check_is_writable(path) -> None: ... +def to_bytestring(value, encoding: str = "utf8"): ... +def has_fileno(obj): ... +def warn(msg) -> None: ... +def make_fail_app(msg): ... +def split_request_uri(uri): ... +def reraise(tp, value, tb=None) -> None: ... +def bytes_to_str(b): ... +def unquote_to_wsgi_str(string): ... diff --git a/stubs/gunicorn/gunicorn/workers/__init__.pyi b/stubs/gunicorn/gunicorn/workers/__init__.pyi new file mode 100644 index 000000000000..8ad1ff0c044e --- /dev/null +++ b/stubs/gunicorn/gunicorn/workers/__init__.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +SUPPORTED_WORKERS: Incomplete diff --git a/stubs/gunicorn/gunicorn/workers/base.pyi b/stubs/gunicorn/gunicorn/workers/base.pyi new file mode 100644 index 000000000000..6841190b3881 --- /dev/null +++ b/stubs/gunicorn/gunicorn/workers/base.pyi @@ -0,0 +1,34 @@ +from _typeshed import Incomplete + +class Worker: + SIGNALS: Incomplete + PIPE: Incomplete + age: Incomplete + pid: str + ppid: Incomplete + sockets: Incomplete + app: Incomplete + timeout: Incomplete + cfg: Incomplete + booted: bool + aborted: bool + reloader: Incomplete + nr: int + max_requests: Incomplete + alive: bool + log: Incomplete + tmp: Incomplete + def __init__(self, age, ppid, sockets, app, timeout, cfg, log) -> None: ... + def notify(self) -> None: ... + def run(self) -> None: ... + wait_fds: Incomplete + def init_process(self) -> None: ... + wsgi: Incomplete + def load_wsgi(self) -> None: ... + def init_signals(self) -> None: ... + def handle_usr1(self, sig, frame) -> None: ... + def handle_exit(self, sig, frame) -> None: ... + def handle_quit(self, sig, frame) -> None: ... + def handle_abort(self, sig, frame) -> None: ... + def handle_error(self, req, client, addr, exc) -> None: ... + def handle_winch(self, sig, fname) -> None: ... diff --git a/stubs/gunicorn/gunicorn/workers/base_async.pyi b/stubs/gunicorn/gunicorn/workers/base_async.pyi new file mode 100644 index 000000000000..8f0dacbfe609 --- /dev/null +++ b/stubs/gunicorn/gunicorn/workers/base_async.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete + +from gunicorn.workers import base + +ALREADY_HANDLED: Incomplete + +class AsyncWorker(base.Worker): + worker_connections: Incomplete + def __init__(self, *args, **kwargs) -> None: ... + def timeout_ctx(self) -> None: ... + def is_already_handled(self, respiter): ... + def handle(self, listener, client, addr) -> None: ... + alive: bool + def handle_request(self, listener_name, req, sock, addr): ... diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi new file mode 100644 index 000000000000..ece24ff71721 --- /dev/null +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete + +from gunicorn.workers.base_async import AsyncWorker + +EVENTLET_WSGI_LOCAL: Incomplete +EVENTLET_ALREADY_HANDLED: Incomplete + +def patch_sendfile() -> None: ... + +class EventletWorker(AsyncWorker): + def patch(self) -> None: ... + def is_already_handled(self, respiter): ... + def init_process(self) -> None: ... + def handle_quit(self, sig, frame) -> None: ... + def handle_usr1(self, sig, frame) -> None: ... + def timeout_ctx(self): ... + def handle(self, listener, client, addr) -> None: ... + def run(self) -> None: ... diff --git a/stubs/gunicorn/gunicorn/workers/ggevent.pyi b/stubs/gunicorn/gunicorn/workers/ggevent.pyi new file mode 100644 index 000000000000..5b609b0144c3 --- /dev/null +++ b/stubs/gunicorn/gunicorn/workers/ggevent.pyi @@ -0,0 +1,36 @@ +from _typeshed import Incomplete + +from gevent import pywsgi +from gunicorn.workers.base_async import AsyncWorker + +VERSION: Incomplete + +class GeventWorker(AsyncWorker): + server_class: Incomplete + wsgi_handler: Incomplete + sockets: Incomplete + def patch(self) -> None: ... + def notify(self) -> None: ... + def timeout_ctx(self): ... + def run(self) -> None: ... + def handle(self, listener, client, addr) -> None: ... + def handle_request(self, listener_name, req, sock, addr) -> None: ... + def handle_quit(self, sig, frame) -> None: ... + def handle_usr1(self, sig, frame) -> None: ... + def init_process(self) -> None: ... + +class GeventResponse: + status: Incomplete + headers: Incomplete + sent: Incomplete + def __init__(self, status, headers, clength) -> None: ... + +class PyWSGIHandler(pywsgi.WSGIHandler): + def log_request(self) -> None: ... + def get_environ(self): ... + +class PyWSGIServer(pywsgi.WSGIServer): ... + +class GeventPyWSGIWorker(GeventWorker): + server_class = PyWSGIServer + wsgi_handler = PyWSGIHandler diff --git a/stubs/gunicorn/gunicorn/workers/gthread.pyi b/stubs/gunicorn/gunicorn/workers/gthread.pyi new file mode 100644 index 000000000000..3dd7b634b03c --- /dev/null +++ b/stubs/gunicorn/gunicorn/workers/gthread.pyi @@ -0,0 +1,40 @@ +from _typeshed import Incomplete + +from . import base + +class TConn: + cfg: Incomplete + sock: Incomplete + client: Incomplete + server: Incomplete + timeout: Incomplete + parser: Incomplete + initialized: bool + def __init__(self, cfg, sock, client, server) -> None: ... + def init(self) -> None: ... + def set_timeout(self) -> None: ... + def close(self) -> None: ... + +class ThreadWorker(base.Worker): + worker_connections: Incomplete + max_keepalived: Incomplete + tpool: Incomplete + poller: Incomplete + futures: Incomplete + nr_conns: int + def __init__(self, *args, **kwargs) -> None: ... + @classmethod + def check_config(cls, cfg, log) -> None: ... + def init_process(self) -> None: ... + def get_thread_pool(self): ... + alive: bool + def handle_quit(self, sig, frame) -> None: ... + def enqueue_req(self, conn) -> None: ... + def accept(self, server, listener) -> None: ... + def on_client_socket_readable(self, conn, client) -> None: ... + def murder_keepalived(self) -> None: ... + def is_parent_alive(self): ... + def run(self) -> None: ... + def finish_request(self, fs) -> None: ... + def handle(self, conn): ... + def handle_request(self, req, conn): ... diff --git a/stubs/gunicorn/gunicorn/workers/gtornado.pyi b/stubs/gunicorn/gunicorn/workers/gtornado.pyi new file mode 100644 index 000000000000..1f21dae156b8 --- /dev/null +++ b/stubs/gunicorn/gunicorn/workers/gtornado.pyi @@ -0,0 +1,20 @@ +from _typeshed import Incomplete + +from gunicorn.workers.base import Worker + +TORNADO5: Incomplete + +class TornadoWorker(Worker): + @classmethod + def setup(cls) -> None: ... + def handle_exit(self, sig, frame) -> None: ... + alive: bool + def handle_request(self) -> None: ... + def watchdog(self) -> None: ... + server_alive: bool + def heartbeat(self) -> None: ... + def init_process(self) -> None: ... + ioloop: Incomplete + callbacks: Incomplete + server: Incomplete + def run(self) -> None: ... diff --git a/stubs/gunicorn/gunicorn/workers/sync.pyi b/stubs/gunicorn/gunicorn/workers/sync.pyi new file mode 100644 index 000000000000..3e6862e1cb7e --- /dev/null +++ b/stubs/gunicorn/gunicorn/workers/sync.pyi @@ -0,0 +1,14 @@ +from gunicorn.workers import base + +class StopWaiting(Exception): ... + +class SyncWorker(base.Worker): + def accept(self, listener) -> None: ... + def wait(self, timeout): ... + def is_parent_alive(self): ... + def run_for_one(self, timeout) -> None: ... + def run_for_multiple(self, timeout) -> None: ... + def run(self) -> None: ... + def handle(self, listener, client, addr) -> None: ... + alive: bool + def handle_request(self, listener, req, client, addr) -> None: ... diff --git a/stubs/gunicorn/gunicorn/workers/workertmp.pyi b/stubs/gunicorn/gunicorn/workers/workertmp.pyi new file mode 100644 index 000000000000..39e84b7b056b --- /dev/null +++ b/stubs/gunicorn/gunicorn/workers/workertmp.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +PLATFORM: Incomplete +IS_CYGWIN: Incomplete + +class WorkerTmp: + def __init__(self, cfg) -> None: ... + def notify(self) -> None: ... + def last_update(self): ... + def fileno(self): ... + def close(self): ... From abab2e727a09e2aeb5ebd1aa8f491a6698c819cc Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 14:48:08 +0300 Subject: [PATCH 002/102] [gunicorn] Add metadata --- stubs/gunicorn/METADATA.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 stubs/gunicorn/METADATA.toml diff --git a/stubs/gunicorn/METADATA.toml b/stubs/gunicorn/METADATA.toml new file mode 100644 index 000000000000..88053dbbb993 --- /dev/null +++ b/stubs/gunicorn/METADATA.toml @@ -0,0 +1,3 @@ +version = "23.0.*" +upstream_repository = "https://github.com/benoitc/gunicorn" +requires = ["types-gevent"] From 7ec2ee60766bbbbf08265b13f5182383528f4c33 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 14:49:48 +0300 Subject: [PATCH 003/102] [gunicorn] Create _types.pyi file --- stubs/gunicorn/gunicorn/_types.pyi | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 stubs/gunicorn/gunicorn/_types.pyi diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi new file mode 100644 index 000000000000..084706a8efa2 --- /dev/null +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -0,0 +1,11 @@ +from collections.abc import Iterable +from typing import Any, Callable, TypeAlias + +Status: TypeAlias = str +Headers: TypeAlias = list[tuple[str, str]] + +Environ: TypeAlias = dict[str, Any] +StartResponse: TypeAlias = Callable[[Status, Headers], None] +ResponseBody: TypeAlias = Iterable[bytes] + +WSGIApp: TypeAlias = Callable[[Environ, StartResponse], ResponseBody] From 93780f5690c72ca7634e386e78e6a1db744a5ac1 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 14:50:49 +0300 Subject: [PATCH 004/102] [gunicorn] Update stubs for util.pyi --- stubs/gunicorn/gunicorn/util.pyi | 95 +++++++++++++++++++------------- 1 file changed, 58 insertions(+), 37 deletions(-) diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index 3b840cdd0fe5..72038723d85e 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -1,39 +1,60 @@ -from _typeshed import Incomplete - -REDIRECT_TO: Incomplete -hop_headers: Incomplete - -def load_entry_point(distribution, group, name): ... -def load_class(uri, default: str = "gunicorn.workers.sync.SyncWorker", section: str = "gunicorn.workers"): ... - -positionals: Incomplete - -def get_arity(f): ... -def get_username(uid): ... -def set_owner_process(uid, gid, initgroups: bool = False) -> None: ... -def chown(path, uid, gid) -> None: ... -def unlink(filename) -> None: ... -def is_ipv6(addr): ... -def parse_address(netloc, default_port: str = "8000"): ... -def close_on_exec(fd) -> None: ... -def set_non_blocking(fd) -> None: ... -def close(sock) -> None: ... -def write_chunk(sock, data) -> None: ... -def write(sock, data, chunked: bool = False): ... -def write_nonblock(sock, data, chunked: bool = False): ... -def write_error(sock, status_int, reason, mesg) -> None: ... -def import_app(module): ... -def getcwd(): ... -def http_date(timestamp=None): ... -def is_hoppish(header): ... +import types +from _typeshed import FileDescriptorLike, FileDescriptorOrPath, HasFileno, StrOrBytesPath +from inspect import _ParameterKind +from socket import socket +from typing import Any, Callable, Literal, LiteralString, NoReturn +from urllib.parse import SplitResult + +from ._types import WSGIApp + +REDIRECT_TO: str +hop_headers: set[str] + + +def load_entry_point(distribution: str, group: str, name: str) -> Any: ... +def load_class( + uri: str | object, + default: str = "gunicorn.workers.sync.SyncWorker", + section: str = "gunicorn.workers", +) -> Any: ... + + +positionals: tuple[ + Literal[_ParameterKind.POSITIONAL_ONLY], + Literal[_ParameterKind.POSITIONAL_OR_KEYWORD], +] + + +def get_arity(f: Callable[..., Any]) -> int: ... +def get_username(uid: int) -> str: ... +def set_owner_process(uid: int, gid: int, initgroups: bool = False) -> None: ... +def chown(path: FileDescriptorOrPath, uid: int, gid: int) -> None: ... +def unlink(filename: StrOrBytesPath) -> None: ... +def is_ipv6(addr: str) -> bool: ... +def parse_address(netloc: str, default_port: str = "8000") -> str | int | tuple[LiteralString, int]: ... +def close_on_exec(fd: FileDescriptorLike) -> None: ... +def set_non_blocking(fd: FileDescriptorLike) -> None: ... +def close(sock: socket) -> None: ... +def write_chunk(sock: socket, data: bytes) -> None: ... +def write(sock: socket, data: bytes, chunked: bool = False) -> None: ... +def write_nonblock(sock: socket, data: bytes, chunked: bool = False) -> None: ... +def write_error(sock: socket, status_int: int, reason: str, mesg: str) -> None: ... +def import_app(module: str) -> WSGIApp: ... +def getcwd() -> str: ... +def http_date(timestamp: float | None = None) -> str: ... +def is_hoppish(header: str) -> bool: ... def daemonize(enable_stdio_inheritance: bool = False) -> None: ... def seed() -> None: ... -def check_is_writable(path) -> None: ... -def to_bytestring(value, encoding: str = "utf8"): ... -def has_fileno(obj): ... -def warn(msg) -> None: ... -def make_fail_app(msg): ... -def split_request_uri(uri): ... -def reraise(tp, value, tb=None) -> None: ... -def bytes_to_str(b): ... -def unquote_to_wsgi_str(string): ... +def check_is_writable(path: FileDescriptorOrPath) -> None: ... +def to_bytestring(value: str | bytes, encoding: str = "utf8") -> bytes: ... +def has_fileno(obj: HasFileno) -> bool: ... +def warn(msg: str) -> None: ... +def make_fail_app(msg: str) -> WSGIApp: ... +def split_request_uri(uri: str) -> SplitResult: ... +def reraise( + tp: type[BaseException], + value: BaseException | None, + tb: types.TracebackType | None = None, +) -> NoReturn: ... +def bytes_to_str(b: bytes) -> str: ... +def unquote_to_wsgi_str(string: str) -> str: ... From d86324997b2f330fed3cbedb96a3bb4c00d2eafc Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 18:44:28 +0300 Subject: [PATCH 005/102] [gunicorn] Update stubs for systemd.pyi --- stubs/gunicorn/gunicorn/systemd.pyi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/systemd.pyi b/stubs/gunicorn/gunicorn/systemd.pyi index 930244980064..4f2b1dbd4a8b 100644 --- a/stubs/gunicorn/gunicorn/systemd.pyi +++ b/stubs/gunicorn/gunicorn/systemd.pyi @@ -1,4 +1,7 @@ +from logging import Logger + SD_LISTEN_FDS_START: int -def listen_fds(unset_environment: bool = True): ... -def sd_notify(state, logger, unset_environment: bool = False) -> None: ... + +def listen_fds(unset_environment: bool = True) -> int: ... +def sd_notify(state: str, logger: Logger, unset_environment: bool = False) -> None: ... From cf928b2a7798e2bfa32e203532c7e4ae3b10dd3b Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 20:24:06 +0300 Subject: [PATCH 006/102] [gunicorn] Update stubs for sock.pyi --- stubs/gunicorn/gunicorn/sock.pyi | 50 ++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/stubs/gunicorn/gunicorn/sock.pyi b/stubs/gunicorn/gunicorn/sock.pyi index bfda2acdf7ba..5dba2ef144e2 100644 --- a/stubs/gunicorn/gunicorn/sock.pyi +++ b/stubs/gunicorn/gunicorn/sock.pyi @@ -1,29 +1,41 @@ +import socket from _typeshed import Incomplete +from collections.abc import Iterable +from logging import Logger +from ssl import SSLSocket +from typing import Any, ClassVar, Literal, SupportsIndex, override + +from .config import Config + class BaseSocket: - log: Incomplete - conf: Incomplete - cfg_addr: Incomplete - sock: Incomplete - def __init__(self, address, conf, log, fd=None) -> None: ... - def __getattr__(self, name): ... - def set_options(self, sock, bound: bool = False): ... - def bind(self, sock) -> None: ... + def __init__(self, address: str, conf: Config, log: Logger, fd: SupportsIndex | None = None) -> None: ... + def __getattr__(self, name: str) -> Any: ... + def set_options[T: socket.socket](self, sock: T, bound: bool = False) -> T: ... + def bind(self, sock: socket.socket) -> None: ... def close(self) -> None: ... + class TCPSocket(BaseSocket): - FAMILY: Incomplete - def set_options(self, sock, bound: bool = False): ... + FAMILY: ClassVar[Literal[socket.AddressFamily.AF_INET, socket.AddressFamily.AF_INET6]] + + @override + def set_options[T: socket.socket](self, sock: T, bound: bool = False) -> T: ... + class TCP6Socket(TCPSocket): - FAMILY: Incomplete + FAMILY: ClassVar[Literal[socket.AddressFamily.AF_INET6]] + class UnixSocket(BaseSocket): - FAMILY: Incomplete - def __init__(self, addr, conf, log, fd=None) -> None: ... - def bind(self, sock) -> None: ... - -def create_sockets(conf, log, fds=None): ... -def close_sockets(listeners, unlink: bool = True) -> None: ... -def ssl_context(conf): ... -def ssl_wrap_socket(sock, conf): ... + FAMILY: ClassVar[Literal[socket.AddressFamily.AF_UNIX]] + + def __init__(self, addr: str, conf: Config, log: Logger, fd: SupportsIndex | None = None) -> None: ... + @override + def bind(self, sock: socket.socket) -> None: ... + + +def create_sockets(conf: Config, log: Logger, fds: Iterable[SupportsIndex] | None = None) -> list[BaseSocket]: ... +def close_sockets(listeners: Iterable[socket.socket], unlink: bool = True) -> None: ... +def ssl_context(conf: Config) -> Incomplete: ... +def ssl_wrap_socket(sock: socket.socket, conf: Config) -> SSLSocket: ... From 41a6c47f500ffcd34b08acd18f3dd9f1eed0b260 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 20:50:51 +0300 Subject: [PATCH 007/102] [gunicorn] Update stubs for reloader.pyi --- stubs/gunicorn/gunicorn/reloader.pyi | 58 +++++++++++++++++++++------- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index 7ab754fcfe37..ad9ba5a2330a 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -1,27 +1,59 @@ import threading -from _typeshed import Incomplete +from collections.abc import Iterable, Set as AbstractSet +from re import Pattern +from typing import Callable, TypedDict, type_check_only + +try: + from inotify.adapters import Inotify + from inotify.constants import IN_CREATE, IN_DELETE, IN_DELETE_SELF, IN_MODIFY, IN_MOVE_SELF, IN_MOVED_FROM, IN_MOVED_TO +except ImportError: + Inotify = object + +COMPILED_EXT_RE: Pattern[str] -COMPILED_EXT_RE: Incomplete class Reloader(threading.Thread): daemon: bool - def __init__(self, extra_files=None, interval: int = 1, callback=None) -> None: ... - def add_extra_file(self, filename) -> None: ... - def get_files(self): ... + + def __init__( + self, + extra_files: Iterable[str] | None = None, + interval: int = 1, + callback: Callable[[str], None] | None = None, + ) -> None: ... + def add_extra_file(self, filename: str) -> None: ... + def get_files(self) -> list[str]: ... def run(self) -> None: ... + has_inotify: bool +EventMask = int + + class InotifyReloader(threading.Thread): - event_mask: Incomplete + event_mask: EventMask daemon: bool - def __init__(self, extra_files=None, callback=None) -> None: ... - def add_extra_file(self, filename) -> None: ... - def get_dirs(self): ... + + def __init__( + self, + extra_files: Iterable[str] | None = None, + callback: Callable[[str], None] | None = None, + ) -> None: ... + def add_extra_file(self, filename: str) -> None: ... + def get_dirs(self) -> AbstractSet[str]: ... def run(self) -> None: ... -class InotifyReloader: - def __init__(self, extra_files=None, callback=None) -> None: ... -preferred_reloader: Incomplete -reloader_engines: Incomplete +type PreferredReloaderType = type[InotifyReloader | Reloader] + + +@type_check_only +class _ReloadedEngines(TypedDict): + auto: PreferredReloaderType + pool: type[Reloader] + inotify: type[InotifyReloader] + + +preferred_reloader: PreferredReloaderType +reloader_engines: _ReloadedEngines From 1d917a54e6d8dd3cff8530601fa3d3b626faf063 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 20:58:03 +0300 Subject: [PATCH 008/102] [gunicorn] Update stubs for pidfile.pyi --- stubs/gunicorn/gunicorn/pidfile.pyi | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/stubs/gunicorn/gunicorn/pidfile.pyi b/stubs/gunicorn/gunicorn/pidfile.pyi index 1176f9b4335d..b3151df1c05a 100644 --- a/stubs/gunicorn/gunicorn/pidfile.pyi +++ b/stubs/gunicorn/gunicorn/pidfile.pyi @@ -1,10 +1,9 @@ -from _typeshed import Incomplete +from _typeshed import StrOrBytesPath + class Pidfile: - fname: Incomplete - pid: Incomplete - def __init__(self, fname) -> None: ... - def create(self, pid) -> None: ... - def rename(self, path) -> None: ... + def __init__(self, fname: StrOrBytesPath) -> None: ... + def create(self, pid: int) -> None: ... + def rename(self, path: StrOrBytesPath) -> None: ... def unlink(self) -> None: ... - def validate(self): ... + def validate(self) -> None: ... From 4a0e58ac2cba31c26737b4f6bb1bcdd972c7fda9 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 22:30:00 +0300 Subject: [PATCH 009/102] [gunicorn] Update stubs for glogging.pyi --- stubs/gunicorn/gunicorn/glogging.pyi | 170 ++++++++++++++++++++++----- 1 file changed, 140 insertions(+), 30 deletions(-) diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 8aca6591dca9..6920cad3d789 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -1,42 +1,152 @@ -from _typeshed import Incomplete +import logging +import threading +from datetime import timedelta +from socket import SocketKind +from typing import Annotated, Any, Literal, TypedDict, type_check_only -SYSLOG_FACILITIES: Incomplete -CONFIG_DEFAULTS: Incomplete +from gunicorn.http import Request +from gunicorn.http.wsgi import Response -def loggers(): ... +from ._types import Environ +from .config import Config -class SafeAtoms(dict): - def __init__(self, atoms) -> None: ... - def __getitem__(self, k): ... +SYSLOG_FACILITIES: dict[str, int] + + +@type_check_only +class _AtomsDict(TypedDict, total=False): + """ + Dictionary of atoms for log formatting. + Additionally contains dynamic keys in the format '{key}i' (request headers), + '{key}o' (response headers), and '{key}e' (environment variables), all with str values. + """ + + h: str + l: str + u: str + t: str + r: str + s: str + m: str | None + U: str | None + q: str | None + H: str | None + b: str + B: int | None + f: str + a: str + T: int + D: int + M: int + L: str + p: str + + +type _CriticalIntType = Annotated[int, "50"] +type _ErrorIntType = Annotated[int, "40"] +type _WarningIntType = Annotated[int, "30"] +type _InfoIntType = Annotated[int, "20"] +type _DebugIntType = Annotated[int, "10"] + +type _LogLevelIntType = _CriticalIntType | _ErrorIntType | _WarningIntType | _InfoIntType | _DebugIntType +type _LogLevelStrType = Literal["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"] +type _LogLevelType = _LogLevelIntType | _LogLevelStrType + + +@type_check_only +class _RootConfig(TypedDict): + level: str + handlers: list[str] + + +@type_check_only +class _LoggerConfig(TypedDict): + level: _LogLevelStrType + handlers: list[str] + propagate: bool + qualname: str + + +@type_check_only +class _HandlerConfig(TypedDict, total=False): + # class: str [Should be provided!] + formatter: str + stream: str + + +@type_check_only +class _FormatterConfig(TypedDict, total=False): + # class: str [Should be provided!] + format: str + datefmt: str + + +@type_check_only +class _ConfigDefaults(TypedDict): + version: int + disable_existing_loggers: bool + root: _RootConfig + loggers: dict[str, _LoggerConfig] + handlers: dict[str, _HandlerConfig] + formatters: dict[str, _FormatterConfig] + + +CONFIG_DEFAULTS: _ConfigDefaults + + +def loggers() -> list[logging.Logger]: ... + + +class SafeAtoms(dict[str, Any]): + def __init__(self, atoms: dict[str, Any]) -> None: ... + def __getitem__(self, k: str) -> str: ... + + +type _SyslogAddressType = ( + tuple[Literal[SocketKind.SOCK_DGRAM] | None, str] # Unix Socket + | tuple[Literal[SocketKind.SOCK_DGRAM, SocketKind.SOCK_STREAM], tuple[str, int]] # TCP/UDP Socket +) + + +def parse_syslog_address(addr: str) -> _SyslogAddressType: ... + + +@type_check_only +class _LogLevels(TypedDict): + critical: _CriticalIntType + error: _ErrorIntType + warning: _WarningIntType + info: _InfoIntType + debug: _DebugIntType -def parse_syslog_address(addr): ... class Logger: - LOG_LEVELS: Incomplete - loglevel: Incomplete + LOG_LEVELS: _LogLevels + loglevel: _LogLevelIntType error_fmt: str datefmt: str access_fmt: str syslog_fmt: str - atoms_wrapper_class = SafeAtoms - error_log: Incomplete - access_log: Incomplete - error_handlers: Incomplete - access_handlers: Incomplete - logfile: Incomplete - lock: Incomplete - cfg: Incomplete - def __init__(self, cfg) -> None: ... - def setup(self, cfg) -> None: ... - def critical(self, msg, *args, **kwargs) -> None: ... - def error(self, msg, *args, **kwargs) -> None: ... - def warning(self, msg, *args, **kwargs) -> None: ... - def info(self, msg, *args, **kwargs) -> None: ... - def debug(self, msg, *args, **kwargs) -> None: ... - def exception(self, msg, *args, **kwargs) -> None: ... - def log(self, lvl, msg, *args, **kwargs) -> None: ... - def atoms(self, resp, req, environ, request_time): ... - def access(self, resp, req, environ, request_time) -> None: ... - def now(self): ... + atoms_wrapper_class: type[SafeAtoms] + error_log: logging.Logger + access_log: logging.Logger + error_handlers: list[logging.Handler] + access_handlers: list[logging.Handler] + logfile: Any | None + lock: threading.Lock + cfg: Config + + def __init__(self, cfg: Config) -> None: ... + def setup(self, cfg: Config) -> None: ... + def critical(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def error(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def warning(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def info(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def debug(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def exception(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def log(self, lvl: _LogLevelIntType | str, msg: str, *args: Any, **kwargs: Any) -> None: ... + def atoms(self, resp: Response, req: Request, environ: Environ, request_time: timedelta) -> _AtomsDict: ... + def access(self, resp: Response, req: Request, environ: Environ, request_time: timedelta) -> None: ... + def now(self) -> str: ... def reopen_files(self) -> None: ... def close_on_exec(self) -> None: ... From ba4e46db756b35fd0c03a34266dc2d22cfce92de Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 22:40:19 +0300 Subject: [PATCH 010/102] [gunicorn] Update stubs for errors.pyi --- stubs/gunicorn/gunicorn/errors.pyi | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stubs/gunicorn/gunicorn/errors.pyi b/stubs/gunicorn/gunicorn/errors.pyi index 40d585e44b45..07263798b029 100644 --- a/stubs/gunicorn/gunicorn/errors.pyi +++ b/stubs/gunicorn/gunicorn/errors.pyi @@ -1,9 +1,11 @@ -from _typeshed import Incomplete - class HaltServer(BaseException): - reason: Incomplete - exit_status: Incomplete - def __init__(self, reason, exit_status: int = 1) -> None: ... + reason: str + exit_status: int + + def __init__(self, reason: str, exit_status: int = 1) -> None: ... + class ConfigError(Exception): ... + + class AppImportError(Exception): ... From 5e538fba2e1bc8669cf4a1944f3acacb0a25eceb Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 22:53:41 +0300 Subject: [PATCH 011/102] [gunicorn] Update stubs for debug.pyi --- stubs/gunicorn/gunicorn/debug.pyi | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/stubs/gunicorn/gunicorn/debug.pyi b/stubs/gunicorn/gunicorn/debug.pyi index 663c77d93850..48c4a7459bdd 100644 --- a/stubs/gunicorn/gunicorn/debug.pyi +++ b/stubs/gunicorn/gunicorn/debug.pyi @@ -1,12 +1,17 @@ -from _typeshed import Incomplete - __all__ = ["spew", "unspew"] +from collections.abc import Container +from types import FrameType +from typing import Any, Self + + class Spew: - trace_names: Incomplete - show_values: Incomplete - def __init__(self, trace_names=None, show_values: bool = True) -> None: ... - def __call__(self, frame, event, arg): ... + trace_names: Container[str] | None = None + show_values: bool + + def __init__(self, trace_names: Container[str] | None = None, show_values: bool = True) -> None: ... + def __call__(self, frame: FrameType, event: str, arg: Any) -> Self: ... + -def spew(trace_names=None, show_values: bool = False) -> None: ... +def spew(trace_names: Container[str] | None = None, show_values: bool = False) -> None: ... def unspew() -> None: ... From ad1bfe2d36854bb6866c7f1a17ca540ad5bf3c00 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sun, 7 Sep 2025 23:54:30 +0300 Subject: [PATCH 012/102] [gunicorn] Add type alias for parse_address function in util.pyi --- stubs/gunicorn/gunicorn/util.pyi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index 72038723d85e..c76177091e47 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -7,10 +7,14 @@ from urllib.parse import SplitResult from ._types import WSGIApp +type _UnixSocketPathType = str +type _FileDescriptorType = int +type _TcpAddressType = tuple[LiteralString, int] +type _AddressType = _UnixSocketPathType | _FileDescriptorType | _TcpAddressType + REDIRECT_TO: str hop_headers: set[str] - def load_entry_point(distribution: str, group: str, name: str) -> Any: ... def load_class( uri: str | object, @@ -18,20 +22,18 @@ def load_class( section: str = "gunicorn.workers", ) -> Any: ... - positionals: tuple[ Literal[_ParameterKind.POSITIONAL_ONLY], Literal[_ParameterKind.POSITIONAL_OR_KEYWORD], ] - def get_arity(f: Callable[..., Any]) -> int: ... def get_username(uid: int) -> str: ... def set_owner_process(uid: int, gid: int, initgroups: bool = False) -> None: ... def chown(path: FileDescriptorOrPath, uid: int, gid: int) -> None: ... def unlink(filename: StrOrBytesPath) -> None: ... def is_ipv6(addr: str) -> bool: ... -def parse_address(netloc: str, default_port: str = "8000") -> str | int | tuple[LiteralString, int]: ... +def parse_address(netloc: str, default_port: str = "8000") -> _AddressType: ... def close_on_exec(fd: FileDescriptorLike) -> None: ... def set_non_blocking(fd: FileDescriptorLike) -> None: ... def close(sock: socket) -> None: ... From 7224967270da970c3d54feb9d846a6cd0c5cd545 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Mon, 8 Sep 2025 00:01:35 +0300 Subject: [PATCH 013/102] [gunicorn] Add type construct (py3.12) instead TypeAlias --- stubs/gunicorn/gunicorn/_types.pyi | 14 +++++++------- stubs/gunicorn/gunicorn/glogging.pyi | 6 +++--- stubs/gunicorn/gunicorn/util.pyi | 9 ++++++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index 084706a8efa2..e244c7b5eb49 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -1,11 +1,11 @@ from collections.abc import Iterable -from typing import Any, Callable, TypeAlias +from typing import Any, Callable -Status: TypeAlias = str -Headers: TypeAlias = list[tuple[str, str]] +type _StatusType = str +type _HeadersType = list[tuple[str, str]] -Environ: TypeAlias = dict[str, Any] -StartResponse: TypeAlias = Callable[[Status, Headers], None] -ResponseBody: TypeAlias = Iterable[bytes] +type _EnvironType = dict[str, Any] +type _StartResponseType = Callable[[_StatusType, _HeadersType], None] +type _ResponseBodyType = Iterable[bytes] -WSGIApp: TypeAlias = Callable[[Environ, StartResponse], ResponseBody] +type _WSGIAppType = Callable[[_EnvironType, _StartResponseType], _ResponseBodyType] diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 6920cad3d789..638df653531d 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -7,7 +7,7 @@ from typing import Annotated, Any, Literal, TypedDict, type_check_only from gunicorn.http import Request from gunicorn.http.wsgi import Response -from ._types import Environ +from ._types import _EnvironType from .config import Config SYSLOG_FACILITIES: dict[str, int] @@ -145,8 +145,8 @@ class Logger: def debug(self, msg: str, *args: Any, **kwargs: Any) -> None: ... def exception(self, msg: str, *args: Any, **kwargs: Any) -> None: ... def log(self, lvl: _LogLevelIntType | str, msg: str, *args: Any, **kwargs: Any) -> None: ... - def atoms(self, resp: Response, req: Request, environ: Environ, request_time: timedelta) -> _AtomsDict: ... - def access(self, resp: Response, req: Request, environ: Environ, request_time: timedelta) -> None: ... + def atoms(self, resp: Response, req: Request, environ: _EnvironType, request_time: timedelta) -> _AtomsDict: ... + def access(self, resp: Response, req: Request, environ: _EnvironType, request_time: timedelta) -> None: ... def now(self) -> str: ... def reopen_files(self) -> None: ... def close_on_exec(self) -> None: ... diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index c76177091e47..7174b451f23e 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -5,7 +5,7 @@ from socket import socket from typing import Any, Callable, Literal, LiteralString, NoReturn from urllib.parse import SplitResult -from ._types import WSGIApp +from ._types import _WSGIAppType type _UnixSocketPathType = str type _FileDescriptorType = int @@ -15,6 +15,7 @@ type _AddressType = _UnixSocketPathType | _FileDescriptorType | _TcpAddressType REDIRECT_TO: str hop_headers: set[str] + def load_entry_point(distribution: str, group: str, name: str) -> Any: ... def load_class( uri: str | object, @@ -22,11 +23,13 @@ def load_class( section: str = "gunicorn.workers", ) -> Any: ... + positionals: tuple[ Literal[_ParameterKind.POSITIONAL_ONLY], Literal[_ParameterKind.POSITIONAL_OR_KEYWORD], ] + def get_arity(f: Callable[..., Any]) -> int: ... def get_username(uid: int) -> str: ... def set_owner_process(uid: int, gid: int, initgroups: bool = False) -> None: ... @@ -41,7 +44,7 @@ def write_chunk(sock: socket, data: bytes) -> None: ... def write(sock: socket, data: bytes, chunked: bool = False) -> None: ... def write_nonblock(sock: socket, data: bytes, chunked: bool = False) -> None: ... def write_error(sock: socket, status_int: int, reason: str, mesg: str) -> None: ... -def import_app(module: str) -> WSGIApp: ... +def import_app(module: str) -> _WSGIAppType: ... def getcwd() -> str: ... def http_date(timestamp: float | None = None) -> str: ... def is_hoppish(header: str) -> bool: ... @@ -51,7 +54,7 @@ def check_is_writable(path: FileDescriptorOrPath) -> None: ... def to_bytestring(value: str | bytes, encoding: str = "utf8") -> bytes: ... def has_fileno(obj: HasFileno) -> bool: ... def warn(msg: str) -> None: ... -def make_fail_app(msg: str) -> WSGIApp: ... +def make_fail_app(msg: str) -> _WSGIAppType: ... def split_request_uri(uri: str) -> SplitResult: ... def reraise( tp: type[BaseException], From a4d62942203ecd212961ed7f5213ef06efbacc76 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 00:51:39 +0300 Subject: [PATCH 014/102] [gunicorn] Update stubs for config.pyi --- stubs/gunicorn/gunicorn/config.pyi | 832 ++++++++++++++++++----------- 1 file changed, 507 insertions(+), 325 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index bafb2f2df2cf..704a3be8c0fc 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -1,934 +1,1116 @@ -from _typeshed import Incomplete +import argparse +from _typeshed import ConvertibleToInt +from collections.abc import Container +from ssl import SSLContext, _SSLMethod +from typing import Any, Callable, Type, overload + +from gunicorn.arbiter import Arbiter +from gunicorn.http import Request +from gunicorn.http.wsgi import Response +from gunicorn.workers.base import Worker + +from ._types import _EnvironType +from .util import _AddressType + +type _OnStartingHookType = Callable[[Arbiter], None] +type _OnReloadHookType = Callable[[Arbiter], None] +type _WhenReadyHookType = Callable[[Arbiter], None] +type _PreForkHookType = Callable[[Arbiter, Worker], None] +type _PostForkHookType = Callable[[Arbiter, Worker], None] +type _PostWorkerInitHookType = Callable[[Worker], None] +type _WorkerIntHookType = Callable[[Worker], None] +type _WorkerAbortHookType = Callable[[Worker], None] +type _PreExecHookType = Callable[[Arbiter], None] +type _PreRequestHookType = Callable[[Worker, Request], None] +type _PostRequestHookType = Callable[[Worker, Request, _EnvironType, Response], None] +type _ChildExitHookType = Callable[[Arbiter, Worker], None] +type _WorkerExitHookType = Callable[[Arbiter, Worker], None] +type _NumWorkersChangedHookType = Callable[[Arbiter, int, int | None], None] +type _OnExitHookType = Callable[[Arbiter], None] +type _SSLContextHookType = Callable[[Config, Callable[[], SSLContext]], SSLContext] + +type _BoolValidatorType = Callable[[bool | str | None], bool | None] +type _StringValidatorType = Callable[[str | None], str | None] +type _ListStringValidatorType = Callable[[str | list[str] | None], list[str]] +type _IntValidatorType = Callable[[int | ConvertibleToInt], int] +type _DictValidatorType = Callable[[dict[str, Any]], dict[str, Any]] +type _ClassValidatorType = Callable[[object | str | None], Type[Any] | None] +type _UserGroupValidatorType = Callable[[str | int | None], int] +type _AddressValidatorType = Callable[[str | None], _AddressType | None] + +KNOWN_SETTINGS: list[Setting] +PLATFORM: str + + +def make_settings(ignore: Container[Setting] | None = None) -> dict[str, Setting]: ... +def auto_int(_: Any, x: str) -> int: ... -KNOWN_SETTINGS: Incomplete -PLATFORM: Incomplete - -def make_settings(ignore=None): ... -def auto_int(_, x): ... class Config: - settings: Incomplete - usage: Incomplete - prog: Incomplete - env_orig: Incomplete - def __init__(self, usage=None, prog=None) -> None: ... - def __getattr__(self, name): ... - def __setattr__(self, name, value) -> None: ... - def set(self, name, value) -> None: ... - def get_cmd_args_from_env(self): ... - def parser(self): ... + settings: dict[str, Setting] + usage: str | None + prog: str | None + env_orig: dict[str, str] + + def __init__(self, usage: str | None = None, prog: str | None = None) -> None: ... + def __getattr__(self, name: str) -> Any: ... + def __setattr__(self, name: str, value: Any) -> None: ... + def set(self, name: str, value: Any) -> None: ... + def get_cmd_args_from_env(self) -> list[str]: ... + def parser(self) -> argparse.ArgumentParser: ... @property - def worker_class_str(self): ... + def worker_class_str(self) -> str: ... @property - def worker_class(self): ... + def worker_class(self) -> Type[Any]: ... @property - def address(self): ... + def address(self) -> list[_AddressType]: ... @property - def uid(self): ... + def uid(self) -> int: ... @property - def gid(self): ... + def gid(self) -> int: ... @property - def proc_name(self): ... + def proc_name(self) -> str | None: ... @property - def logger_class(self): ... + def logger_class(self) -> Type[Any]: ... @property - def is_ssl(self): ... + def is_ssl(self) -> bool: ... @property - def ssl_options(self): ... + def ssl_options(self) -> dict[str, Any]: ... @property - def env(self): ... + def env(self) -> dict[str, str]: ... @property - def sendfile(self): ... + def sendfile(self) -> bool: ... @property - def reuse_port(self): ... + def reuse_port(self) -> bool: ... @property - def paste_global_conf(self): ... + def paste_global_conf(self) -> dict[str, str] | None: ... + class SettingMeta(type): - def __new__(cls, name, bases, attrs): ... - def fmt_desc(cls, desc) -> None: ... - -class Setting: - name: Incomplete - value: Incomplete - section: Incomplete - cli: Incomplete - validator: Incomplete - type: Incomplete - meta: Incomplete - action: Incomplete - default: Incomplete - short: Incomplete - desc: Incomplete - nargs: Incomplete - const: Incomplete + def __new__(cls, name: str, bases: tuple[type, ...], attrs: dict[str, Any]) -> type: ... + def fmt_desc(cls, desc: str) -> None: ... + + +class Setting(metaclass=SettingMeta): + name: str | None + value: Any + section: str | None + cli: list[str] | None + validator: Callable[..., Any] | None + type: Type[Any] | Callable[..., Any] | None + meta: str | None + action: str | None + default: Any + short: str | None + desc: str | None + nargs: int | str | None + const: bool | None + order: int + def __init__(self) -> None: ... - def add_option(self, parser) -> None: ... - def copy(self): ... - def get(self): ... - def set(self, val) -> None: ... - def __lt__(self, other): ... + def add_option(self, parser: argparse.ArgumentParser) -> None: ... + def copy(self) -> Setting: ... + def get(self) -> Any: ... + def set(self, val: Any) -> None: ... + def __lt__(self, other: Setting) -> bool: ... + __cmp__ = __lt__ -def validate_bool(val): ... -def validate_dict(val): ... -def validate_pos_int(val): ... -def validate_ssl_version(val): ... -def validate_string(val): ... -def validate_file_exists(val): ... -def validate_list_string(val): ... -def validate_list_of_existing_files(val): ... -def validate_string_to_addr_list(val): ... -def validate_string_to_list(val): ... -def validate_class(val): ... -def validate_callable(arity): ... -def validate_user(val): ... -def validate_group(val): ... -def validate_post_request(val): ... -def validate_chdir(val): ... -def validate_statsd_address(val): ... -def validate_reload_engine(val): ... -def get_default_config_file(): ... + +@overload +def validate_bool(val: bool) -> bool: ... +@overload +def validate_bool(val: str | None) -> bool | None: ... +def validate_dict(val: dict[str, Any]) -> dict[str, Any]: ... +@overload +def validate_pos_int(val: int) -> int: ... +@overload +def validate_pos_int(val: ConvertibleToInt) -> int: ... +def validate_ssl_version(val: _SSLMethod) -> _SSLMethod: ... +def validate_string(val: str | None) -> str | None: ... +def validate_file_exists(val: str | None) -> str | None: ... +@overload +def validate_list_string(val: str) -> list[str]: ... +@overload +def validate_list_string(val: list[str]) -> list[str]: ... +@overload +def validate_list_string(val: None) -> list[str]: ... +@overload +def validate_list_of_existing_files(val: str) -> list[str]: ... +@overload +def validate_list_of_existing_files(val: list[str]) -> list[str]: ... +@overload +def validate_list_of_existing_files(val: None) -> list[str]: ... +def validate_string_to_addr_list(val: str | None) -> list[str]: ... +def validate_string_to_list(val: str | None) -> list[str]: ... +@overload +def validate_class(val: str) -> Type[Any]: ... +@overload +def validate_class(val: None) -> None: ... +@overload +def validate_class(val: object) -> Type[Any]: ... +def validate_callable(arity: int) -> Callable[[str | Callable[..., Any]], Callable[..., Any]]: ... +def validate_user(val: int | str | None) -> int: ... +def validate_group(val: int | str | None) -> int: ... +def validate_post_request(val: str | Callable[..., Any]) -> _PostRequestHookType: ... +def validate_chdir(val: str) -> str: ... +@overload +def validate_statsd_address(val: str) -> _AddressType: ... +@overload +def validate_statsd_address(val: None) -> None: ... +def validate_reload_engine(val: str) -> str: ... +@overload +def validate_header_map_behaviour(val: str) -> str: ... +@overload +def validate_header_map_behaviour(val: None) -> None: ... +def get_default_config_file() -> str | None: ... + class ConfigFile(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string + validator: _StringValidatorType default: str desc: str + class WSGIApp(Setting): name: str section: str meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class Bind(Setting): name: str action: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_list_string - default: Incomplete + validator: _ListStringValidatorType + default: list[str] desc: str + class Backlog(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class Workers(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int - default: Incomplete + validator: _IntValidatorType + type: Type[int] + default: int desc: str + class WorkerClass(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_class + validator: _ClassValidatorType default: str desc: str + class WorkerThreads(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class WorkerConnections(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class MaxRequests(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class MaxRequestsJitter(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class Timeout(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class GracefulTimeout(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class Keepalive(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class LimitRequestLine(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class LimitRequestFields(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class LimitRequestFieldSize(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = int + validator: _IntValidatorType + type: Type[int] default: int desc: str + class Reload(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class ReloadEngine(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_reload_engine + validator: Callable[[str], str] default: str desc: str + class ReloadExtraFiles(Setting): name: str action: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_list_of_existing_files - default: Incomplete + validator: _ListStringValidatorType + default: list[str] desc: str + class Spew(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class ConfigCheck(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class PrintConfig(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class PreloadApp(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class Sendfile(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str const: bool desc: str + class ReusePort(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class Chdir(Setting): name: str section: str - cli: Incomplete - validator = validate_chdir - default: Incomplete + cli: list[str] + validator: Callable[[str], str] + default: str default_doc: str desc: str + class Daemon(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class Env(Setting): name: str action: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_list_string - default: Incomplete + validator: _ListStringValidatorType + default: list[str] desc: str + class Pidfile(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class WorkerTmpDir(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class User(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_user - default: Incomplete + validator: _UserGroupValidatorType + default: int default_doc: str desc: str + class Group(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_group - default: Incomplete + validator: _UserGroupValidatorType + default: int default_doc: str desc: str + class Umask(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_pos_int - type = auto_int + validator: _IntValidatorType + type: Callable[[Any, str], int] default: int desc: str + class Initgroups(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class TmpUploadDir(Setting): name: str section: str meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class SecureSchemeHeader(Setting): name: str section: str - validator = validate_dict - default: Incomplete + validator: _DictValidatorType + default: dict[str, str] desc: str + class ForwardedAllowIPS(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string_to_addr_list - default: Incomplete + validator: _ListStringValidatorType + default: str desc: str + class AccessLog(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class DisableRedirectAccessToSyslog(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class AccessLogFormat(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string + validator: _StringValidatorType default: str desc: str + class ErrorLog(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string + validator: _StringValidatorType default: str desc: str + class Loglevel(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string + validator: _StringValidatorType default: str desc: str + class CaptureOutput(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class LoggerClass(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_class + validator: _ClassValidatorType default: str desc: str + class LogConfig(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class LogConfigDict(Setting): name: str section: str - validator = validate_dict - default: Incomplete + validator: _DictValidatorType + default: dict[str, Any] desc: str + class LogConfigJson(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class SyslogTo(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string + validator: _StringValidatorType default: str desc: str + class Syslog(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class SyslogPrefix(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class SyslogFacility(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string + validator: _StringValidatorType default: str desc: str + class EnableStdioInheritance(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType default: bool action: str desc: str + class StatsdHost(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - default: Incomplete - validator = validate_statsd_address + default: None + validator: _AddressValidatorType desc: str + class DogstatsdTags(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str default: str - validator = validate_string + validator: _StringValidatorType desc: str + class StatsdPrefix(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str default: str - validator = validate_string + validator: _StringValidatorType desc: str + class Procname(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class DefaultProcName(Setting): name: str section: str - validator = validate_string + validator: _StringValidatorType default: str desc: str + class PythonPath(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class Paste(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class OnStarting(Setting): name: str section: str - validator: Incomplete - type = callable - def on_starting(server) -> None: ... - default: Incomplete + validator: Callable[[str | _OnStartingHookType], _OnStartingHookType] + type: Callable[..., Any] + default: _OnStartingHookType desc: str + def on_starting(server: Arbiter) -> None: ... # type: ignore[misc] + + class OnReload(Setting): name: str section: str - validator: Incomplete - type = callable - def on_reload(server) -> None: ... - default: Incomplete + validator: Callable[[str | _OnReloadHookType], _OnReloadHookType] + type: Callable[..., Any] + default: _OnReloadHookType desc: str + def on_reload(server: Arbiter) -> None: ... # type: ignore[misc] + + class WhenReady(Setting): name: str section: str - validator: Incomplete - type = callable - def when_ready(server) -> None: ... - default: Incomplete + validator: Callable[[str | _WhenReadyHookType], _WhenReadyHookType] + type: Callable[..., Any] + default: _WhenReadyHookType desc: str + def when_ready(server: Arbiter) -> None: ... # type: ignore[misc] + + class Prefork(Setting): name: str section: str - validator: Incomplete - type = callable - def pre_fork(server, worker) -> None: ... - default: Incomplete + validator: Callable[[str | _PreForkHookType], _PreForkHookType] + type: Callable[..., Any] + default: _PreForkHookType desc: str + def pre_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] + + class Postfork(Setting): name: str section: str - validator: Incomplete - type = callable - def post_fork(server, worker) -> None: ... - default: Incomplete + validator: Callable[[str | _PostForkHookType], _PostForkHookType] + type: Callable[..., Any] + default: _PostForkHookType desc: str + def post_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] + + class PostWorkerInit(Setting): name: str section: str - validator: Incomplete - type = callable - def post_worker_init(worker) -> None: ... - default: Incomplete + validator: Callable[[str | _PostWorkerInitHookType], _PostWorkerInitHookType] + type: Callable[..., Any] + default: _PostWorkerInitHookType desc: str + def post_worker_init(worker: Worker) -> None: ... # type: ignore[misc] + + class WorkerInt(Setting): name: str section: str - validator: Incomplete - type = callable - def worker_int(worker) -> None: ... - default: Incomplete + validator: Callable[[str | _WorkerIntHookType], _WorkerIntHookType] + type: Callable[..., Any] + default: _WorkerIntHookType desc: str + def worker_int(worker: Worker) -> None: ... # type: ignore[misc] + + class WorkerAbort(Setting): name: str section: str - validator: Incomplete - type = callable - def worker_abort(worker) -> None: ... - default: Incomplete + validator: Callable[[str | _WorkerAbortHookType], _WorkerAbortHookType] + type: Callable[..., Any] + default: _WorkerAbortHookType desc: str + def worker_abort(worker: Worker) -> None: ... # type: ignore[misc] + + class PreExec(Setting): name: str section: str - validator: Incomplete - type = callable - def pre_exec(server) -> None: ... - default: Incomplete + validator: Callable[[str | _PreExecHookType], _PreExecHookType] + type: Callable[..., Any] + default: _PreExecHookType desc: str + def pre_exec(server: Arbiter) -> None: ... # type: ignore[misc] + + class PreRequest(Setting): name: str section: str - validator: Incomplete - type = callable - def pre_request(worker, req) -> None: ... - default: Incomplete + validator: Callable[[str | _PreRequestHookType], _PreRequestHookType] + type: Callable[..., Any] + default: _PreRequestHookType desc: str + def pre_request(worker: Worker, req: Request) -> None: ... # type: ignore[misc] + + class PostRequest(Setting): name: str section: str - validator = validate_post_request - type = callable - def post_request(worker, req, environ, resp) -> None: ... - default: Incomplete + validator: Callable[[str | Callable[..., Any]], _PostRequestHookType] + type: Callable[..., Any] + default: _PostRequestHookType desc: str + def post_request(worker: Worker, req: Request, environ: _EnvironType, resp: Response) -> None: ... # type: ignore[misc] + + class ChildExit(Setting): name: str section: str - validator: Incomplete - type = callable - def child_exit(server, worker) -> None: ... - default: Incomplete + validator: Callable[[str | _ChildExitHookType], _ChildExitHookType] + type: Callable[..., Any] + default: _ChildExitHookType desc: str + def child_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] + + class WorkerExit(Setting): name: str section: str - validator: Incomplete - type = callable - def worker_exit(server, worker) -> None: ... - default: Incomplete + validator: Callable[[str | _WorkerExitHookType], _WorkerExitHookType] + type: Callable[..., Any] + default: _WorkerExitHookType desc: str + def worker_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] + + class NumWorkersChanged(Setting): name: str section: str - validator: Incomplete - type = callable - def nworkers_changed(server, new_value, old_value) -> None: ... - default: Incomplete + validator: Callable[[str | _NumWorkersChangedHookType], _NumWorkersChangedHookType] + type: Callable[..., Any] + default: _NumWorkersChangedHookType desc: str + def nworkers_changed(server: Arbiter, new_value: int, old_value: int | None) -> None: ... # type: ignore[misc] + + class OnExit(Setting): name: str section: str - validator: Incomplete - def on_exit(server) -> None: ... - default: Incomplete + validator: Callable[[str | _OnExitHookType], _OnExitHookType] + default: _OnExitHookType desc: str + def on_exit(server: Arbiter) -> None: ... # type: ignore[misc] + + class NewSSLContext(Setting): name: str section: str - validator: Incomplete - type = callable - def ssl_context(config, default_ssl_context_factory): ... - default: Incomplete + validator: Callable[[str | _SSLContextHookType], _SSLContextHookType] + type: Callable[..., Any] + default: _SSLContextHookType desc: str + def ssl_context(config: Config, default_ssl_context_factory: Callable[[], SSLContext]) -> SSLContext: ... # type: ignore[misc] + + class ProxyProtocol(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType default: bool action: str desc: str + class ProxyAllowFrom(Setting): name: str section: str - cli: Incomplete - validator = validate_string_to_addr_list + cli: list[str] + validator: _ListStringValidatorType default: str desc: str + class KeyFile(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class CertFile(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class SSLVersion(Setting): name: str section: str - cli: Incomplete - validator = validate_ssl_version - default: Incomplete + cli: list[str] + validator: Callable[[_SSLMethod], _SSLMethod] + default: _SSLMethod desc: str + class CertReqs(Setting): name: str section: str - cli: Incomplete - validator = validate_pos_int - default: Incomplete + cli: list[str] + validator: _IntValidatorType + default: int desc: str + class CACerts(Setting): name: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_string - default: Incomplete + validator: _StringValidatorType + default: None desc: str + class SuppressRaggedEOFs(Setting): name: str section: str - cli: Incomplete + cli: list[str] action: str default: bool - validator = validate_bool + validator: _BoolValidatorType desc: str + class DoHandshakeOnConnect(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class Ciphers(Setting): name: str section: str - cli: Incomplete - validator = validate_string - default: Incomplete + cli: list[str] + validator: _StringValidatorType + default: None desc: str + class PasteGlobalConf(Setting): name: str action: str section: str - cli: Incomplete + cli: list[str] meta: str - validator = validate_list_string - default: Incomplete + validator: _ListStringValidatorType + default: list[str] desc: str + class PermitObsoleteFolding(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class StripHeaderSpaces(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class PermitUnconventionalHTTPMethod(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class PermitUnconventionalHTTPVersion(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str + class CasefoldHTTPMethod(Setting): name: str section: str - cli: Incomplete - validator = validate_bool + cli: list[str] + validator: _BoolValidatorType action: str default: bool desc: str -def validate_header_map_behaviour(val): ... class ForwarderHeaders(Setting): name: str section: str - cli: Incomplete - validator = validate_string_to_list + cli: list[str] + validator: _ListStringValidatorType default: str desc: str + class HeaderMap(Setting): name: str section: str - cli: Incomplete - validator = validate_header_map_behaviour + cli: list[str] + validator: _StringValidatorType default: str desc: str From af6f58adb8822ac7460df6883f9d3b462165da7f Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 12:59:53 +0300 Subject: [PATCH 015/102] [gunicorn] Fix load_class function type annotation --- stubs/gunicorn/gunicorn/util.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index 7174b451f23e..b3af3b03a810 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -2,7 +2,7 @@ import types from _typeshed import FileDescriptorLike, FileDescriptorOrPath, HasFileno, StrOrBytesPath from inspect import _ParameterKind from socket import socket -from typing import Any, Callable, Literal, LiteralString, NoReturn +from typing import Any, Callable, Literal, LiteralString, NoReturn, Type from urllib.parse import SplitResult from ._types import _WSGIAppType @@ -21,7 +21,7 @@ def load_class( uri: str | object, default: str = "gunicorn.workers.sync.SyncWorker", section: str = "gunicorn.workers", -) -> Any: ... +) -> Type[Any]: ... positionals: tuple[ From 211747122bc51667d4ca675c474008ae05841df8 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 13:01:27 +0300 Subject: [PATCH 016/102] [gunicorn] Fix logger_class property return type annotation --- stubs/gunicorn/gunicorn/config.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 704a3be8c0fc..9194a3347175 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -4,6 +4,7 @@ from collections.abc import Container from ssl import SSLContext, _SSLMethod from typing import Any, Callable, Type, overload +from gunicorn import glogging from gunicorn.arbiter import Arbiter from gunicorn.http import Request from gunicorn.http.wsgi import Response @@ -71,7 +72,7 @@ class Config: @property def proc_name(self) -> str | None: ... @property - def logger_class(self) -> Type[Any]: ... + def logger_class(self) -> Type[glogging.Logger]: ... @property def is_ssl(self) -> bool: ... @property From e1138bddf7525c920367a3b497fe12c1cfde7856 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 13:01:33 +0300 Subject: [PATCH 017/102] [gunicorn] Fix worker_class property return type annotation --- stubs/gunicorn/gunicorn/config.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 9194a3347175..49ea1bafd8ca 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -62,7 +62,7 @@ class Config: @property def worker_class_str(self) -> str: ... @property - def worker_class(self) -> Type[Any]: ... + def worker_class(self) -> Type[Worker]: ... @property def address(self) -> list[_AddressType]: ... @property From b3f5b4f43d73f71870396aeb376aa9a862636f91 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 13:58:40 +0300 Subject: [PATCH 018/102] [gunicorn] Update stubs for arbiter.pyi --- stubs/gunicorn/gunicorn/arbiter.pyi | 66 +++++++++++++++++------------ 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/stubs/gunicorn/gunicorn/arbiter.pyi b/stubs/gunicorn/gunicorn/arbiter.pyi index a263d7344dec..c021d22b0c52 100644 --- a/stubs/gunicorn/gunicorn/arbiter.pyi +++ b/stubs/gunicorn/gunicorn/arbiter.pyi @@ -1,37 +1,49 @@ -from _typeshed import Incomplete +import socket +from types import FrameType +from typing import Type + +from gunicorn.app.base import BaseApplication +from gunicorn.config import Config +from gunicorn.glogging import Logger +from gunicorn.workers.base import Worker + +from .pidfile import Pidfile +from .util import _AddressType + class Arbiter: WORKER_BOOT_ERROR: int APP_LOAD_ERROR: int - START_CTX: Incomplete - LISTENERS: Incomplete - WORKERS: Incomplete - PIPE: Incomplete - SIG_QUEUE: Incomplete - SIGNALS: Incomplete - SIG_NAMES: Incomplete - log: Incomplete - pidfile: Incomplete + START_CTX: dict[int | str, str | list[str]] + LISTENERS: list[socket.socket] + WORKERS: dict[int, Worker] + PIPE: list[int] + SIG_QUEUE: list[int] + SIGNALS: list[int] + SIG_NAMES: dict[int, str] + log: Logger | None + pidfile: Pidfile | None systemd: bool worker_age: int reexec_pid: int master_pid: int master_name: str - def __init__(self, app) -> None: ... - num_workers: Incomplete - app: Incomplete - cfg: Incomplete - worker_class: Incomplete - address: Incomplete - timeout: Incomplete - proc_name: Incomplete - def setup(self, app): ... - pid: Incomplete + pid: int + app: BaseApplication + cfg: Config + worker_class: Type[Worker] + address: list[_AddressType] + timeout: int + proc_name: str + num_workers: int + + def __init__(self, app: BaseApplication) -> None: ... + def setup(self, app: BaseApplication) -> None: ... def start(self) -> None: ... def init_signals(self) -> None: ... - def signal(self, sig, frame) -> None: ... + def signal(self, sig: int, frame: FrameType | None) -> None: ... def run(self) -> None: ... - def handle_chld(self, sig, frame) -> None: ... + def handle_chld(self, sig: int, frame: FrameType | None) -> None: ... def handle_hup(self) -> None: ... def handle_term(self) -> None: ... def handle_int(self) -> None: ... @@ -43,15 +55,15 @@ class Arbiter: def handle_winch(self) -> None: ... def maybe_promote_master(self) -> None: ... def wakeup(self) -> None: ... - def halt(self, reason=None, exit_status: int = 0) -> None: ... + def halt(self, reason: str | None = None, exit_status: int = 0) -> None: ... def sleep(self) -> None: ... def stop(self, graceful: bool = True) -> None: ... def reexec(self) -> None: ... def reload(self) -> None: ... def murder_workers(self) -> None: ... def reap_workers(self) -> None: ... - def manage_workers(self): ... - def spawn_worker(self): ... + def manage_workers(self) -> None: ... + def spawn_worker(self) -> int: ... def spawn_workers(self) -> None: ... - def kill_workers(self, sig) -> None: ... - def kill_worker(self, pid, sig) -> None: ... + def kill_workers(self, sig: int) -> None: ... + def kill_worker(self, pid: int, sig: int) -> None: ... From f97a5f6846420b6c02bd4bef1d2da4d5ffb32d61 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 14:00:01 +0300 Subject: [PATCH 019/102] [gunicorn] Update stubs for __init__.pyi --- stubs/gunicorn/gunicorn/__init__.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/gunicorn/gunicorn/__init__.pyi b/stubs/gunicorn/gunicorn/__init__.pyi index 234233d984f3..cfee5fc04685 100644 --- a/stubs/gunicorn/gunicorn/__init__.pyi +++ b/stubs/gunicorn/gunicorn/__init__.pyi @@ -1,6 +1,6 @@ -from _typeshed import Incomplete +from typing import LiteralString -version_info: Incomplete -__version__: Incomplete +version_info: tuple[int, int, int] +__version__: LiteralString SERVER: str -SERVER_SOFTWARE: Incomplete +SERVER_SOFTWARE: str From bfabbcb1a8e2de40b027dc112bde1327b4a766f1 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 14:05:04 +0300 Subject: [PATCH 020/102] [gunicorn] Update stubs for workers/workertmp.pyi --- stubs/gunicorn/gunicorn/workers/workertmp.pyi | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/workertmp.pyi b/stubs/gunicorn/gunicorn/workers/workertmp.pyi index 39e84b7b056b..c2323ac06e2d 100644 --- a/stubs/gunicorn/gunicorn/workers/workertmp.pyi +++ b/stubs/gunicorn/gunicorn/workers/workertmp.pyi @@ -1,11 +1,12 @@ -from _typeshed import Incomplete +from gunicorn.config import Config + +PLATFORM: str +IS_CYGWIN: bool -PLATFORM: Incomplete -IS_CYGWIN: Incomplete class WorkerTmp: - def __init__(self, cfg) -> None: ... + def __init__(self, cfg: Config) -> None: ... def notify(self) -> None: ... - def last_update(self): ... - def fileno(self): ... - def close(self): ... + def last_update(self) -> float: ... + def fileno(self) -> int: ... + def close(self) -> None: ... From b25a69a15e5814f255609ac042e3c36c8a18569e Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 14:10:40 +0300 Subject: [PATCH 021/102] [gunicorn] Fix ssl_context function return type annotation --- stubs/gunicorn/gunicorn/sock.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/sock.pyi b/stubs/gunicorn/gunicorn/sock.pyi index 5dba2ef144e2..838699131d0a 100644 --- a/stubs/gunicorn/gunicorn/sock.pyi +++ b/stubs/gunicorn/gunicorn/sock.pyi @@ -2,7 +2,7 @@ import socket from _typeshed import Incomplete from collections.abc import Iterable from logging import Logger -from ssl import SSLSocket +from ssl import SSLSocket, SSLContext from typing import Any, ClassVar, Literal, SupportsIndex, override from .config import Config @@ -37,5 +37,5 @@ class UnixSocket(BaseSocket): def create_sockets(conf: Config, log: Logger, fds: Iterable[SupportsIndex] | None = None) -> list[BaseSocket]: ... def close_sockets(listeners: Iterable[socket.socket], unlink: bool = True) -> None: ... -def ssl_context(conf: Config) -> Incomplete: ... +def ssl_context(conf: Config) -> SSLContext: ... def ssl_wrap_socket(sock: socket.socket, conf: Config) -> SSLSocket: ... From f23abec8a85c483873b8eed9cf3ce63aa5715a87 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 14:36:09 +0300 Subject: [PATCH 022/102] [gunicorn] Update stubs for workers/sync.pyi --- stubs/gunicorn/gunicorn/workers/sync.pyi | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/sync.pyi b/stubs/gunicorn/gunicorn/workers/sync.pyi index 3e6862e1cb7e..0075e55f86f1 100644 --- a/stubs/gunicorn/gunicorn/workers/sync.pyi +++ b/stubs/gunicorn/gunicorn/workers/sync.pyi @@ -1,14 +1,21 @@ -from gunicorn.workers import base +import socket + +from gunicorn.http import Request +from gunicorn.workers.base import Worker + +from ..util import _AddressType + class StopWaiting(Exception): ... -class SyncWorker(base.Worker): - def accept(self, listener) -> None: ... - def wait(self, timeout): ... - def is_parent_alive(self): ... - def run_for_one(self, timeout) -> None: ... - def run_for_multiple(self, timeout) -> None: ... + +class SyncWorker(Worker): + def accept(self, listener: socket.socket) -> None: ... + def wait(self, timeout: int) -> list[socket.socket | int] | None: ... + def is_parent_alive(self) -> bool: ... + def run_for_one(self, timeout: int) -> None: ... + def run_for_multiple(self, timeout: int) -> None: ... def run(self) -> None: ... - def handle(self, listener, client, addr) -> None: ... - alive: bool - def handle_request(self, listener, req, client, addr) -> None: ... + def handle(self, listener: socket.socket, client: socket.socket, addr: _AddressType) -> None: ... + def handle_request(self, listener: socket.socket, req: Request, client: socket.socket, addr: tuple[str, int]) -> None: ... + def handle_error(self, req: Request, client: socket.socket, addr: _AddressType, exc: BaseException) -> None: ... From fc17f3ff796f412ebf7e8ebfd558f85e4fb0c188 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 14:42:29 +0300 Subject: [PATCH 023/102] [gunicorn] Move _AddressType to file ._types.pyi --- stubs/gunicorn/gunicorn/_types.pyi | 7 ++++++- stubs/gunicorn/gunicorn/arbiter.pyi | 2 +- stubs/gunicorn/gunicorn/config.pyi | 3 +-- stubs/gunicorn/gunicorn/util.pyi | 9 ++------- stubs/gunicorn/gunicorn/workers/sync.pyi | 4 +--- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index e244c7b5eb49..c9300092b93c 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable -from typing import Any, Callable +from typing import Any, Callable, LiteralString type _StatusType = str type _HeadersType = list[tuple[str, str]] @@ -9,3 +9,8 @@ type _StartResponseType = Callable[[_StatusType, _HeadersType], None] type _ResponseBodyType = Iterable[bytes] type _WSGIAppType = Callable[[_EnvironType, _StartResponseType], _ResponseBodyType] + +type _UnixSocketPathType = str +type _FileDescriptorType = int +type _TcpAddressType = tuple[LiteralString, int] +type _AddressType = _UnixSocketPathType | _FileDescriptorType | _TcpAddressType diff --git a/stubs/gunicorn/gunicorn/arbiter.pyi b/stubs/gunicorn/gunicorn/arbiter.pyi index c021d22b0c52..4450f4c17daa 100644 --- a/stubs/gunicorn/gunicorn/arbiter.pyi +++ b/stubs/gunicorn/gunicorn/arbiter.pyi @@ -7,8 +7,8 @@ from gunicorn.config import Config from gunicorn.glogging import Logger from gunicorn.workers.base import Worker +from ._types import _AddressType from .pidfile import Pidfile -from .util import _AddressType class Arbiter: diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 49ea1bafd8ca..445f76bed341 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -10,8 +10,7 @@ from gunicorn.http import Request from gunicorn.http.wsgi import Response from gunicorn.workers.base import Worker -from ._types import _EnvironType -from .util import _AddressType +from ._types import _AddressType, _EnvironType type _OnStartingHookType = Callable[[Arbiter], None] type _OnReloadHookType = Callable[[Arbiter], None] diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index b3af3b03a810..fcf6db5920bb 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -2,15 +2,10 @@ import types from _typeshed import FileDescriptorLike, FileDescriptorOrPath, HasFileno, StrOrBytesPath from inspect import _ParameterKind from socket import socket -from typing import Any, Callable, Literal, LiteralString, NoReturn, Type +from typing import Any, Callable, Literal, NoReturn, Type from urllib.parse import SplitResult -from ._types import _WSGIAppType - -type _UnixSocketPathType = str -type _FileDescriptorType = int -type _TcpAddressType = tuple[LiteralString, int] -type _AddressType = _UnixSocketPathType | _FileDescriptorType | _TcpAddressType +from ._types import _AddressType, _WSGIAppType REDIRECT_TO: str hop_headers: set[str] diff --git a/stubs/gunicorn/gunicorn/workers/sync.pyi b/stubs/gunicorn/gunicorn/workers/sync.pyi index 0075e55f86f1..3b07736b089e 100644 --- a/stubs/gunicorn/gunicorn/workers/sync.pyi +++ b/stubs/gunicorn/gunicorn/workers/sync.pyi @@ -3,12 +3,10 @@ import socket from gunicorn.http import Request from gunicorn.workers.base import Worker -from ..util import _AddressType - +from .._types import _AddressType class StopWaiting(Exception): ... - class SyncWorker(Worker): def accept(self, listener: socket.socket) -> None: ... def wait(self, timeout: int) -> list[socket.socket | int] | None: ... From 955063290e89cab79bb82b1c762c9a5b21c9f772 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 14:56:15 +0300 Subject: [PATCH 024/102] [gunicorn] Update stubs for workers/gtornado.pyi --- stubs/gunicorn/gunicorn/workers/gtornado.pyi | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/gtornado.pyi b/stubs/gunicorn/gunicorn/workers/gtornado.pyi index 1f21dae156b8..96bc85529541 100644 --- a/stubs/gunicorn/gunicorn/workers/gtornado.pyi +++ b/stubs/gunicorn/gunicorn/workers/gtornado.pyi @@ -1,20 +1,26 @@ -from _typeshed import Incomplete +from types import FrameType +from typing import override from gunicorn.workers.base import Worker +from tornado.ioloop import IOLoop, PeriodicCallback + +TORNADO5: bool -TORNADO5: Incomplete class TornadoWorker(Worker): + alive: bool + server_alive: bool + ioloop: IOLoop + callbacks: list[PeriodicCallback] + @classmethod def setup(cls) -> None: ... - def handle_exit(self, sig, frame) -> None: ... - alive: bool + @override + def handle_exit(self, sig: int, frame: FrameType | None) -> None: ... def handle_request(self) -> None: ... def watchdog(self) -> None: ... - server_alive: bool def heartbeat(self) -> None: ... + @override def init_process(self) -> None: ... - ioloop: Incomplete - callbacks: Incomplete - server: Incomplete + @override def run(self) -> None: ... From f444d1abaf1a36fa29f49f2920f594031df5981c Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 15:06:05 +0300 Subject: [PATCH 025/102] [gunicorn] Add override decorator --- stubs/gunicorn/gunicorn/config.pyi | 3 ++- stubs/gunicorn/gunicorn/glogging.pyi | 3 ++- stubs/gunicorn/gunicorn/reloader.pyi | 4 +++- stubs/gunicorn/gunicorn/workers/sync.pyi | 3 +++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 445f76bed341..3ea43dc04f43 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -2,7 +2,7 @@ import argparse from _typeshed import ConvertibleToInt from collections.abc import Container from ssl import SSLContext, _SSLMethod -from typing import Any, Callable, Type, overload +from typing import Any, Callable, Type, overload, override from gunicorn import glogging from gunicorn.arbiter import Arbiter @@ -54,6 +54,7 @@ class Config: def __init__(self, usage: str | None = None, prog: str | None = None) -> None: ... def __getattr__(self, name: str) -> Any: ... + @override def __setattr__(self, name: str, value: Any) -> None: ... def set(self, name: str, value: Any) -> None: ... def get_cmd_args_from_env(self) -> list[str]: ... diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 638df653531d..0e59800b25f1 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -2,7 +2,7 @@ import logging import threading from datetime import timedelta from socket import SocketKind -from typing import Annotated, Any, Literal, TypedDict, type_check_only +from typing import Annotated, Any, Literal, TypedDict, override, type_check_only from gunicorn.http import Request from gunicorn.http.wsgi import Response @@ -99,6 +99,7 @@ def loggers() -> list[logging.Logger]: ... class SafeAtoms(dict[str, Any]): def __init__(self, atoms: dict[str, Any]) -> None: ... + @override def __getitem__(self, k: str) -> str: ... diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index ad9ba5a2330a..00ffa725332b 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -1,7 +1,7 @@ import threading from collections.abc import Iterable, Set as AbstractSet from re import Pattern -from typing import Callable, TypedDict, type_check_only +from typing import Callable, TypedDict, override, type_check_only try: from inotify.adapters import Inotify @@ -23,6 +23,7 @@ class Reloader(threading.Thread): ) -> None: ... def add_extra_file(self, filename: str) -> None: ... def get_files(self) -> list[str]: ... + @override def run(self) -> None: ... @@ -42,6 +43,7 @@ class InotifyReloader(threading.Thread): ) -> None: ... def add_extra_file(self, filename: str) -> None: ... def get_dirs(self) -> AbstractSet[str]: ... + @override def run(self) -> None: ... diff --git a/stubs/gunicorn/gunicorn/workers/sync.pyi b/stubs/gunicorn/gunicorn/workers/sync.pyi index 3b07736b089e..fa6d52402a31 100644 --- a/stubs/gunicorn/gunicorn/workers/sync.pyi +++ b/stubs/gunicorn/gunicorn/workers/sync.pyi @@ -1,4 +1,5 @@ import socket +from typing import override from gunicorn.http import Request from gunicorn.workers.base import Worker @@ -13,7 +14,9 @@ class SyncWorker(Worker): def is_parent_alive(self) -> bool: ... def run_for_one(self, timeout: int) -> None: ... def run_for_multiple(self, timeout: int) -> None: ... + @override def run(self) -> None: ... def handle(self, listener: socket.socket, client: socket.socket, addr: _AddressType) -> None: ... def handle_request(self, listener: socket.socket, req: Request, client: socket.socket, addr: tuple[str, int]) -> None: ... + @override def handle_error(self, req: Request, client: socket.socket, addr: _AddressType, exc: BaseException) -> None: ... From 9168bfae261c81bb2e3275afb1a64a88bf878172 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 15:26:42 +0300 Subject: [PATCH 026/102] [gunicorn] Add types-tornado in METADATA.toml requires --- stubs/gunicorn/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/METADATA.toml b/stubs/gunicorn/METADATA.toml index 88053dbbb993..ce0d76b59093 100644 --- a/stubs/gunicorn/METADATA.toml +++ b/stubs/gunicorn/METADATA.toml @@ -1,3 +1,3 @@ version = "23.0.*" upstream_repository = "https://github.com/benoitc/gunicorn" -requires = ["types-gevent"] +requires = ["types-gevent", "types-tornado"] From 43b02f0a9d4ad22935dc4cb6943b4a4e2478f862 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 15:27:03 +0300 Subject: [PATCH 027/102] [gunicorn] Update stubs for workers/gthread.pyi --- stubs/gunicorn/gunicorn/workers/gthread.pyi | 57 +++++++++++++-------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/gthread.pyi b/stubs/gunicorn/gunicorn/workers/gthread.pyi index 3dd7b634b03c..fc2aa58a0ff3 100644 --- a/stubs/gunicorn/gunicorn/workers/gthread.pyi +++ b/stubs/gunicorn/gunicorn/workers/gthread.pyi @@ -1,40 +1,53 @@ +import logging +import socket from _typeshed import Incomplete +from concurrent.futures import ThreadPoolExecutor +from selectors import DefaultSelector +from types import FrameType +from gunicorn.config import Config +from gunicorn.http import RequestParser + +from .._types import _AddressType from . import base + class TConn: - cfg: Incomplete - sock: Incomplete - client: Incomplete - server: Incomplete - timeout: Incomplete - parser: Incomplete + cfg: Config + sock: socket.socket + client: _AddressType + server: _AddressType + timeout: float | None + parser: RequestParser | None initialized: bool - def __init__(self, cfg, sock, client, server) -> None: ... + + def __init__(self, cfg: Config, sock: socket.socket, client: _AddressType, server: _AddressType) -> None: ... def init(self) -> None: ... def set_timeout(self) -> None: ... def close(self) -> None: ... + class ThreadWorker(base.Worker): - worker_connections: Incomplete - max_keepalived: Incomplete - tpool: Incomplete - poller: Incomplete + worker_connections: int + max_keepalived: int + tpool: ThreadPoolExecutor + poller: DefaultSelector futures: Incomplete nr_conns: int + alive: bool + def __init__(self, *args, **kwargs) -> None: ... @classmethod - def check_config(cls, cfg, log) -> None: ... + def check_config(cls, cfg: Config, log: logging.Logger) -> None: ... def init_process(self) -> None: ... - def get_thread_pool(self): ... - alive: bool - def handle_quit(self, sig, frame) -> None: ... - def enqueue_req(self, conn) -> None: ... - def accept(self, server, listener) -> None: ... - def on_client_socket_readable(self, conn, client) -> None: ... + def get_thread_pool(self) -> ThreadPoolExecutor: ... + def handle_quit(self, sig: int, frame: FrameType | None) -> None: ... + def enqueue_req(self, conn: TConn) -> None: ... + def accept(self, server: _AddressType, listener: socket.socket) -> None: ... + def on_client_socket_readable(self, conn: TConn, client: socket.socket) -> None: ... def murder_keepalived(self) -> None: ... - def is_parent_alive(self): ... + def is_parent_alive(self) -> bool: ... def run(self) -> None: ... - def finish_request(self, fs) -> None: ... - def handle(self, conn): ... - def handle_request(self, req, conn): ... + def finish_request(self, fs: Incomplete) -> None: ... + def handle(self, conn: TConn) -> tuple[bool, TConn]: ... + def handle_request(self, req: RequestParser, conn: TConn) -> bool: ... From e29de4ae493bb3e708800f6195fb85a1a6859f89 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 17:59:27 +0300 Subject: [PATCH 028/102] [gunicorn] Update stubs for workers/ggevent.pyi --- stubs/gunicorn/gunicorn/workers/ggevent.pyi | 57 +++++++++++++++------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/ggevent.pyi b/stubs/gunicorn/gunicorn/workers/ggevent.pyi index 5b609b0144c3..6571e5498e0a 100644 --- a/stubs/gunicorn/gunicorn/workers/ggevent.pyi +++ b/stubs/gunicorn/gunicorn/workers/ggevent.pyi @@ -1,36 +1,59 @@ -from _typeshed import Incomplete +from types import FrameType +from typing import Any, Type +from typing_extensions import override from gevent import pywsgi +from gevent.pywsgi import WSGIHandler +from gevent.server import StreamServer +from gevent.socket import socket as GeventSocket +from gunicorn.http import Request from gunicorn.workers.base_async import AsyncWorker -VERSION: Incomplete +from .._types import _AddressType + +VERSION: str + class GeventWorker(AsyncWorker): - server_class: Incomplete - wsgi_handler: Incomplete - sockets: Incomplete + server_class: Type[StreamServer] | None + wsgi_handler: Type[WSGIHandler] | None + sockets: list[GeventSocket] + def patch(self) -> None: ... + @override def notify(self) -> None: ... - def timeout_ctx(self): ... + @override + def timeout_ctx(self) -> None: ... + @override def run(self) -> None: ... - def handle(self, listener, client, addr) -> None: ... - def handle_request(self, listener_name, req, sock, addr) -> None: ... - def handle_quit(self, sig, frame) -> None: ... - def handle_usr1(self, sig, frame) -> None: ... + @override + def handle(self, listener: GeventSocket, client: GeventSocket, addr: _AddressType) -> None: ... + @override + def handle_request(self, listener_name: str, req: Request, sock: GeventSocket, addr: _AddressType) -> None: ... + @override + def handle_quit(self, sig: int, frame: FrameType | None) -> None: ... + @override + def handle_usr1(self, sig: int, frame: FrameType | None) -> None: ... + @override def init_process(self) -> None: ... + class GeventResponse: - status: Incomplete - headers: Incomplete - sent: Incomplete - def __init__(self, status, headers, clength) -> None: ... + status: str | None + headers: dict[str, str] | None + sent: int | None + + def __init__(self, status: str, headers: dict[str, str], clength: int | None) -> None: ... + class PyWSGIHandler(pywsgi.WSGIHandler): def log_request(self) -> None: ... - def get_environ(self): ... + def get_environ(self) -> dict[str, Any]: ... + class PyWSGIServer(pywsgi.WSGIServer): ... + class GeventPyWSGIWorker(GeventWorker): - server_class = PyWSGIServer - wsgi_handler = PyWSGIHandler + server_class: Type[PyWSGIServer] | None + wsgi_handler: Type[PyWSGIHandler] | None From 401499a8a24711ce52272fdb050ace59a7f18ac2 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 18:26:49 +0300 Subject: [PATCH 029/102] [gunicorn] Update stubs for workers/geventlet.pyi --- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index ece24ff71721..5b82ae9fe54e 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -1,18 +1,32 @@ -from _typeshed import Incomplete +from types import FrameType +from typing import Any, override +from eventlet.greenio import GreenSocket # type: ignore[import-untyped] +from eventlet.wsgi import local # type: ignore[import-untyped] from gunicorn.workers.base_async import AsyncWorker -EVENTLET_WSGI_LOCAL: Incomplete -EVENTLET_ALREADY_HANDLED: Incomplete +from .._types import _AddressType + +EVENTLET_WSGI_LOCAL: local | None +EVENTLET_ALREADY_HANDLED: bool | None + def patch_sendfile() -> None: ... + class EventletWorker(AsyncWorker): def patch(self) -> None: ... - def is_already_handled(self, respiter): ... + @override + def is_already_handled(self, respiter: Any) -> bool: ... + @override def init_process(self) -> None: ... - def handle_quit(self, sig, frame) -> None: ... - def handle_usr1(self, sig, frame) -> None: ... - def timeout_ctx(self): ... - def handle(self, listener, client, addr) -> None: ... + @override + def handle_quit(self, sig: int, frame: FrameType | None) -> None: ... + @override + def handle_usr1(self, sig: int, frame: FrameType | None) -> None: ... + @override + def timeout_ctx(self) -> None: ... + @override + def handle(self, listener: GreenSocket, client: GreenSocket, addr: _AddressType) -> None: ... + @override def run(self) -> None: ... From c513eb5c61866e968bb04a8cf33adb8b8bcda1fe Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 18:34:47 +0300 Subject: [PATCH 030/102] [gunicorn] Update stubs for workers/base_async.pyi --- .../gunicorn/gunicorn/workers/base_async.pyi | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/base_async.pyi b/stubs/gunicorn/gunicorn/workers/base_async.pyi index 8f0dacbfe609..1ba05fc14dee 100644 --- a/stubs/gunicorn/gunicorn/workers/base_async.pyi +++ b/stubs/gunicorn/gunicorn/workers/base_async.pyi @@ -1,14 +1,19 @@ -from _typeshed import Incomplete +import socket +from typing import Any +from gunicorn.http import Request from gunicorn.workers import base -ALREADY_HANDLED: Incomplete +from .._types import _AddressType + +ALREADY_HANDLED: object class AsyncWorker(base.Worker): - worker_connections: Incomplete - def __init__(self, *args, **kwargs) -> None: ... - def timeout_ctx(self) -> None: ... - def is_already_handled(self, respiter): ... - def handle(self, listener, client, addr) -> None: ... + worker_connections: int alive: bool - def handle_request(self, listener_name, req, sock, addr): ... + + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def timeout_ctx(self) -> None: ... + def is_already_handled(self, respiter: Any): ... + def handle(self, listener: socket.socket, client: socket.socket, addr: _AddressType) -> None: ... + def handle_request(self, listener_name: str, req: Request, sock: socket.socket, addr: _AddressType) -> bool: ... From 268be543ec4e6a2379ef3e219eda3258dd389822 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 18:41:23 +0300 Subject: [PATCH 031/102] [gunicorn] Delete EventMask type from reloader.pyi --- stubs/gunicorn/gunicorn/reloader.pyi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index 00ffa725332b..bf73abef8b22 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -29,11 +29,9 @@ class Reloader(threading.Thread): has_inotify: bool -EventMask = int - class InotifyReloader(threading.Thread): - event_mask: EventMask + event_mask: int daemon: bool def __init__( From 4ce39a07e022724ccf9137a2fc3d65be2d28cbda Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 18:46:48 +0300 Subject: [PATCH 032/102] [gunicorn] Add prefix '_' to types in reloader.pyi --- stubs/gunicorn/gunicorn/reloader.pyi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index bf73abef8b22..db2289f55ead 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -45,15 +45,16 @@ class InotifyReloader(threading.Thread): def run(self) -> None: ... -type PreferredReloaderType = type[InotifyReloader | Reloader] +type _PreferredReloaderType = type[InotifyReloader | Reloader] +type _ReloaderType = InotifyReloader | Reloader @type_check_only class _ReloadedEngines(TypedDict): - auto: PreferredReloaderType + auto: _PreferredReloaderType pool: type[Reloader] inotify: type[InotifyReloader] -preferred_reloader: PreferredReloaderType +preferred_reloader: _PreferredReloaderType reloader_engines: _ReloadedEngines From 23d0ded4182cbe966691f54a596ef3104c5472ce Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 18:52:30 +0300 Subject: [PATCH 033/102] [gunicorn] Add type: ignore for inotify library in reloader.pyi --- stubs/gunicorn/gunicorn/reloader.pyi | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index db2289f55ead..6b9106bec71a 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -4,8 +4,16 @@ from re import Pattern from typing import Callable, TypedDict, override, type_check_only try: - from inotify.adapters import Inotify - from inotify.constants import IN_CREATE, IN_DELETE, IN_DELETE_SELF, IN_MODIFY, IN_MOVE_SELF, IN_MOVED_FROM, IN_MOVED_TO + from inotify.adapters import Inotify # type: ignore[import-untyped] + from inotify.constants import ( # type: ignore[import-untyped] + IN_CREATE, + IN_DELETE, + IN_DELETE_SELF, + IN_MODIFY, + IN_MOVE_SELF, + IN_MOVED_FROM, + IN_MOVED_TO, + ) except ImportError: Inotify = object From 24d50280850b14aa8d586d985fd944e014c14d40 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 18:52:54 +0300 Subject: [PATCH 034/102] [gunicorn] Update stubs for workers/base.pyi --- stubs/gunicorn/gunicorn/workers/base.pyi | 65 ++++++++++++++++-------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/base.pyi b/stubs/gunicorn/gunicorn/workers/base.pyi index 6841190b3881..319b61a993ab 100644 --- a/stubs/gunicorn/gunicorn/workers/base.pyi +++ b/stubs/gunicorn/gunicorn/workers/base.pyi @@ -1,34 +1,55 @@ -from _typeshed import Incomplete +import socket +from types import FrameType + +from gunicorn.app.base import BaseApplication +from gunicorn.config import Config +from gunicorn.glogging import Logger as GLogger +from gunicorn.http import Request +from gunicorn.workers.workertmp import WorkerTmp + +from .._types import _AddressType, _WSGIAppType +from ..reloader import _ReloaderType + class Worker: - SIGNALS: Incomplete - PIPE: Incomplete - age: Incomplete + SIGNALS: list[int] + PIPE: list[int] + age: int pid: str - ppid: Incomplete - sockets: Incomplete - app: Incomplete - timeout: Incomplete - cfg: Incomplete + ppid: int + sockets: list[socket.socket] + app: BaseApplication + timeout: int + cfg: Config booted: bool aborted: bool - reloader: Incomplete + reloader: _ReloaderType | None nr: int - max_requests: Incomplete + max_requests: int alive: bool - log: Incomplete - tmp: Incomplete - def __init__(self, age, ppid, sockets, app, timeout, cfg, log) -> None: ... + log: GLogger + tmp: WorkerTmp + wait_fds: list[socket.socket | int] + wsgi: _WSGIAppType + + def __init__( + self, + age: int, + ppid: int, + sockets: list[socket.socket], + app: BaseApplication, + timeout: int, + cfg: Config, + log: GLogger, + ) -> None: ... def notify(self) -> None: ... def run(self) -> None: ... - wait_fds: Incomplete def init_process(self) -> None: ... - wsgi: Incomplete def load_wsgi(self) -> None: ... def init_signals(self) -> None: ... - def handle_usr1(self, sig, frame) -> None: ... - def handle_exit(self, sig, frame) -> None: ... - def handle_quit(self, sig, frame) -> None: ... - def handle_abort(self, sig, frame) -> None: ... - def handle_error(self, req, client, addr, exc) -> None: ... - def handle_winch(self, sig, fname) -> None: ... + def handle_usr1(self, sig: int, frame: FrameType | None) -> None: ... + def handle_exit(self, sig: int, frame: FrameType | None) -> None: ... + def handle_quit(self, sig: int, frame: FrameType | None) -> None: ... + def handle_abort(self, sig: int, frame: FrameType | None) -> None: ... + def handle_error(self, req: Request | None, client: socket.socket, addr: _AddressType, exc: BaseException) -> None: ... + def handle_winch(self, sig: int, fname: str | None) -> None: ... From 32dc3ebdf4f5492866b9269cfbf36676301f49ff Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 19:00:57 +0300 Subject: [PATCH 035/102] [gunicorn] Fix logger annotations --- stubs/gunicorn/gunicorn/arbiter.pyi | 4 ++-- stubs/gunicorn/gunicorn/config.pyi | 4 ++-- stubs/gunicorn/gunicorn/sock.pyi | 12 ++++++------ stubs/gunicorn/gunicorn/systemd.pyi | 4 ++-- stubs/gunicorn/gunicorn/workers/gthread.pyi | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/stubs/gunicorn/gunicorn/arbiter.pyi b/stubs/gunicorn/gunicorn/arbiter.pyi index 4450f4c17daa..aff752bcaa01 100644 --- a/stubs/gunicorn/gunicorn/arbiter.pyi +++ b/stubs/gunicorn/gunicorn/arbiter.pyi @@ -4,7 +4,7 @@ from typing import Type from gunicorn.app.base import BaseApplication from gunicorn.config import Config -from gunicorn.glogging import Logger +from gunicorn.glogging import Logger as GLogger from gunicorn.workers.base import Worker from ._types import _AddressType @@ -21,7 +21,7 @@ class Arbiter: SIG_QUEUE: list[int] SIGNALS: list[int] SIG_NAMES: dict[int, str] - log: Logger | None + log: GLogger | None pidfile: Pidfile | None systemd: bool worker_age: int diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 3ea43dc04f43..f7421d6db1a4 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -4,8 +4,8 @@ from collections.abc import Container from ssl import SSLContext, _SSLMethod from typing import Any, Callable, Type, overload, override -from gunicorn import glogging from gunicorn.arbiter import Arbiter +from gunicorn.glogging import Logger as GLogger from gunicorn.http import Request from gunicorn.http.wsgi import Response from gunicorn.workers.base import Worker @@ -72,7 +72,7 @@ class Config: @property def proc_name(self) -> str | None: ... @property - def logger_class(self) -> Type[glogging.Logger]: ... + def logger_class(self) -> Type[GLogger]: ... @property def is_ssl(self) -> bool: ... @property diff --git a/stubs/gunicorn/gunicorn/sock.pyi b/stubs/gunicorn/gunicorn/sock.pyi index 838699131d0a..dead824b812f 100644 --- a/stubs/gunicorn/gunicorn/sock.pyi +++ b/stubs/gunicorn/gunicorn/sock.pyi @@ -1,15 +1,15 @@ import socket -from _typeshed import Incomplete from collections.abc import Iterable -from logging import Logger -from ssl import SSLSocket, SSLContext +from ssl import SSLContext, SSLSocket from typing import Any, ClassVar, Literal, SupportsIndex, override +from gunicorn.glogging import Logger as GLogger + from .config import Config class BaseSocket: - def __init__(self, address: str, conf: Config, log: Logger, fd: SupportsIndex | None = None) -> None: ... + def __init__(self, address: str, conf: Config, log: GLogger, fd: SupportsIndex | None = None) -> None: ... def __getattr__(self, name: str) -> Any: ... def set_options[T: socket.socket](self, sock: T, bound: bool = False) -> T: ... def bind(self, sock: socket.socket) -> None: ... @@ -30,12 +30,12 @@ class TCP6Socket(TCPSocket): class UnixSocket(BaseSocket): FAMILY: ClassVar[Literal[socket.AddressFamily.AF_UNIX]] - def __init__(self, addr: str, conf: Config, log: Logger, fd: SupportsIndex | None = None) -> None: ... + def __init__(self, addr: str, conf: Config, log: GLogger, fd: SupportsIndex | None = None) -> None: ... @override def bind(self, sock: socket.socket) -> None: ... -def create_sockets(conf: Config, log: Logger, fds: Iterable[SupportsIndex] | None = None) -> list[BaseSocket]: ... +def create_sockets(conf: Config, log: GLogger, fds: Iterable[SupportsIndex] | None = None) -> list[BaseSocket]: ... def close_sockets(listeners: Iterable[socket.socket], unlink: bool = True) -> None: ... def ssl_context(conf: Config) -> SSLContext: ... def ssl_wrap_socket(sock: socket.socket, conf: Config) -> SSLSocket: ... diff --git a/stubs/gunicorn/gunicorn/systemd.pyi b/stubs/gunicorn/gunicorn/systemd.pyi index 4f2b1dbd4a8b..ccdae639170d 100644 --- a/stubs/gunicorn/gunicorn/systemd.pyi +++ b/stubs/gunicorn/gunicorn/systemd.pyi @@ -1,7 +1,7 @@ -from logging import Logger +from gunicorn.glogging import Logger as GLogger SD_LISTEN_FDS_START: int def listen_fds(unset_environment: bool = True) -> int: ... -def sd_notify(state: str, logger: Logger, unset_environment: bool = False) -> None: ... +def sd_notify(state: str, logger: GLogger, unset_environment: bool = False) -> None: ... diff --git a/stubs/gunicorn/gunicorn/workers/gthread.pyi b/stubs/gunicorn/gunicorn/workers/gthread.pyi index fc2aa58a0ff3..f56489d08090 100644 --- a/stubs/gunicorn/gunicorn/workers/gthread.pyi +++ b/stubs/gunicorn/gunicorn/workers/gthread.pyi @@ -1,4 +1,3 @@ -import logging import socket from _typeshed import Incomplete from concurrent.futures import ThreadPoolExecutor @@ -6,6 +5,7 @@ from selectors import DefaultSelector from types import FrameType from gunicorn.config import Config +from gunicorn.glogging import Logger as GLogger from gunicorn.http import RequestParser from .._types import _AddressType @@ -38,7 +38,7 @@ class ThreadWorker(base.Worker): def __init__(self, *args, **kwargs) -> None: ... @classmethod - def check_config(cls, cfg: Config, log: logging.Logger) -> None: ... + def check_config(cls, cfg: Config, log: GLogger) -> None: ... def init_process(self) -> None: ... def get_thread_pool(self) -> ThreadPoolExecutor: ... def handle_quit(self, sig: int, frame: FrameType | None) -> None: ... From 2d7546556d06d49fbc5bd5938bf26c4293940a09 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 19:03:24 +0300 Subject: [PATCH 036/102] [gunicorn] Update stubs for workers/__init__.pyi --- stubs/gunicorn/gunicorn/workers/__init__.pyi | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/__init__.pyi b/stubs/gunicorn/gunicorn/workers/__init__.pyi index 8ad1ff0c044e..db480b10ac88 100644 --- a/stubs/gunicorn/gunicorn/workers/__init__.pyi +++ b/stubs/gunicorn/gunicorn/workers/__init__.pyi @@ -1,3 +1,15 @@ -from _typeshed import Incomplete +from typing import TypedDict, type_check_only -SUPPORTED_WORKERS: Incomplete + +@type_check_only +class _SupportedWorkers(TypedDict): + sync: str + eventlet: str + gevent: str + gevent_wsgi: str + gevent_pywsgi: str + tornado: str + gthread: str + + +SUPPORTED_WORKERS: _SupportedWorkers From e529ff9135fa1d1dd1b485ad13a631265037b688 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 19:08:41 +0300 Subject: [PATCH 037/102] [gunicorn] Fix handle_request return type annotation --- stubs/gunicorn/gunicorn/workers/ggevent.pyi | 2 +- stubs/gunicorn/gunicorn/workers/sync.pyi | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/ggevent.pyi b/stubs/gunicorn/gunicorn/workers/ggevent.pyi index 6571e5498e0a..2a5af9b671be 100644 --- a/stubs/gunicorn/gunicorn/workers/ggevent.pyi +++ b/stubs/gunicorn/gunicorn/workers/ggevent.pyi @@ -29,7 +29,7 @@ class GeventWorker(AsyncWorker): @override def handle(self, listener: GeventSocket, client: GeventSocket, addr: _AddressType) -> None: ... @override - def handle_request(self, listener_name: str, req: Request, sock: GeventSocket, addr: _AddressType) -> None: ... + def handle_request(self, listener_name: str, req: Request, sock: GeventSocket, addr: _AddressType) -> bool: ... @override def handle_quit(self, sig: int, frame: FrameType | None) -> None: ... @override diff --git a/stubs/gunicorn/gunicorn/workers/sync.pyi b/stubs/gunicorn/gunicorn/workers/sync.pyi index fa6d52402a31..4e58e40ec961 100644 --- a/stubs/gunicorn/gunicorn/workers/sync.pyi +++ b/stubs/gunicorn/gunicorn/workers/sync.pyi @@ -6,8 +6,10 @@ from gunicorn.workers.base import Worker from .._types import _AddressType + class StopWaiting(Exception): ... + class SyncWorker(Worker): def accept(self, listener: socket.socket) -> None: ... def wait(self, timeout: int) -> list[socket.socket | int] | None: ... @@ -17,6 +19,6 @@ class SyncWorker(Worker): @override def run(self) -> None: ... def handle(self, listener: socket.socket, client: socket.socket, addr: _AddressType) -> None: ... - def handle_request(self, listener: socket.socket, req: Request, client: socket.socket, addr: tuple[str, int]) -> None: ... + def handle_request(self, listener: socket.socket, req: Request, client: socket.socket, addr: tuple[str, int]) -> bool: ... @override - def handle_error(self, req: Request, client: socket.socket, addr: _AddressType, exc: BaseException) -> None: ... + def handle_error(self, req: Request | None, client: socket.socket, addr: _AddressType, exc: BaseException) -> None: ... From 5fe6ade0b698470de791187c879cdd97283bfa76 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 19:14:08 +0300 Subject: [PATCH 038/102] [gunicorn] Fix _LogLevelType type in glogging.pyi --- stubs/gunicorn/gunicorn/glogging.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 0e59800b25f1..89a04310684c 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -49,7 +49,7 @@ type _InfoIntType = Annotated[int, "20"] type _DebugIntType = Annotated[int, "10"] type _LogLevelIntType = _CriticalIntType | _ErrorIntType | _WarningIntType | _InfoIntType | _DebugIntType -type _LogLevelStrType = Literal["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"] +type _LogLevelStrType = Literal["critical", "error", "warning", "info", "debug"] type _LogLevelType = _LogLevelIntType | _LogLevelStrType @@ -145,7 +145,7 @@ class Logger: def info(self, msg: str, *args: Any, **kwargs: Any) -> None: ... def debug(self, msg: str, *args: Any, **kwargs: Any) -> None: ... def exception(self, msg: str, *args: Any, **kwargs: Any) -> None: ... - def log(self, lvl: _LogLevelIntType | str, msg: str, *args: Any, **kwargs: Any) -> None: ... + def log(self, lvl: _LogLevelType, msg: str, *args: Any, **kwargs: Any) -> None: ... def atoms(self, resp: Response, req: Request, environ: _EnvironType, request_time: timedelta) -> _AtomsDict: ... def access(self, resp: Response, req: Request, environ: _EnvironType, request_time: timedelta) -> None: ... def now(self) -> str: ... From d1efd5486df2f6bf01d343aa35c3cb7ab97e961d Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 19:17:06 +0300 Subject: [PATCH 039/102] [gunicorn] Update stubs for instrument/statsd.pyi --- stubs/gunicorn/gunicorn/instrument/statsd.pyi | 53 +++++++++++++------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/stubs/gunicorn/gunicorn/instrument/statsd.pyi b/stubs/gunicorn/gunicorn/instrument/statsd.pyi index 75bebebd055f..3364120a1a49 100644 --- a/stubs/gunicorn/gunicorn/instrument/statsd.pyi +++ b/stubs/gunicorn/gunicorn/instrument/statsd.pyi @@ -1,6 +1,14 @@ -from _typeshed import Incomplete +import socket +from datetime import timedelta +from typing import Any, override +from gunicorn.config import Config from gunicorn.glogging import Logger +from gunicorn.http import Request +from gunicorn.http.wsgi import Response + +from .._types import _EnvironType +from ..glogging import _LogLevelType METRIC_VAR: str VALUE_VAR: str @@ -9,20 +17,31 @@ GAUGE_TYPE: str COUNTER_TYPE: str HISTOGRAM_TYPE: str + class Statsd(Logger): - prefix: Incomplete - sock: Incomplete - dogstatsd_tags: Incomplete - def __init__(self, cfg) -> None: ... - def critical(self, msg, *args, **kwargs) -> None: ... - def error(self, msg, *args, **kwargs) -> None: ... - def warning(self, msg, *args, **kwargs) -> None: ... - def exception(self, msg, *args, **kwargs) -> None: ... - def info(self, msg, *args, **kwargs) -> None: ... - def debug(self, msg, *args, **kwargs) -> None: ... - def log(self, lvl, msg, *args, **kwargs) -> None: ... - def access(self, resp, req, environ, request_time) -> None: ... - def gauge(self, name, value) -> None: ... - def increment(self, name, value, sampling_rate: float = 1.0) -> None: ... - def decrement(self, name, value, sampling_rate: float = 1.0) -> None: ... - def histogram(self, name, value) -> None: ... + prefix: str + sock: socket.socket | None + dogstatsd_tags: str | None + cfg: Config + + def __init__(self, cfg: Config) -> None: ... + @override + def critical(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + @override + def error(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + @override + def warning(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + @override + def exception(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + @override + def info(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + @override + def debug(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + @override + def log(self, lvl: _LogLevelType, msg: str, *args: Any, **kwargs: Any) -> None: ... + @override + def access(self, resp: Response, req: Request, environ: _EnvironType, request_time: timedelta) -> None: ... + def gauge(self, name: str, value: float) -> None: ... + def increment(self, name: str, value: int, sampling_rate: float = 1.0) -> None: ... + def decrement(self, name: str, value: int, sampling_rate: float = 1.0) -> None: ... + def histogram(self, name: str, value: float) -> None: ... From b133c64e7d058afb559f3a4a7d0a1c4f24a31a30 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 20:03:48 +0300 Subject: [PATCH 040/102] [gunicorn] Add documentation for _EnvironType in _types.pyi --- stubs/gunicorn/gunicorn/_types.pyi | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index c9300092b93c..b0d75af8a840 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -5,6 +5,68 @@ type _StatusType = str type _HeadersType = list[tuple[str, str]] type _EnvironType = dict[str, Any] +# """ +# WSGI environment dictionary containing request and server information. +# +# Keys and their types: +# - wsgi.version: tuple[int, int] +# WSGI version (e.g., (1, 0)). Required. +# - wsgi.url_scheme: str +# URL scheme (e.g., 'http', 'https'). Required. +# - wsgi.input: io.BytesIO +# Input stream for request body. Required. +# - wsgi.errors: WSGIErrorsWrapper +# Error stream for logging. Required. +# - wsgi.multithread: bool +# Indicates if the server supports multithreading (False in Gunicorn). Required. +# - wsgi.multiprocess: bool +# Indicates if the server supports multiprocessing (based on cfg.workers). Required. +# - wsgi.run_once: bool +# Indicates if the application runs once (False in Gunicorn). Required. +# - wsgi.file_wrapper: type[FileWrapper] +# Type of FileWrapper class for file handling. Required. +# - wsgi.input_terminated: bool +# Indicates if the input stream is terminated (True in Gunicorn). Required. +# - SERVER_SOFTWARE: str +# Server software description. Required. +# - gunicorn.socket: socket.socket +# Socket for the connection. Required. +# - REQUEST_METHOD: str +# HTTP request method (e.g., 'GET', 'POST'). Required. +# - QUERY_STRING: str +# Query string (may be empty). Required. +# - RAW_URI: str +# Raw URI of the request. Required. +# - SERVER_PROTOCOL: str +# HTTP protocol version (e.g., 'HTTP/1.1'). Required. +# - SERVER_NAME: str +# Server name. Required. +# - SERVER_PORT: str +# Server port (may be empty for Unix sockets). Required. +# - PATH_INFO: str +# Request path, excluding SCRIPT_NAME. Required. +# - SCRIPT_NAME: str +# Application path prefix (may be empty). Required. +# - REMOTE_ADDR: str +# Client IP address. Required. +# - REMOTE_PORT: str +# Client port. Optional. +# - CONTENT_TYPE: str +# Content type from request headers. Optional. +# - CONTENT_LENGTH: str +# Content length from request headers. Optional. +# - HTTP_HOST: str +# Host header value. Optional. +# - HTTP_*: str +# Other HTTP headers (e.g., HTTP_ACCEPT, HTTP_USER_AGENT). Optional. +# - PROXY_PROTOCOL: str +# Proxy protocol, if proxy_protocol_info is present. Optional. +# - PROXY_ADDR: str +# Proxy address, if proxy_protocol_info is present. Optional. +# - PROXY_PORT: str +# Proxy port, if proxy_protocol_info is present. Optional. +# """ + type _StartResponseType = Callable[[_StatusType, _HeadersType], None] type _ResponseBodyType = Iterable[bytes] From 6a2ac3c6376e8f61d2c1bdad63d478edc25115d2 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 20:12:40 +0300 Subject: [PATCH 041/102] [gunicorn] Update stubs for http/wsgi.pyi --- stubs/gunicorn/gunicorn/http/wsgi.pyi | 87 +++++++++++++++++---------- 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/stubs/gunicorn/gunicorn/http/wsgi.pyi b/stubs/gunicorn/gunicorn/http/wsgi.pyi index 7464a3735bdf..fd25bb561773 100644 --- a/stubs/gunicorn/gunicorn/http/wsgi.pyi +++ b/stubs/gunicorn/gunicorn/http/wsgi.pyi @@ -1,51 +1,72 @@ import io -from _typeshed import Incomplete +import logging +import re +import socket +from _typeshed import ReadableBuffer +from typing import Any, Callable, override + +from gunicorn.config import Config +from gunicorn.http import Request + +from .._types import _AddressType, _EnvironType, _HeadersType, _StatusType BLKSIZE: int -HEADER_VALUE_RE: Incomplete -log: Incomplete +HEADER_VALUE_RE: re.Pattern[str] +log: logging.Logger class FileWrapper: - filelike: Incomplete - blksize: Incomplete - close: Incomplete - def __init__(self, filelike, blksize: int = 8192) -> None: ... - def __getitem__(self, key): ... + filelike: io.IOBase + blksize: int + close: Callable[[], None] | None + + def __init__(self, filelike: io.IOBase, blksize: int = 8192) -> None: ... + def __getitem__(self, key: Any) -> bytes: ... class WSGIErrorsWrapper(io.RawIOBase): - streams: Incomplete - def __init__(self, cfg) -> None: ... - def write(self, data) -> None: ... + streams: list[io.TextIOBase] -def base_environ(cfg): ... -def default_environ(req, sock, cfg): ... -def proxy_environ(req): ... -def create(req, sock, client, server, cfg): ... + def __init__(self, cfg: Config) -> None: ... + @override + def write(self, data: ReadableBuffer) -> None: ... + +def base_environ(cfg: Config) -> _EnvironType: ... +def default_environ(req: Request, sock: socket.socket, cfg: Config) -> _EnvironType: ... +def proxy_environ(req: Request) -> _EnvironType: ... +def create( + req: Request, + sock: socket.socket, + client: _AddressType, + server: _AddressType, + cfg: Config, +) -> tuple[Response, _EnvironType]: ... class Response: - req: Incomplete - sock: Incomplete - version: Incomplete - status: Incomplete + req: Request + sock: socket.socket + version: str + status: str | None chunked: bool must_close: bool - headers: Incomplete + headers: _HeadersType headers_sent: bool - response_length: Incomplete + response_length: int | None sent: int upgrade: bool - cfg: Incomplete - def __init__(self, req, sock, cfg) -> None: ... + cfg: Config + status_code: int | None + + def __init__(self, req: Request, sock: socket.socket, cfg: Config) -> None: ... def force_close(self) -> None: ... - def should_close(self): ... - status_code: Incomplete - def start_response(self, status, headers, exc_info=None): ... - def process_headers(self, headers) -> None: ... - def is_chunked(self): ... - def default_headers(self): ... + def should_close(self) -> bool: ... + def start_response( + self, status: _StatusType, headers: _HeadersType, exc_info: tuple[type, BaseException, Any] | None = None + ) -> Callable[[bytes], None]: ... + def process_headers(self, headers: _HeadersType) -> None: ... + def is_chunked(self) -> bool: ... + def default_headers(self) -> list[str]: ... def send_headers(self) -> None: ... - def write(self, arg) -> None: ... - def can_sendfile(self): ... - def sendfile(self, respiter): ... - def write_file(self, respiter) -> None: ... + def write(self, arg: bytes) -> None: ... + def can_sendfile(self) -> bool: ... + def sendfile(self, respiter: FileWrapper) -> bool: ... + def write_file(self, respiter: FileWrapper) -> None: ... def close(self) -> None: ... From afd978362636cf6c9a65e465b89f5b7434a0f57c Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 20:18:41 +0300 Subject: [PATCH 042/102] [gunicorn] Refactor: migrate from typing.Type to builtin type annotation excluding config.pyi (because conflict) --- stubs/gunicorn/gunicorn/arbiter.pyi | 3 +-- stubs/gunicorn/gunicorn/util.pyi | 4 ++-- stubs/gunicorn/gunicorn/workers/ggevent.pyi | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/stubs/gunicorn/gunicorn/arbiter.pyi b/stubs/gunicorn/gunicorn/arbiter.pyi index aff752bcaa01..4d9fca207f57 100644 --- a/stubs/gunicorn/gunicorn/arbiter.pyi +++ b/stubs/gunicorn/gunicorn/arbiter.pyi @@ -1,6 +1,5 @@ import socket from types import FrameType -from typing import Type from gunicorn.app.base import BaseApplication from gunicorn.config import Config @@ -31,7 +30,7 @@ class Arbiter: pid: int app: BaseApplication cfg: Config - worker_class: Type[Worker] + worker_class: type[Worker] address: list[_AddressType] timeout: int proc_name: str diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index fcf6db5920bb..65084aa3e993 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -2,7 +2,7 @@ import types from _typeshed import FileDescriptorLike, FileDescriptorOrPath, HasFileno, StrOrBytesPath from inspect import _ParameterKind from socket import socket -from typing import Any, Callable, Literal, NoReturn, Type +from typing import Any, Callable, Literal, NoReturn from urllib.parse import SplitResult from ._types import _AddressType, _WSGIAppType @@ -16,7 +16,7 @@ def load_class( uri: str | object, default: str = "gunicorn.workers.sync.SyncWorker", section: str = "gunicorn.workers", -) -> Type[Any]: ... +) -> type[Any]: ... positionals: tuple[ diff --git a/stubs/gunicorn/gunicorn/workers/ggevent.pyi b/stubs/gunicorn/gunicorn/workers/ggevent.pyi index 2a5af9b671be..407f1bcbaab7 100644 --- a/stubs/gunicorn/gunicorn/workers/ggevent.pyi +++ b/stubs/gunicorn/gunicorn/workers/ggevent.pyi @@ -1,5 +1,5 @@ from types import FrameType -from typing import Any, Type +from typing import Any from typing_extensions import override from gevent import pywsgi @@ -15,8 +15,8 @@ VERSION: str class GeventWorker(AsyncWorker): - server_class: Type[StreamServer] | None - wsgi_handler: Type[WSGIHandler] | None + server_class: type[StreamServer] | None + wsgi_handler: type[WSGIHandler] | None sockets: list[GeventSocket] def patch(self) -> None: ... @@ -55,5 +55,5 @@ class PyWSGIServer(pywsgi.WSGIServer): ... class GeventPyWSGIWorker(GeventWorker): - server_class: Type[PyWSGIServer] | None - wsgi_handler: Type[PyWSGIHandler] | None + server_class: type[PyWSGIServer] | None + wsgi_handler: type[PyWSGIHandler] | None From 157a62c3589af046891a05778f79746d8b51272c Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 20:20:49 +0300 Subject: [PATCH 043/102] [gunicorn] Update stubs for http/unreader.pyi --- stubs/gunicorn/gunicorn/http/unreader.pyi | 36 +++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/stubs/gunicorn/gunicorn/http/unreader.pyi b/stubs/gunicorn/gunicorn/http/unreader.pyi index 3a3af3b495d0..ee848c099929 100644 --- a/stubs/gunicorn/gunicorn/http/unreader.pyi +++ b/stubs/gunicorn/gunicorn/http/unreader.pyi @@ -1,19 +1,31 @@ -from _typeshed import Incomplete +import io +import socket +from _typeshed import ReadableBuffer +from collections.abc import Iterable, Iterator +from typing_extensions import override + class Unreader: - buf: Incomplete + buf: io.BytesIO + def __init__(self) -> None: ... - def chunk(self) -> None: ... - def read(self, size=None): ... - def unread(self, data) -> None: ... + def chunk(self) -> bytes: ... + def read(self, size: int | None = None) -> bytes: ... + def unread(self, data: ReadableBuffer) -> None: ... + class SocketUnreader(Unreader): - sock: Incomplete - mxchunk: Incomplete - def __init__(self, sock, max_chunk: int = 8192) -> None: ... - def chunk(self): ... + sock: socket.socket + mxchunk: int + + def __init__(self, sock: socket.socket, max_chunk: int = 8192) -> None: ... + @override + def chunk(self) -> bytes: ... + class IterUnreader(Unreader): - iter: Incomplete - def __init__(self, iterable) -> None: ... - def chunk(self): ... + iter: Iterator[bytes] | None + + def __init__(self, iterable: Iterable[bytes]) -> None: ... + @override + def chunk(self) -> bytes: ... From 800d7101732b9478af79f4f4d8c358e0b2ea5f1c Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 20:29:56 +0300 Subject: [PATCH 044/102] [gunicorn] Update stubs for http/parser.pyi --- stubs/gunicorn/gunicorn/http/parser.pyi | 31 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/stubs/gunicorn/gunicorn/http/parser.pyi b/stubs/gunicorn/gunicorn/http/parser.pyi index 7e5293d4200a..3a5cfb4701c1 100644 --- a/stubs/gunicorn/gunicorn/http/parser.pyi +++ b/stubs/gunicorn/gunicorn/http/parser.pyi @@ -1,18 +1,27 @@ -from _typeshed import Incomplete +import socket +from collections.abc import Callable, Iterable, Iterator +from gunicorn.config import Config from gunicorn.http.message import Request +from gunicorn.http.unreader import Unreader + +from .._types import _AddressType + class Parser: - mesg_class: Incomplete - cfg: Incomplete - unreader: Incomplete - mesg: Incomplete - source_addr: Incomplete + mesg_class: type[Request] | None + cfg: Config + unreader: Unreader + mesg: Request | None + source_addr: _AddressType req_count: int - def __init__(self, cfg, source, source_addr) -> None: ... - def __iter__(self): ... - def __next__(self): ... - next = __next__ + + def __init__(self, cfg: Config, source: socket.socket | Iterable[bytes], source_addr: _AddressType) -> None: ... + def __iter__(self) -> Iterator[Request]: ... + def __next__(self) -> Request: ... + + next: Callable[[Parser], Request] + class RequestParser(Parser): - mesg_class = Request + mesg_class: type[Request] From a50e7b7f520491fa84543e28e09675a217390740 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 20:35:46 +0300 Subject: [PATCH 045/102] [gunicorn] Update stubs for http/message.pyi --- stubs/gunicorn/gunicorn/http/message.pyi | 89 +++++++++++++----------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/stubs/gunicorn/gunicorn/http/message.pyi b/stubs/gunicorn/gunicorn/http/message.pyi index af3d14c1335a..5cae21375e66 100644 --- a/stubs/gunicorn/gunicorn/http/message.pyi +++ b/stubs/gunicorn/gunicorn/http/message.pyi @@ -1,53 +1,64 @@ -from _typeshed import Incomplete +import io +import re +from typing_extensions import override + +from gunicorn.config import Config +from gunicorn.http.body import Body +from gunicorn.http.unreader import Unreader + +from .._types import _AddressType MAX_REQUEST_LINE: int MAX_HEADERS: int DEFAULT_MAX_HEADERFIELD_SIZE: int RFC9110_5_6_2_TOKEN_SPECIALS: str -TOKEN_RE: Incomplete -METHOD_BADCHAR_RE: Incomplete -VERSION_RE: Incomplete -RFC9110_5_5_INVALID_AND_DANGEROUS: Incomplete +TOKEN_RE: re.Pattern[str] +METHOD_BADCHAR_RE: re.Pattern[str] +VERSION_RE: re.Pattern[str] +RFC9110_5_5_INVALID_AND_DANGEROUS: re.Pattern[str] + class Message: - cfg: Incomplete - unreader: Incomplete - peer_addr: Incomplete - remote_addr: Incomplete - version: Incomplete - headers: Incomplete - trailers: Incomplete - body: Incomplete - scheme: Incomplete + cfg: Config + unreader: Unreader + peer_addr: _AddressType + remote_addr: _AddressType + version: tuple[int, int] | None + headers: list[tuple[str, str]] + trailers: list[tuple[str, str]] + body: Body | None + scheme: str must_close: bool - limit_request_fields: Incomplete - limit_request_field_size: Incomplete - max_buffer_headers: Incomplete - def __init__(self, cfg, unreader, peer_addr) -> None: ... + limit_request_fields: int + limit_request_field_size: int + max_buffer_headers: int + + def __init__(self, cfg: Config, unreader: Unreader, peer_addr: _AddressType) -> None: ... def force_close(self) -> None: ... - def parse(self, unreader) -> None: ... - def parse_headers(self, data, from_trailer: bool = False): ... + def parse(self, unreader: Unreader) -> bytes: ... + def parse_headers(self, data: bytes, from_trailer: bool = False) -> list[tuple[str, str]]: ... def set_body_reader(self) -> None: ... - def should_close(self): ... + def should_close(self) -> bool: ... + class Request(Message): - method: Incomplete - uri: Incomplete - path: Incomplete - query: Incomplete - fragment: Incomplete - limit_request_line: Incomplete - req_number: Incomplete - proxy_protocol_info: Incomplete - def __init__(self, cfg, unreader, peer_addr, req_number: int = 1) -> None: ... - def get_data(self, unreader, buf, stop: bool = False) -> None: ... - headers: Incomplete - def parse(self, unreader): ... - def read_line(self, unreader, buf, limit: int = 0): ... - def proxy_protocol(self, line): ... + method: str | None + uri: str | None + path: str | None + query: str | None + fragment: str | None + limit_request_line: int + req_number: int + proxy_protocol_info: dict[str, str | int] | None + + def __init__(self, cfg: Config, unreader: Unreader, peer_addr: _AddressType, req_number: int = 1) -> None: ... + def get_data(self, unreader: Unreader, buf: io.BytesIO, stop: bool = False) -> None: ... + @override + def parse(self, unreader: Unreader) -> bytes: ... + def read_line(self, unreader: Unreader, buf: io.BytesIO, limit: int = 0) -> tuple[bytes, bytes]: ... + def proxy_protocol(self, line: str) -> bool: ... def proxy_protocol_access_check(self) -> None: ... - def parse_proxy_protocol(self, line) -> None: ... - version: Incomplete - def parse_request_line(self, line_bytes) -> None: ... - body: Incomplete + def parse_proxy_protocol(self, line: str) -> None: ... + def parse_request_line(self, line_bytes: bytes) -> None: ... + @override def set_body_reader(self) -> None: ... From 63b2fd0ca6f9721620a84dc9747f3e25ae64f254 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 20:46:18 +0300 Subject: [PATCH 046/102] [gunicorn] Update stubs for http/errors.pyi --- stubs/gunicorn/gunicorn/http/errors.pyi | 100 ++++++++++++++++-------- 1 file changed, 67 insertions(+), 33 deletions(-) diff --git a/stubs/gunicorn/gunicorn/http/errors.pyi b/stubs/gunicorn/gunicorn/http/errors.pyi index 2530c678292b..6d913a71b70f 100644 --- a/stubs/gunicorn/gunicorn/http/errors.pyi +++ b/stubs/gunicorn/gunicorn/http/errors.pyi @@ -1,72 +1,106 @@ -from _typeshed import Incomplete +from collections.abc import Buffer + +from gunicorn.http import Message + class ParseException(Exception): ... + class NoMoreData(IOError): - buf: Incomplete - def __init__(self, buf=None) -> None: ... + buf: Buffer + + def __init__(self, buf: Buffer | None = None) -> None: ... + class ConfigurationProblem(ParseException): - info: Incomplete + info: str code: int - def __init__(self, info) -> None: ... + + def __init__(self, info: str) -> None: ... + class InvalidRequestLine(ParseException): - req: Incomplete + req: str code: int - def __init__(self, req) -> None: ... + + def __init__(self, req: str) -> None: ... + class InvalidRequestMethod(ParseException): - method: Incomplete - def __init__(self, method) -> None: ... + method: str + + def __init__(self, method: str) -> None: ... + class InvalidHTTPVersion(ParseException): - version: Incomplete - def __init__(self, version) -> None: ... + version: str | tuple[int, int] + + def __init__(self, version: str | tuple[int, int]) -> None: ... + class InvalidHeader(ParseException): - hdr: Incomplete - req: Incomplete - def __init__(self, hdr, req=None) -> None: ... + hdr: str + req: Message | None + + def __init__(self, hdr: str, req: Message | None = None) -> None: ... + class ObsoleteFolding(ParseException): - hdr: Incomplete - def __init__(self, hdr) -> None: ... + hdr: str + + def __init__(self, hdr: str) -> None: ... + class InvalidHeaderName(ParseException): - hdr: Incomplete - def __init__(self, hdr) -> None: ... + hdr: str + + def __init__(self, hdr: str) -> None: ... + class UnsupportedTransferCoding(ParseException): - hdr: Incomplete + hdr: str code: int - def __init__(self, hdr) -> None: ... + + def __init__(self, hdr: str) -> None: ... + class InvalidChunkSize(IOError): - data: Incomplete - def __init__(self, data) -> None: ... + data: bytes + + def __init__(self, data: bytes) -> None: ... + class ChunkMissingTerminator(IOError): - term: Incomplete - def __init__(self, term) -> None: ... + term: bytes + + def __init__(self, term: bytes) -> None: ... + class LimitRequestLine(ParseException): - size: Incomplete - max_size: Incomplete - def __init__(self, size, max_size) -> None: ... + size: int + max_size: int + + def __init__(self, size: int, max_size: int) -> None: ... + class LimitRequestHeaders(ParseException): - msg: Incomplete - def __init__(self, msg) -> None: ... + msg: str + + def __init__(self, msg: str) -> None: ... + class InvalidProxyLine(ParseException): - line: Incomplete + line: str code: int - def __init__(self, line) -> None: ... + + def __init__(self, line: str) -> None: ... + class ForbiddenProxyRequest(ParseException): - host: Incomplete + host: str code: int - def __init__(self, host) -> None: ... + + def __init__(self, host: str) -> None: ... + class InvalidSchemeHeaders(ParseException): ... From 1c855644c51d108384cfb53d144ad4cc0174bdfd Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 22:40:09 +0300 Subject: [PATCH 047/102] [gunicorn] Update stubs for http/body.pyi --- stubs/gunicorn/gunicorn/http/body.pyi | 68 +++++++++++++++------------ 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/stubs/gunicorn/gunicorn/http/body.pyi b/stubs/gunicorn/gunicorn/http/body.pyi index be377e01638d..56d742347bea 100644 --- a/stubs/gunicorn/gunicorn/http/body.pyi +++ b/stubs/gunicorn/gunicorn/http/body.pyi @@ -1,38 +1,48 @@ -from _typeshed import Incomplete -from collections.abc import Generator +import io +from collections.abc import Generator, Iterable +from typing import Callable + +from gunicorn.http.message import Request +from gunicorn.http.unreader import Unreader class ChunkedReader: - req: Incomplete - parser: Incomplete - buf: Incomplete - def __init__(self, req, unreader) -> None: ... - def read(self, size): ... - def parse_trailers(self, unreader, data): ... - def parse_chunked(self, unreader) -> Generator[Incomplete]: ... - def parse_chunk_size(self, unreader, data=None): ... - def get_data(self, unreader, buf) -> None: ... + req: Request + parser: Generator[bytes, None, None] | None + buf: io.BytesIO + + def __init__(self, req: Request, unreader: Unreader) -> None: ... + def read(self, size: int) -> bytes: ... + def parse_trailers(self, unreader: Unreader, data: bytes) -> None: ... + def parse_chunked(self, unreader: Unreader) -> Generator[bytes, None, None]: ... + def parse_chunk_size(self, unreader: Unreader, data: bytes | None = None) -> tuple[int, bytes | None]: ... + def get_data(self, unreader: Unreader, buf: io.BytesIO) -> None: ... class LengthReader: - unreader: Incomplete - length: Incomplete - def __init__(self, unreader, length) -> None: ... - def read(self, size): ... + unreader: Unreader + length: int + + def __init__(self, unreader: Unreader, length: int) -> None: ... + def read(self, size: int) -> bytes: ... class EOFReader: - unreader: Incomplete - buf: Incomplete + unreader: Unreader + buf: io.BytesIO finished: bool - def __init__(self, unreader) -> None: ... - def read(self, size): ... + + def __init__(self, unreader: Unreader) -> None: ... + def read(self, size: int) -> bytes: ... + +type _ReaderType = ChunkedReader | LengthReader | EOFReader class Body: - reader: Incomplete - buf: Incomplete - def __init__(self, reader) -> None: ... - def __iter__(self): ... - def __next__(self): ... - next = __next__ - def getsize(self, size): ... - def read(self, size=None): ... - def readline(self, size=None): ... - def readlines(self, size=None): ... + reader: _ReaderType + buf: io.BytesIO + + def __init__(self, reader: _ReaderType) -> None: ... + def __iter__(self) -> Iterable[bytes]: ... + def __next__(self) -> bytes: ... + next: Callable[[Body], bytes] + def getsize(self, size: int | None) -> int: ... + def read(self, size: int | None = None) -> bytes: ... + def readline(self, size: int | None = None) -> bytes: ... + def readlines(self, size: int | None = None) -> list[bytes]: ... From d3cb24503fc84c10d28194b7d25245eb9d670b87 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 23:05:33 +0300 Subject: [PATCH 048/102] [gunicorn] Add _ASGIAppType in _types.pyi --- stubs/gunicorn/gunicorn/_types.pyi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index b0d75af8a840..1ba450645926 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -1,4 +1,4 @@ -from collections.abc import Iterable +from collections.abc import Awaitable, Iterable from typing import Any, Callable, LiteralString type _StatusType = str @@ -72,6 +72,11 @@ type _ResponseBodyType = Iterable[bytes] type _WSGIAppType = Callable[[_EnvironType, _StartResponseType], _ResponseBodyType] +type _ScopeType = dict[str, Any] +type _ReceiveType = Callable[[], Awaitable[dict[str, Any]]] +type _SendType = Callable[[dict[str, Any]], Awaitable[None]] +type _ASGIAppType = Callable[[_ScopeType, _ReceiveType, _SendType], Awaitable[None]] + type _UnixSocketPathType = str type _FileDescriptorType = int type _TcpAddressType = tuple[LiteralString, int] From 5c323bd698388061cff5f8a056f3f1de0070e746 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 23:08:28 +0300 Subject: [PATCH 049/102] [gunicorn] Update stubs for app/base.pyi --- stubs/gunicorn/gunicorn/app/base.pyi | 47 +++++++++++++++++++--------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/stubs/gunicorn/gunicorn/app/base.pyi b/stubs/gunicorn/gunicorn/app/base.pyi index 51618342e8da..8dbc4c83ad6a 100644 --- a/stubs/gunicorn/gunicorn/app/base.pyi +++ b/stubs/gunicorn/gunicorn/app/base.pyi @@ -1,26 +1,45 @@ -from _typeshed import Incomplete +from argparse import ArgumentParser, Namespace +from collections.abc import Awaitable, Callable, Iterable +from typing import Any, override + +from gunicorn.config import Config +from gunicorn.glogging import Logger as GLogger + +type _EnvironType = dict[str, Any] +type _StartResponseType = Callable[[str, list[tuple[str, str]]], None] +type _ResponseBodyType = Iterable[bytes] +type _WSGIAppType = Callable[[_EnvironType, _StartResponseType], _ResponseBodyType] +type _ScopeType = dict[str, Any] +type _ReceiveType = Callable[[], Awaitable[dict[str, Any]]] +type _SendType = Callable[[dict[str, Any]], Awaitable[None]] +type _ASGIAppType = Callable[[_ScopeType, _ReceiveType, _SendType], Awaitable[None]] + class BaseApplication: - usage: Incomplete - cfg: Incomplete - callable: Incomplete - prog: Incomplete - logger: Incomplete - def __init__(self, usage=None, prog=None) -> None: ... + usage: str | None + cfg: Config + callable: _WSGIAppType | _ASGIAppType | None + prog: str | None + logger: GLogger + + def __init__(self, usage: str | None = None, prog: str | None = None) -> None: ... def do_load_config(self) -> None: ... def load_default_config(self) -> None: ... - def init(self, parser, opts, args) -> None: ... - def load(self) -> None: ... + def init(self, parser: ArgumentParser, opts: Namespace, args: list[str]) -> dict[str, Any] | None: ... + def load(self) -> _WSGIAppType | _ASGIAppType: ... def load_config(self) -> None: ... def reload(self) -> None: ... - def wsgi(self): ... + def wsgi(self) -> _WSGIAppType | _ASGIAppType: ... def run(self) -> None: ... + class Application(BaseApplication): def chdir(self) -> None: ... - def get_config_from_filename(self, filename): ... - def get_config_from_module_name(self, module_name): ... - def load_config_from_module_name_or_filename(self, location): ... - def load_config_from_file(self, filename): ... + def get_config_from_filename(self, filename: str) -> dict[str, Any]: ... + def get_config_from_module_name(self, module_name: str) -> dict[str, Any]: ... + def load_config_from_module_name_or_filename(self, location: str) -> dict[str, Any]: ... + def load_config_from_file(self, filename: str) -> dict[str, Any]: ... + @override def load_config(self) -> None: ... + @override def run(self) -> None: ... From a10038bc662301caac338e8f95995020af5e6ae0 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 23:19:32 +0300 Subject: [PATCH 050/102] [gunicorn] Update stubs for app/pasterapp.pyi --- stubs/gunicorn/gunicorn/app/pasterapp.pyi | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/stubs/gunicorn/gunicorn/app/pasterapp.pyi b/stubs/gunicorn/gunicorn/app/pasterapp.pyi index d0a2876277e1..4fafa91df013 100644 --- a/stubs/gunicorn/gunicorn/app/pasterapp.pyi +++ b/stubs/gunicorn/gunicorn/app/pasterapp.pyi @@ -1,3 +1,8 @@ -def get_wsgi_app(config_uri, name=None, defaults=None): ... -def has_logging_config(config_file): ... -def serve(app, global_conf, **local_conf): ... +from typing import Any + +from .._types import _WSGIAppType + + +def get_wsgi_app(config_uri: str, name: str | None = None, defaults: dict[str, Any] | None = None) -> _WSGIAppType: ... +def has_logging_config(config_file: str) -> bool: ... +def serve(app: _WSGIAppType, global_conf: dict[str, Any], **local_conf: Any) -> None: ... From 1f73313aa28e90047ac42b34df6dfbe6a4489fa6 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 23:19:40 +0300 Subject: [PATCH 051/102] [gunicorn] Update stubs for app/wsgiapp.pyi --- stubs/gunicorn/gunicorn/app/wsgiapp.pyi | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/stubs/gunicorn/gunicorn/app/wsgiapp.pyi b/stubs/gunicorn/gunicorn/app/wsgiapp.pyi index 9d8b7a06f9e2..b0eb06ff3387 100644 --- a/stubs/gunicorn/gunicorn/app/wsgiapp.pyi +++ b/stubs/gunicorn/gunicorn/app/wsgiapp.pyi @@ -1,13 +1,22 @@ -from _typeshed import Incomplete +from argparse import ArgumentParser, Namespace +from typing import override from gunicorn.app.base import Application +from .._types import _WSGIAppType + + class WSGIApplication(Application): - app_uri: Incomplete - def init(self, parser, opts, args) -> None: ... + app_uri: str | None + + @override + def init(self, parser: ArgumentParser, opts: Namespace, args: list[str]) -> None: ... + @override def load_config(self) -> None: ... - def load_wsgiapp(self): ... - def load_pasteapp(self): ... - def load(self): ... + def load_wsgiapp(self) -> _WSGIAppType: ... + def load_pasteapp(self) -> _WSGIAppType: ... + @override + def load(self) -> _WSGIAppType: ... + -def run(prog=None) -> None: ... +def run(prog: str | None = None) -> None: ... From 0aa6efd5bdc4f1a53f01dbbf267db6cb4e4b06a4 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 23:37:24 +0300 Subject: [PATCH 052/102] [gunicorn] Add stubtest_allowlist.txt --- stubs/gunicorn/@tests/stubtest_allowlist.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 stubs/gunicorn/@tests/stubtest_allowlist.txt diff --git a/stubs/gunicorn/@tests/stubtest_allowlist.txt b/stubs/gunicorn/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000000..ac02eb7acc3d --- /dev/null +++ b/stubs/gunicorn/@tests/stubtest_allowlist.txt @@ -0,0 +1,4 @@ +# Helper +gunicorn._types + +gunicorn.__main__ From d7235652eed885c9db7aca4e34cb3a694d371220 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 23:40:32 +0300 Subject: [PATCH 053/102] [gunicorn] Add return type annotation for is_already_handled function --- stubs/gunicorn/gunicorn/workers/base_async.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/workers/base_async.pyi b/stubs/gunicorn/gunicorn/workers/base_async.pyi index 1ba05fc14dee..9d6810dc6788 100644 --- a/stubs/gunicorn/gunicorn/workers/base_async.pyi +++ b/stubs/gunicorn/gunicorn/workers/base_async.pyi @@ -8,12 +8,13 @@ from .._types import _AddressType ALREADY_HANDLED: object + class AsyncWorker(base.Worker): worker_connections: int alive: bool def __init__(self, *args: Any, **kwargs: Any) -> None: ... def timeout_ctx(self) -> None: ... - def is_already_handled(self, respiter: Any): ... + def is_already_handled(self, respiter: Any) -> bool: ... def handle(self, listener: socket.socket, client: socket.socket, addr: _AddressType) -> None: ... def handle_request(self, listener_name: str, req: Request, sock: socket.socket, addr: _AddressType) -> bool: ... From aff785be2600799a907315cdf21d51a88f6ca980 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 23:41:06 +0300 Subject: [PATCH 054/102] [gunicorn] Add 'args', 'kwargs' type annotation for __init__ function --- stubs/gunicorn/gunicorn/workers/gthread.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/workers/gthread.pyi b/stubs/gunicorn/gunicorn/workers/gthread.pyi index f56489d08090..d003b1539887 100644 --- a/stubs/gunicorn/gunicorn/workers/gthread.pyi +++ b/stubs/gunicorn/gunicorn/workers/gthread.pyi @@ -3,6 +3,7 @@ from _typeshed import Incomplete from concurrent.futures import ThreadPoolExecutor from selectors import DefaultSelector from types import FrameType +from typing import Any from gunicorn.config import Config from gunicorn.glogging import Logger as GLogger @@ -36,7 +37,7 @@ class ThreadWorker(base.Worker): nr_conns: int alive: bool - def __init__(self, *args, **kwargs) -> None: ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... @classmethod def check_config(cls, cfg: Config, log: GLogger) -> None: ... def init_process(self) -> None: ... From a74424e53e086e2901c88f7fc3a33e1cc40ad5c0 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Tue, 9 Sep 2025 23:43:11 +0300 Subject: [PATCH 055/102] [gunicorn] run script 'pre-commit run --all-files' --- stubs/gunicorn/gunicorn/app/base.pyi | 2 - stubs/gunicorn/gunicorn/app/pasterapp.pyi | 1 - stubs/gunicorn/gunicorn/app/wsgiapp.pyi | 2 - stubs/gunicorn/gunicorn/arbiter.pyi | 1 - stubs/gunicorn/gunicorn/config.pyi | 98 ------------------- stubs/gunicorn/gunicorn/debug.pyi | 2 - stubs/gunicorn/gunicorn/errors.pyi | 3 - stubs/gunicorn/gunicorn/glogging.pyi | 15 --- stubs/gunicorn/gunicorn/http/errors.pyi | 17 ---- stubs/gunicorn/gunicorn/http/message.pyi | 2 - stubs/gunicorn/gunicorn/http/parser.pyi | 2 - stubs/gunicorn/gunicorn/http/unreader.pyi | 3 - stubs/gunicorn/gunicorn/http/wsgi.pyi | 6 +- stubs/gunicorn/gunicorn/instrument/statsd.pyi | 1 - stubs/gunicorn/gunicorn/pidfile.pyi | 1 - stubs/gunicorn/gunicorn/reloader.pyi | 17 +--- stubs/gunicorn/gunicorn/sock.pyi | 5 - stubs/gunicorn/gunicorn/systemd.pyi | 1 - stubs/gunicorn/gunicorn/util.pyi | 18 +--- stubs/gunicorn/gunicorn/workers/__init__.pyi | 2 - stubs/gunicorn/gunicorn/workers/base.pyi | 10 +- .../gunicorn/gunicorn/workers/base_async.pyi | 1 - stubs/gunicorn/gunicorn/workers/geventlet.pyi | 2 - stubs/gunicorn/gunicorn/workers/ggevent.pyi | 5 - stubs/gunicorn/gunicorn/workers/gthread.pyi | 2 - stubs/gunicorn/gunicorn/workers/gtornado.pyi | 1 - stubs/gunicorn/gunicorn/workers/sync.pyi | 2 - stubs/gunicorn/gunicorn/workers/workertmp.pyi | 1 - 28 files changed, 7 insertions(+), 216 deletions(-) diff --git a/stubs/gunicorn/gunicorn/app/base.pyi b/stubs/gunicorn/gunicorn/app/base.pyi index 8dbc4c83ad6a..188850f4b114 100644 --- a/stubs/gunicorn/gunicorn/app/base.pyi +++ b/stubs/gunicorn/gunicorn/app/base.pyi @@ -14,7 +14,6 @@ type _ReceiveType = Callable[[], Awaitable[dict[str, Any]]] type _SendType = Callable[[dict[str, Any]], Awaitable[None]] type _ASGIAppType = Callable[[_ScopeType, _ReceiveType, _SendType], Awaitable[None]] - class BaseApplication: usage: str | None cfg: Config @@ -32,7 +31,6 @@ class BaseApplication: def wsgi(self) -> _WSGIAppType | _ASGIAppType: ... def run(self) -> None: ... - class Application(BaseApplication): def chdir(self) -> None: ... def get_config_from_filename(self, filename: str) -> dict[str, Any]: ... diff --git a/stubs/gunicorn/gunicorn/app/pasterapp.pyi b/stubs/gunicorn/gunicorn/app/pasterapp.pyi index 4fafa91df013..ab94b4872f49 100644 --- a/stubs/gunicorn/gunicorn/app/pasterapp.pyi +++ b/stubs/gunicorn/gunicorn/app/pasterapp.pyi @@ -2,7 +2,6 @@ from typing import Any from .._types import _WSGIAppType - def get_wsgi_app(config_uri: str, name: str | None = None, defaults: dict[str, Any] | None = None) -> _WSGIAppType: ... def has_logging_config(config_file: str) -> bool: ... def serve(app: _WSGIAppType, global_conf: dict[str, Any], **local_conf: Any) -> None: ... diff --git a/stubs/gunicorn/gunicorn/app/wsgiapp.pyi b/stubs/gunicorn/gunicorn/app/wsgiapp.pyi index b0eb06ff3387..60a94ac865cc 100644 --- a/stubs/gunicorn/gunicorn/app/wsgiapp.pyi +++ b/stubs/gunicorn/gunicorn/app/wsgiapp.pyi @@ -5,7 +5,6 @@ from gunicorn.app.base import Application from .._types import _WSGIAppType - class WSGIApplication(Application): app_uri: str | None @@ -18,5 +17,4 @@ class WSGIApplication(Application): @override def load(self) -> _WSGIAppType: ... - def run(prog: str | None = None) -> None: ... diff --git a/stubs/gunicorn/gunicorn/arbiter.pyi b/stubs/gunicorn/gunicorn/arbiter.pyi index 4d9fca207f57..bb6a192c88e4 100644 --- a/stubs/gunicorn/gunicorn/arbiter.pyi +++ b/stubs/gunicorn/gunicorn/arbiter.pyi @@ -9,7 +9,6 @@ from gunicorn.workers.base import Worker from ._types import _AddressType from .pidfile import Pidfile - class Arbiter: WORKER_BOOT_ERROR: int APP_LOAD_ERROR: int diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index f7421d6db1a4..a9762f110c2a 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -41,11 +41,9 @@ type _AddressValidatorType = Callable[[str | None], _AddressType | None] KNOWN_SETTINGS: list[Setting] PLATFORM: str - def make_settings(ignore: Container[Setting] | None = None) -> dict[str, Setting]: ... def auto_int(_: Any, x: str) -> int: ... - class Config: settings: dict[str, Setting] usage: str | None @@ -86,12 +84,10 @@ class Config: @property def paste_global_conf(self) -> dict[str, str] | None: ... - class SettingMeta(type): def __new__(cls, name: str, bases: tuple[type, ...], attrs: dict[str, Any]) -> type: ... def fmt_desc(cls, desc: str) -> None: ... - class Setting(metaclass=SettingMeta): name: str | None value: Any @@ -117,7 +113,6 @@ class Setting(metaclass=SettingMeta): __cmp__ = __lt__ - @overload def validate_bool(val: bool) -> bool: ... @overload @@ -166,7 +161,6 @@ def validate_header_map_behaviour(val: str) -> str: ... def validate_header_map_behaviour(val: None) -> None: ... def get_default_config_file() -> str | None: ... - class ConfigFile(Setting): name: str section: str @@ -176,7 +170,6 @@ class ConfigFile(Setting): default: str desc: str - class WSGIApp(Setting): name: str section: str @@ -185,7 +178,6 @@ class WSGIApp(Setting): default: None desc: str - class Bind(Setting): name: str action: str @@ -196,7 +188,6 @@ class Bind(Setting): default: list[str] desc: str - class Backlog(Setting): name: str section: str @@ -207,7 +198,6 @@ class Backlog(Setting): default: int desc: str - class Workers(Setting): name: str section: str @@ -218,7 +208,6 @@ class Workers(Setting): default: int desc: str - class WorkerClass(Setting): name: str section: str @@ -228,7 +217,6 @@ class WorkerClass(Setting): default: str desc: str - class WorkerThreads(Setting): name: str section: str @@ -239,7 +227,6 @@ class WorkerThreads(Setting): default: int desc: str - class WorkerConnections(Setting): name: str section: str @@ -250,7 +237,6 @@ class WorkerConnections(Setting): default: int desc: str - class MaxRequests(Setting): name: str section: str @@ -261,7 +247,6 @@ class MaxRequests(Setting): default: int desc: str - class MaxRequestsJitter(Setting): name: str section: str @@ -272,7 +257,6 @@ class MaxRequestsJitter(Setting): default: int desc: str - class Timeout(Setting): name: str section: str @@ -283,7 +267,6 @@ class Timeout(Setting): default: int desc: str - class GracefulTimeout(Setting): name: str section: str @@ -294,7 +277,6 @@ class GracefulTimeout(Setting): default: int desc: str - class Keepalive(Setting): name: str section: str @@ -305,7 +287,6 @@ class Keepalive(Setting): default: int desc: str - class LimitRequestLine(Setting): name: str section: str @@ -316,7 +297,6 @@ class LimitRequestLine(Setting): default: int desc: str - class LimitRequestFields(Setting): name: str section: str @@ -327,7 +307,6 @@ class LimitRequestFields(Setting): default: int desc: str - class LimitRequestFieldSize(Setting): name: str section: str @@ -338,7 +317,6 @@ class LimitRequestFieldSize(Setting): default: int desc: str - class Reload(Setting): name: str section: str @@ -348,7 +326,6 @@ class Reload(Setting): default: bool desc: str - class ReloadEngine(Setting): name: str section: str @@ -358,7 +335,6 @@ class ReloadEngine(Setting): default: str desc: str - class ReloadExtraFiles(Setting): name: str action: str @@ -369,7 +345,6 @@ class ReloadExtraFiles(Setting): default: list[str] desc: str - class Spew(Setting): name: str section: str @@ -379,7 +354,6 @@ class Spew(Setting): default: bool desc: str - class ConfigCheck(Setting): name: str section: str @@ -389,7 +363,6 @@ class ConfigCheck(Setting): default: bool desc: str - class PrintConfig(Setting): name: str section: str @@ -399,7 +372,6 @@ class PrintConfig(Setting): default: bool desc: str - class PreloadApp(Setting): name: str section: str @@ -409,7 +381,6 @@ class PreloadApp(Setting): default: bool desc: str - class Sendfile(Setting): name: str section: str @@ -419,7 +390,6 @@ class Sendfile(Setting): const: bool desc: str - class ReusePort(Setting): name: str section: str @@ -429,7 +399,6 @@ class ReusePort(Setting): default: bool desc: str - class Chdir(Setting): name: str section: str @@ -439,7 +408,6 @@ class Chdir(Setting): default_doc: str desc: str - class Daemon(Setting): name: str section: str @@ -449,7 +417,6 @@ class Daemon(Setting): default: bool desc: str - class Env(Setting): name: str action: str @@ -460,7 +427,6 @@ class Env(Setting): default: list[str] desc: str - class Pidfile(Setting): name: str section: str @@ -470,7 +436,6 @@ class Pidfile(Setting): default: None desc: str - class WorkerTmpDir(Setting): name: str section: str @@ -480,7 +445,6 @@ class WorkerTmpDir(Setting): default: None desc: str - class User(Setting): name: str section: str @@ -491,7 +455,6 @@ class User(Setting): default_doc: str desc: str - class Group(Setting): name: str section: str @@ -502,7 +465,6 @@ class Group(Setting): default_doc: str desc: str - class Umask(Setting): name: str section: str @@ -513,7 +475,6 @@ class Umask(Setting): default: int desc: str - class Initgroups(Setting): name: str section: str @@ -523,7 +484,6 @@ class Initgroups(Setting): default: bool desc: str - class TmpUploadDir(Setting): name: str section: str @@ -532,7 +492,6 @@ class TmpUploadDir(Setting): default: None desc: str - class SecureSchemeHeader(Setting): name: str section: str @@ -540,7 +499,6 @@ class SecureSchemeHeader(Setting): default: dict[str, str] desc: str - class ForwardedAllowIPS(Setting): name: str section: str @@ -550,7 +508,6 @@ class ForwardedAllowIPS(Setting): default: str desc: str - class AccessLog(Setting): name: str section: str @@ -560,7 +517,6 @@ class AccessLog(Setting): default: None desc: str - class DisableRedirectAccessToSyslog(Setting): name: str section: str @@ -570,7 +526,6 @@ class DisableRedirectAccessToSyslog(Setting): default: bool desc: str - class AccessLogFormat(Setting): name: str section: str @@ -580,7 +535,6 @@ class AccessLogFormat(Setting): default: str desc: str - class ErrorLog(Setting): name: str section: str @@ -590,7 +544,6 @@ class ErrorLog(Setting): default: str desc: str - class Loglevel(Setting): name: str section: str @@ -600,7 +553,6 @@ class Loglevel(Setting): default: str desc: str - class CaptureOutput(Setting): name: str section: str @@ -610,7 +562,6 @@ class CaptureOutput(Setting): default: bool desc: str - class LoggerClass(Setting): name: str section: str @@ -620,7 +571,6 @@ class LoggerClass(Setting): default: str desc: str - class LogConfig(Setting): name: str section: str @@ -630,7 +580,6 @@ class LogConfig(Setting): default: None desc: str - class LogConfigDict(Setting): name: str section: str @@ -638,7 +587,6 @@ class LogConfigDict(Setting): default: dict[str, Any] desc: str - class LogConfigJson(Setting): name: str section: str @@ -648,7 +596,6 @@ class LogConfigJson(Setting): default: None desc: str - class SyslogTo(Setting): name: str section: str @@ -658,7 +605,6 @@ class SyslogTo(Setting): default: str desc: str - class Syslog(Setting): name: str section: str @@ -668,7 +614,6 @@ class Syslog(Setting): default: bool desc: str - class SyslogPrefix(Setting): name: str section: str @@ -678,7 +623,6 @@ class SyslogPrefix(Setting): default: None desc: str - class SyslogFacility(Setting): name: str section: str @@ -688,7 +632,6 @@ class SyslogFacility(Setting): default: str desc: str - class EnableStdioInheritance(Setting): name: str section: str @@ -698,7 +641,6 @@ class EnableStdioInheritance(Setting): action: str desc: str - class StatsdHost(Setting): name: str section: str @@ -708,7 +650,6 @@ class StatsdHost(Setting): validator: _AddressValidatorType desc: str - class DogstatsdTags(Setting): name: str section: str @@ -718,7 +659,6 @@ class DogstatsdTags(Setting): validator: _StringValidatorType desc: str - class StatsdPrefix(Setting): name: str section: str @@ -728,7 +668,6 @@ class StatsdPrefix(Setting): validator: _StringValidatorType desc: str - class Procname(Setting): name: str section: str @@ -738,7 +677,6 @@ class Procname(Setting): default: None desc: str - class DefaultProcName(Setting): name: str section: str @@ -746,7 +684,6 @@ class DefaultProcName(Setting): default: str desc: str - class PythonPath(Setting): name: str section: str @@ -756,7 +693,6 @@ class PythonPath(Setting): default: None desc: str - class Paste(Setting): name: str section: str @@ -766,7 +702,6 @@ class Paste(Setting): default: None desc: str - class OnStarting(Setting): name: str section: str @@ -777,7 +712,6 @@ class OnStarting(Setting): def on_starting(server: Arbiter) -> None: ... # type: ignore[misc] - class OnReload(Setting): name: str section: str @@ -788,7 +722,6 @@ class OnReload(Setting): def on_reload(server: Arbiter) -> None: ... # type: ignore[misc] - class WhenReady(Setting): name: str section: str @@ -799,7 +732,6 @@ class WhenReady(Setting): def when_ready(server: Arbiter) -> None: ... # type: ignore[misc] - class Prefork(Setting): name: str section: str @@ -810,7 +742,6 @@ class Prefork(Setting): def pre_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] - class Postfork(Setting): name: str section: str @@ -821,7 +752,6 @@ class Postfork(Setting): def post_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] - class PostWorkerInit(Setting): name: str section: str @@ -832,7 +762,6 @@ class PostWorkerInit(Setting): def post_worker_init(worker: Worker) -> None: ... # type: ignore[misc] - class WorkerInt(Setting): name: str section: str @@ -843,7 +772,6 @@ class WorkerInt(Setting): def worker_int(worker: Worker) -> None: ... # type: ignore[misc] - class WorkerAbort(Setting): name: str section: str @@ -854,7 +782,6 @@ class WorkerAbort(Setting): def worker_abort(worker: Worker) -> None: ... # type: ignore[misc] - class PreExec(Setting): name: str section: str @@ -865,7 +792,6 @@ class PreExec(Setting): def pre_exec(server: Arbiter) -> None: ... # type: ignore[misc] - class PreRequest(Setting): name: str section: str @@ -876,7 +802,6 @@ class PreRequest(Setting): def pre_request(worker: Worker, req: Request) -> None: ... # type: ignore[misc] - class PostRequest(Setting): name: str section: str @@ -887,7 +812,6 @@ class PostRequest(Setting): def post_request(worker: Worker, req: Request, environ: _EnvironType, resp: Response) -> None: ... # type: ignore[misc] - class ChildExit(Setting): name: str section: str @@ -898,7 +822,6 @@ class ChildExit(Setting): def child_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] - class WorkerExit(Setting): name: str section: str @@ -909,7 +832,6 @@ class WorkerExit(Setting): def worker_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] - class NumWorkersChanged(Setting): name: str section: str @@ -920,7 +842,6 @@ class NumWorkersChanged(Setting): def nworkers_changed(server: Arbiter, new_value: int, old_value: int | None) -> None: ... # type: ignore[misc] - class OnExit(Setting): name: str section: str @@ -930,7 +851,6 @@ class OnExit(Setting): def on_exit(server: Arbiter) -> None: ... # type: ignore[misc] - class NewSSLContext(Setting): name: str section: str @@ -941,7 +861,6 @@ class NewSSLContext(Setting): def ssl_context(config: Config, default_ssl_context_factory: Callable[[], SSLContext]) -> SSLContext: ... # type: ignore[misc] - class ProxyProtocol(Setting): name: str section: str @@ -951,7 +870,6 @@ class ProxyProtocol(Setting): action: str desc: str - class ProxyAllowFrom(Setting): name: str section: str @@ -960,7 +878,6 @@ class ProxyAllowFrom(Setting): default: str desc: str - class KeyFile(Setting): name: str section: str @@ -970,7 +887,6 @@ class KeyFile(Setting): default: None desc: str - class CertFile(Setting): name: str section: str @@ -980,7 +896,6 @@ class CertFile(Setting): default: None desc: str - class SSLVersion(Setting): name: str section: str @@ -989,7 +904,6 @@ class SSLVersion(Setting): default: _SSLMethod desc: str - class CertReqs(Setting): name: str section: str @@ -998,7 +912,6 @@ class CertReqs(Setting): default: int desc: str - class CACerts(Setting): name: str section: str @@ -1008,7 +921,6 @@ class CACerts(Setting): default: None desc: str - class SuppressRaggedEOFs(Setting): name: str section: str @@ -1018,7 +930,6 @@ class SuppressRaggedEOFs(Setting): validator: _BoolValidatorType desc: str - class DoHandshakeOnConnect(Setting): name: str section: str @@ -1028,7 +939,6 @@ class DoHandshakeOnConnect(Setting): default: bool desc: str - class Ciphers(Setting): name: str section: str @@ -1037,7 +947,6 @@ class Ciphers(Setting): default: None desc: str - class PasteGlobalConf(Setting): name: str action: str @@ -1048,7 +957,6 @@ class PasteGlobalConf(Setting): default: list[str] desc: str - class PermitObsoleteFolding(Setting): name: str section: str @@ -1058,7 +966,6 @@ class PermitObsoleteFolding(Setting): default: bool desc: str - class StripHeaderSpaces(Setting): name: str section: str @@ -1068,7 +975,6 @@ class StripHeaderSpaces(Setting): default: bool desc: str - class PermitUnconventionalHTTPMethod(Setting): name: str section: str @@ -1078,7 +984,6 @@ class PermitUnconventionalHTTPMethod(Setting): default: bool desc: str - class PermitUnconventionalHTTPVersion(Setting): name: str section: str @@ -1088,7 +993,6 @@ class PermitUnconventionalHTTPVersion(Setting): default: bool desc: str - class CasefoldHTTPMethod(Setting): name: str section: str @@ -1098,7 +1002,6 @@ class CasefoldHTTPMethod(Setting): default: bool desc: str - class ForwarderHeaders(Setting): name: str section: str @@ -1107,7 +1010,6 @@ class ForwarderHeaders(Setting): default: str desc: str - class HeaderMap(Setting): name: str section: str diff --git a/stubs/gunicorn/gunicorn/debug.pyi b/stubs/gunicorn/gunicorn/debug.pyi index 48c4a7459bdd..e8684184a0b7 100644 --- a/stubs/gunicorn/gunicorn/debug.pyi +++ b/stubs/gunicorn/gunicorn/debug.pyi @@ -4,7 +4,6 @@ from collections.abc import Container from types import FrameType from typing import Any, Self - class Spew: trace_names: Container[str] | None = None show_values: bool @@ -12,6 +11,5 @@ class Spew: def __init__(self, trace_names: Container[str] | None = None, show_values: bool = True) -> None: ... def __call__(self, frame: FrameType, event: str, arg: Any) -> Self: ... - def spew(trace_names: Container[str] | None = None, show_values: bool = False) -> None: ... def unspew() -> None: ... diff --git a/stubs/gunicorn/gunicorn/errors.pyi b/stubs/gunicorn/gunicorn/errors.pyi index 07263798b029..f25818c3ff07 100644 --- a/stubs/gunicorn/gunicorn/errors.pyi +++ b/stubs/gunicorn/gunicorn/errors.pyi @@ -4,8 +4,5 @@ class HaltServer(BaseException): def __init__(self, reason: str, exit_status: int = 1) -> None: ... - class ConfigError(Exception): ... - - class AppImportError(Exception): ... diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 89a04310684c..856604aa9194 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -12,7 +12,6 @@ from .config import Config SYSLOG_FACILITIES: dict[str, int] - @type_check_only class _AtomsDict(TypedDict, total=False): """ @@ -41,7 +40,6 @@ class _AtomsDict(TypedDict, total=False): L: str p: str - type _CriticalIntType = Annotated[int, "50"] type _ErrorIntType = Annotated[int, "40"] type _WarningIntType = Annotated[int, "30"] @@ -52,13 +50,11 @@ type _LogLevelIntType = _CriticalIntType | _ErrorIntType | _WarningIntType | _In type _LogLevelStrType = Literal["critical", "error", "warning", "info", "debug"] type _LogLevelType = _LogLevelIntType | _LogLevelStrType - @type_check_only class _RootConfig(TypedDict): level: str handlers: list[str] - @type_check_only class _LoggerConfig(TypedDict): level: _LogLevelStrType @@ -66,21 +62,18 @@ class _LoggerConfig(TypedDict): propagate: bool qualname: str - @type_check_only class _HandlerConfig(TypedDict, total=False): # class: str [Should be provided!] formatter: str stream: str - @type_check_only class _FormatterConfig(TypedDict, total=False): # class: str [Should be provided!] format: str datefmt: str - @type_check_only class _ConfigDefaults(TypedDict): version: int @@ -90,28 +83,21 @@ class _ConfigDefaults(TypedDict): handlers: dict[str, _HandlerConfig] formatters: dict[str, _FormatterConfig] - CONFIG_DEFAULTS: _ConfigDefaults - def loggers() -> list[logging.Logger]: ... - class SafeAtoms(dict[str, Any]): def __init__(self, atoms: dict[str, Any]) -> None: ... @override def __getitem__(self, k: str) -> str: ... - type _SyslogAddressType = ( tuple[Literal[SocketKind.SOCK_DGRAM] | None, str] # Unix Socket | tuple[Literal[SocketKind.SOCK_DGRAM, SocketKind.SOCK_STREAM], tuple[str, int]] # TCP/UDP Socket ) - def parse_syslog_address(addr: str) -> _SyslogAddressType: ... - - @type_check_only class _LogLevels(TypedDict): critical: _CriticalIntType @@ -120,7 +106,6 @@ class _LogLevels(TypedDict): info: _InfoIntType debug: _DebugIntType - class Logger: LOG_LEVELS: _LogLevels loglevel: _LogLevelIntType diff --git a/stubs/gunicorn/gunicorn/http/errors.pyi b/stubs/gunicorn/gunicorn/http/errors.pyi index 6d913a71b70f..eae2f468f5d8 100644 --- a/stubs/gunicorn/gunicorn/http/errors.pyi +++ b/stubs/gunicorn/gunicorn/http/errors.pyi @@ -2,105 +2,88 @@ from collections.abc import Buffer from gunicorn.http import Message - class ParseException(Exception): ... - class NoMoreData(IOError): buf: Buffer def __init__(self, buf: Buffer | None = None) -> None: ... - class ConfigurationProblem(ParseException): info: str code: int def __init__(self, info: str) -> None: ... - class InvalidRequestLine(ParseException): req: str code: int def __init__(self, req: str) -> None: ... - class InvalidRequestMethod(ParseException): method: str def __init__(self, method: str) -> None: ... - class InvalidHTTPVersion(ParseException): version: str | tuple[int, int] def __init__(self, version: str | tuple[int, int]) -> None: ... - class InvalidHeader(ParseException): hdr: str req: Message | None def __init__(self, hdr: str, req: Message | None = None) -> None: ... - class ObsoleteFolding(ParseException): hdr: str def __init__(self, hdr: str) -> None: ... - class InvalidHeaderName(ParseException): hdr: str def __init__(self, hdr: str) -> None: ... - class UnsupportedTransferCoding(ParseException): hdr: str code: int def __init__(self, hdr: str) -> None: ... - class InvalidChunkSize(IOError): data: bytes def __init__(self, data: bytes) -> None: ... - class ChunkMissingTerminator(IOError): term: bytes def __init__(self, term: bytes) -> None: ... - class LimitRequestLine(ParseException): size: int max_size: int def __init__(self, size: int, max_size: int) -> None: ... - class LimitRequestHeaders(ParseException): msg: str def __init__(self, msg: str) -> None: ... - class InvalidProxyLine(ParseException): line: str code: int def __init__(self, line: str) -> None: ... - class ForbiddenProxyRequest(ParseException): host: str code: int def __init__(self, host: str) -> None: ... - class InvalidSchemeHeaders(ParseException): ... diff --git a/stubs/gunicorn/gunicorn/http/message.pyi b/stubs/gunicorn/gunicorn/http/message.pyi index 5cae21375e66..54e6057733ba 100644 --- a/stubs/gunicorn/gunicorn/http/message.pyi +++ b/stubs/gunicorn/gunicorn/http/message.pyi @@ -17,7 +17,6 @@ METHOD_BADCHAR_RE: re.Pattern[str] VERSION_RE: re.Pattern[str] RFC9110_5_5_INVALID_AND_DANGEROUS: re.Pattern[str] - class Message: cfg: Config unreader: Unreader @@ -40,7 +39,6 @@ class Message: def set_body_reader(self) -> None: ... def should_close(self) -> bool: ... - class Request(Message): method: str | None uri: str | None diff --git a/stubs/gunicorn/gunicorn/http/parser.pyi b/stubs/gunicorn/gunicorn/http/parser.pyi index 3a5cfb4701c1..2c4c4bb79161 100644 --- a/stubs/gunicorn/gunicorn/http/parser.pyi +++ b/stubs/gunicorn/gunicorn/http/parser.pyi @@ -7,7 +7,6 @@ from gunicorn.http.unreader import Unreader from .._types import _AddressType - class Parser: mesg_class: type[Request] | None cfg: Config @@ -22,6 +21,5 @@ class Parser: next: Callable[[Parser], Request] - class RequestParser(Parser): mesg_class: type[Request] diff --git a/stubs/gunicorn/gunicorn/http/unreader.pyi b/stubs/gunicorn/gunicorn/http/unreader.pyi index ee848c099929..78b47b7de7c2 100644 --- a/stubs/gunicorn/gunicorn/http/unreader.pyi +++ b/stubs/gunicorn/gunicorn/http/unreader.pyi @@ -4,7 +4,6 @@ from _typeshed import ReadableBuffer from collections.abc import Iterable, Iterator from typing_extensions import override - class Unreader: buf: io.BytesIO @@ -13,7 +12,6 @@ class Unreader: def read(self, size: int | None = None) -> bytes: ... def unread(self, data: ReadableBuffer) -> None: ... - class SocketUnreader(Unreader): sock: socket.socket mxchunk: int @@ -22,7 +20,6 @@ class SocketUnreader(Unreader): @override def chunk(self) -> bytes: ... - class IterUnreader(Unreader): iter: Iterator[bytes] | None diff --git a/stubs/gunicorn/gunicorn/http/wsgi.pyi b/stubs/gunicorn/gunicorn/http/wsgi.pyi index fd25bb561773..ee2413bf6f0e 100644 --- a/stubs/gunicorn/gunicorn/http/wsgi.pyi +++ b/stubs/gunicorn/gunicorn/http/wsgi.pyi @@ -33,11 +33,7 @@ def base_environ(cfg: Config) -> _EnvironType: ... def default_environ(req: Request, sock: socket.socket, cfg: Config) -> _EnvironType: ... def proxy_environ(req: Request) -> _EnvironType: ... def create( - req: Request, - sock: socket.socket, - client: _AddressType, - server: _AddressType, - cfg: Config, + req: Request, sock: socket.socket, client: _AddressType, server: _AddressType, cfg: Config ) -> tuple[Response, _EnvironType]: ... class Response: diff --git a/stubs/gunicorn/gunicorn/instrument/statsd.pyi b/stubs/gunicorn/gunicorn/instrument/statsd.pyi index 3364120a1a49..e9a450cc9e35 100644 --- a/stubs/gunicorn/gunicorn/instrument/statsd.pyi +++ b/stubs/gunicorn/gunicorn/instrument/statsd.pyi @@ -17,7 +17,6 @@ GAUGE_TYPE: str COUNTER_TYPE: str HISTOGRAM_TYPE: str - class Statsd(Logger): prefix: str sock: socket.socket | None diff --git a/stubs/gunicorn/gunicorn/pidfile.pyi b/stubs/gunicorn/gunicorn/pidfile.pyi index b3151df1c05a..91fc1f421efe 100644 --- a/stubs/gunicorn/gunicorn/pidfile.pyi +++ b/stubs/gunicorn/gunicorn/pidfile.pyi @@ -1,6 +1,5 @@ from _typeshed import StrOrBytesPath - class Pidfile: def __init__(self, fname: StrOrBytesPath) -> None: ... def create(self, pid: int) -> None: ... diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index 6b9106bec71a..35c3e40744ef 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -19,50 +19,37 @@ except ImportError: COMPILED_EXT_RE: Pattern[str] - class Reloader(threading.Thread): daemon: bool def __init__( - self, - extra_files: Iterable[str] | None = None, - interval: int = 1, - callback: Callable[[str], None] | None = None, + self, extra_files: Iterable[str] | None = None, interval: int = 1, callback: Callable[[str], None] | None = None ) -> None: ... def add_extra_file(self, filename: str) -> None: ... def get_files(self) -> list[str]: ... @override def run(self) -> None: ... - has_inotify: bool - class InotifyReloader(threading.Thread): event_mask: int daemon: bool - def __init__( - self, - extra_files: Iterable[str] | None = None, - callback: Callable[[str], None] | None = None, - ) -> None: ... + def __init__(self, extra_files: Iterable[str] | None = None, callback: Callable[[str], None] | None = None) -> None: ... def add_extra_file(self, filename: str) -> None: ... def get_dirs(self) -> AbstractSet[str]: ... @override def run(self) -> None: ... - type _PreferredReloaderType = type[InotifyReloader | Reloader] type _ReloaderType = InotifyReloader | Reloader - @type_check_only class _ReloadedEngines(TypedDict): auto: _PreferredReloaderType pool: type[Reloader] inotify: type[InotifyReloader] - preferred_reloader: _PreferredReloaderType reloader_engines: _ReloadedEngines diff --git a/stubs/gunicorn/gunicorn/sock.pyi b/stubs/gunicorn/gunicorn/sock.pyi index dead824b812f..e5e6fa9be2ed 100644 --- a/stubs/gunicorn/gunicorn/sock.pyi +++ b/stubs/gunicorn/gunicorn/sock.pyi @@ -7,7 +7,6 @@ from gunicorn.glogging import Logger as GLogger from .config import Config - class BaseSocket: def __init__(self, address: str, conf: Config, log: GLogger, fd: SupportsIndex | None = None) -> None: ... def __getattr__(self, name: str) -> Any: ... @@ -15,18 +14,15 @@ class BaseSocket: def bind(self, sock: socket.socket) -> None: ... def close(self) -> None: ... - class TCPSocket(BaseSocket): FAMILY: ClassVar[Literal[socket.AddressFamily.AF_INET, socket.AddressFamily.AF_INET6]] @override def set_options[T: socket.socket](self, sock: T, bound: bool = False) -> T: ... - class TCP6Socket(TCPSocket): FAMILY: ClassVar[Literal[socket.AddressFamily.AF_INET6]] - class UnixSocket(BaseSocket): FAMILY: ClassVar[Literal[socket.AddressFamily.AF_UNIX]] @@ -34,7 +30,6 @@ class UnixSocket(BaseSocket): @override def bind(self, sock: socket.socket) -> None: ... - def create_sockets(conf: Config, log: GLogger, fds: Iterable[SupportsIndex] | None = None) -> list[BaseSocket]: ... def close_sockets(listeners: Iterable[socket.socket], unlink: bool = True) -> None: ... def ssl_context(conf: Config) -> SSLContext: ... diff --git a/stubs/gunicorn/gunicorn/systemd.pyi b/stubs/gunicorn/gunicorn/systemd.pyi index ccdae639170d..1645f0e68052 100644 --- a/stubs/gunicorn/gunicorn/systemd.pyi +++ b/stubs/gunicorn/gunicorn/systemd.pyi @@ -2,6 +2,5 @@ from gunicorn.glogging import Logger as GLogger SD_LISTEN_FDS_START: int - def listen_fds(unset_environment: bool = True) -> int: ... def sd_notify(state: str, logger: GLogger, unset_environment: bool = False) -> None: ... diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index 65084aa3e993..a5865578ea68 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -10,20 +10,12 @@ from ._types import _AddressType, _WSGIAppType REDIRECT_TO: str hop_headers: set[str] - def load_entry_point(distribution: str, group: str, name: str) -> Any: ... def load_class( - uri: str | object, - default: str = "gunicorn.workers.sync.SyncWorker", - section: str = "gunicorn.workers", + uri: str | object, default: str = "gunicorn.workers.sync.SyncWorker", section: str = "gunicorn.workers" ) -> type[Any]: ... - -positionals: tuple[ - Literal[_ParameterKind.POSITIONAL_ONLY], - Literal[_ParameterKind.POSITIONAL_OR_KEYWORD], -] - +positionals: tuple[Literal[_ParameterKind.POSITIONAL_ONLY], Literal[_ParameterKind.POSITIONAL_OR_KEYWORD]] def get_arity(f: Callable[..., Any]) -> int: ... def get_username(uid: int) -> str: ... @@ -51,10 +43,6 @@ def has_fileno(obj: HasFileno) -> bool: ... def warn(msg: str) -> None: ... def make_fail_app(msg: str) -> _WSGIAppType: ... def split_request_uri(uri: str) -> SplitResult: ... -def reraise( - tp: type[BaseException], - value: BaseException | None, - tb: types.TracebackType | None = None, -) -> NoReturn: ... +def reraise(tp: type[BaseException], value: BaseException | None, tb: types.TracebackType | None = None) -> NoReturn: ... def bytes_to_str(b: bytes) -> str: ... def unquote_to_wsgi_str(string: str) -> str: ... diff --git a/stubs/gunicorn/gunicorn/workers/__init__.pyi b/stubs/gunicorn/gunicorn/workers/__init__.pyi index db480b10ac88..b1e6ab0b1350 100644 --- a/stubs/gunicorn/gunicorn/workers/__init__.pyi +++ b/stubs/gunicorn/gunicorn/workers/__init__.pyi @@ -1,6 +1,5 @@ from typing import TypedDict, type_check_only - @type_check_only class _SupportedWorkers(TypedDict): sync: str @@ -11,5 +10,4 @@ class _SupportedWorkers(TypedDict): tornado: str gthread: str - SUPPORTED_WORKERS: _SupportedWorkers diff --git a/stubs/gunicorn/gunicorn/workers/base.pyi b/stubs/gunicorn/gunicorn/workers/base.pyi index 319b61a993ab..d95fa3a7f289 100644 --- a/stubs/gunicorn/gunicorn/workers/base.pyi +++ b/stubs/gunicorn/gunicorn/workers/base.pyi @@ -10,7 +10,6 @@ from gunicorn.workers.workertmp import WorkerTmp from .._types import _AddressType, _WSGIAppType from ..reloader import _ReloaderType - class Worker: SIGNALS: list[int] PIPE: list[int] @@ -33,14 +32,7 @@ class Worker: wsgi: _WSGIAppType def __init__( - self, - age: int, - ppid: int, - sockets: list[socket.socket], - app: BaseApplication, - timeout: int, - cfg: Config, - log: GLogger, + self, age: int, ppid: int, sockets: list[socket.socket], app: BaseApplication, timeout: int, cfg: Config, log: GLogger ) -> None: ... def notify(self) -> None: ... def run(self) -> None: ... diff --git a/stubs/gunicorn/gunicorn/workers/base_async.pyi b/stubs/gunicorn/gunicorn/workers/base_async.pyi index 9d6810dc6788..96f8206ed30b 100644 --- a/stubs/gunicorn/gunicorn/workers/base_async.pyi +++ b/stubs/gunicorn/gunicorn/workers/base_async.pyi @@ -8,7 +8,6 @@ from .._types import _AddressType ALREADY_HANDLED: object - class AsyncWorker(base.Worker): worker_connections: int alive: bool diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index 5b82ae9fe54e..0beea545649f 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -10,10 +10,8 @@ from .._types import _AddressType EVENTLET_WSGI_LOCAL: local | None EVENTLET_ALREADY_HANDLED: bool | None - def patch_sendfile() -> None: ... - class EventletWorker(AsyncWorker): def patch(self) -> None: ... @override diff --git a/stubs/gunicorn/gunicorn/workers/ggevent.pyi b/stubs/gunicorn/gunicorn/workers/ggevent.pyi index 407f1bcbaab7..1a6443f66943 100644 --- a/stubs/gunicorn/gunicorn/workers/ggevent.pyi +++ b/stubs/gunicorn/gunicorn/workers/ggevent.pyi @@ -13,7 +13,6 @@ from .._types import _AddressType VERSION: str - class GeventWorker(AsyncWorker): server_class: type[StreamServer] | None wsgi_handler: type[WSGIHandler] | None @@ -37,7 +36,6 @@ class GeventWorker(AsyncWorker): @override def init_process(self) -> None: ... - class GeventResponse: status: str | None headers: dict[str, str] | None @@ -45,15 +43,12 @@ class GeventResponse: def __init__(self, status: str, headers: dict[str, str], clength: int | None) -> None: ... - class PyWSGIHandler(pywsgi.WSGIHandler): def log_request(self) -> None: ... def get_environ(self) -> dict[str, Any]: ... - class PyWSGIServer(pywsgi.WSGIServer): ... - class GeventPyWSGIWorker(GeventWorker): server_class: type[PyWSGIServer] | None wsgi_handler: type[PyWSGIHandler] | None diff --git a/stubs/gunicorn/gunicorn/workers/gthread.pyi b/stubs/gunicorn/gunicorn/workers/gthread.pyi index d003b1539887..f6c68861a77a 100644 --- a/stubs/gunicorn/gunicorn/workers/gthread.pyi +++ b/stubs/gunicorn/gunicorn/workers/gthread.pyi @@ -12,7 +12,6 @@ from gunicorn.http import RequestParser from .._types import _AddressType from . import base - class TConn: cfg: Config sock: socket.socket @@ -27,7 +26,6 @@ class TConn: def set_timeout(self) -> None: ... def close(self) -> None: ... - class ThreadWorker(base.Worker): worker_connections: int max_keepalived: int diff --git a/stubs/gunicorn/gunicorn/workers/gtornado.pyi b/stubs/gunicorn/gunicorn/workers/gtornado.pyi index 96bc85529541..d64ac26a1391 100644 --- a/stubs/gunicorn/gunicorn/workers/gtornado.pyi +++ b/stubs/gunicorn/gunicorn/workers/gtornado.pyi @@ -6,7 +6,6 @@ from tornado.ioloop import IOLoop, PeriodicCallback TORNADO5: bool - class TornadoWorker(Worker): alive: bool server_alive: bool diff --git a/stubs/gunicorn/gunicorn/workers/sync.pyi b/stubs/gunicorn/gunicorn/workers/sync.pyi index 4e58e40ec961..3efb37486f5e 100644 --- a/stubs/gunicorn/gunicorn/workers/sync.pyi +++ b/stubs/gunicorn/gunicorn/workers/sync.pyi @@ -6,10 +6,8 @@ from gunicorn.workers.base import Worker from .._types import _AddressType - class StopWaiting(Exception): ... - class SyncWorker(Worker): def accept(self, listener: socket.socket) -> None: ... def wait(self, timeout: int) -> list[socket.socket | int] | None: ... diff --git a/stubs/gunicorn/gunicorn/workers/workertmp.pyi b/stubs/gunicorn/gunicorn/workers/workertmp.pyi index c2323ac06e2d..0ee89ce3686d 100644 --- a/stubs/gunicorn/gunicorn/workers/workertmp.pyi +++ b/stubs/gunicorn/gunicorn/workers/workertmp.pyi @@ -3,7 +3,6 @@ from gunicorn.config import Config PLATFORM: str IS_CYGWIN: bool - class WorkerTmp: def __init__(self, cfg: Config) -> None: ... def notify(self) -> None: ... From 35e4307d6833cfbbb55d340b72db35581482cea5 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 00:30:30 +0300 Subject: [PATCH 056/102] [gunicorn] Fix: flake8, ruff, black rules --- stubs/gunicorn/gunicorn/_types.pyi | 33 ++++---- stubs/gunicorn/gunicorn/app/base.pyi | 10 +-- stubs/gunicorn/gunicorn/config.pyi | 89 +++++++++++---------- stubs/gunicorn/gunicorn/glogging.pyi | 27 +++---- stubs/gunicorn/gunicorn/http/body.pyi | 8 +- stubs/gunicorn/gunicorn/http/wsgi.pyi | 3 +- stubs/gunicorn/gunicorn/reloader.pyi | 22 +---- stubs/gunicorn/gunicorn/sock.pyi | 4 +- stubs/gunicorn/gunicorn/util.pyi | 3 +- stubs/gunicorn/gunicorn/workers/gthread.pyi | 8 +- 10 files changed, 90 insertions(+), 117 deletions(-) diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index 1ba450645926..ff1bdb7030dd 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -1,10 +1,10 @@ -from collections.abc import Awaitable, Iterable -from typing import Any, Callable, LiteralString +from collections.abc import Awaitable, Callable, Iterable +from typing import Any, LiteralString, TypeAlias -type _StatusType = str -type _HeadersType = list[tuple[str, str]] +_StatusType: TypeAlias = str +_HeadersType: TypeAlias = list[tuple[str, str]] -type _EnvironType = dict[str, Any] +_EnvironType: TypeAlias = dict[str, Any] # """ # WSGI environment dictionary containing request and server information. # @@ -67,17 +67,16 @@ type _EnvironType = dict[str, Any] # Proxy port, if proxy_protocol_info is present. Optional. # """ -type _StartResponseType = Callable[[_StatusType, _HeadersType], None] -type _ResponseBodyType = Iterable[bytes] +_StartResponseType: TypeAlias = Callable[[_StatusType, _HeadersType], None] +_ResponseBodyType: TypeAlias = Iterable[bytes] +_WSGIAppType: TypeAlias = Callable[[_EnvironType, _StartResponseType], _ResponseBodyType] # noqa: Y047 -type _WSGIAppType = Callable[[_EnvironType, _StartResponseType], _ResponseBodyType] +_ScopeType: TypeAlias = dict[str, Any] +_ReceiveType: TypeAlias = Callable[[], Awaitable[dict[str, Any]]] +_SendType: TypeAlias = Callable[[dict[str, Any]], Awaitable[None]] +_ASGIAppType: TypeAlias = Callable[[_ScopeType, _ReceiveType, _SendType], Awaitable[None]] # noqa: Y047 -type _ScopeType = dict[str, Any] -type _ReceiveType = Callable[[], Awaitable[dict[str, Any]]] -type _SendType = Callable[[dict[str, Any]], Awaitable[None]] -type _ASGIAppType = Callable[[_ScopeType, _ReceiveType, _SendType], Awaitable[None]] - -type _UnixSocketPathType = str -type _FileDescriptorType = int -type _TcpAddressType = tuple[LiteralString, int] -type _AddressType = _UnixSocketPathType | _FileDescriptorType | _TcpAddressType +_UnixSocketPathType: TypeAlias = str +_FileDescriptorType: TypeAlias = int +_TcpAddressType: TypeAlias = tuple[LiteralString, int] # noqa: Y047 +_AddressType: TypeAlias = _UnixSocketPathType | _FileDescriptorType | _TcpAddressType # noqa: Y047 diff --git a/stubs/gunicorn/gunicorn/app/base.pyi b/stubs/gunicorn/gunicorn/app/base.pyi index 188850f4b114..72d69becedb5 100644 --- a/stubs/gunicorn/gunicorn/app/base.pyi +++ b/stubs/gunicorn/gunicorn/app/base.pyi @@ -1,18 +1,10 @@ from argparse import ArgumentParser, Namespace -from collections.abc import Awaitable, Callable, Iterable from typing import Any, override from gunicorn.config import Config from gunicorn.glogging import Logger as GLogger -type _EnvironType = dict[str, Any] -type _StartResponseType = Callable[[str, list[tuple[str, str]]], None] -type _ResponseBodyType = Iterable[bytes] -type _WSGIAppType = Callable[[_EnvironType, _StartResponseType], _ResponseBodyType] -type _ScopeType = dict[str, Any] -type _ReceiveType = Callable[[], Awaitable[dict[str, Any]]] -type _SendType = Callable[[dict[str, Any]], Awaitable[None]] -type _ASGIAppType = Callable[[_ScopeType, _ReceiveType, _SendType], Awaitable[None]] +from .._types import _ASGIAppType, _WSGIAppType class BaseApplication: usage: str | None diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index a9762f110c2a..95238d6f248c 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -1,8 +1,10 @@ +# This file is part of gunicorn released under the MIT license. +# See the NOTICE for more information. import argparse from _typeshed import ConvertibleToInt -from collections.abc import Container +from collections.abc import Callable, Container from ssl import SSLContext, _SSLMethod -from typing import Any, Callable, Type, overload, override +from typing import Any, TypeAlias, overload, override from gunicorn.arbiter import Arbiter from gunicorn.glogging import Logger as GLogger @@ -12,31 +14,30 @@ from gunicorn.workers.base import Worker from ._types import _AddressType, _EnvironType -type _OnStartingHookType = Callable[[Arbiter], None] -type _OnReloadHookType = Callable[[Arbiter], None] -type _WhenReadyHookType = Callable[[Arbiter], None] -type _PreForkHookType = Callable[[Arbiter, Worker], None] -type _PostForkHookType = Callable[[Arbiter, Worker], None] -type _PostWorkerInitHookType = Callable[[Worker], None] -type _WorkerIntHookType = Callable[[Worker], None] -type _WorkerAbortHookType = Callable[[Worker], None] -type _PreExecHookType = Callable[[Arbiter], None] -type _PreRequestHookType = Callable[[Worker, Request], None] -type _PostRequestHookType = Callable[[Worker, Request, _EnvironType, Response], None] -type _ChildExitHookType = Callable[[Arbiter, Worker], None] -type _WorkerExitHookType = Callable[[Arbiter, Worker], None] -type _NumWorkersChangedHookType = Callable[[Arbiter, int, int | None], None] -type _OnExitHookType = Callable[[Arbiter], None] -type _SSLContextHookType = Callable[[Config, Callable[[], SSLContext]], SSLContext] - -type _BoolValidatorType = Callable[[bool | str | None], bool | None] -type _StringValidatorType = Callable[[str | None], str | None] -type _ListStringValidatorType = Callable[[str | list[str] | None], list[str]] -type _IntValidatorType = Callable[[int | ConvertibleToInt], int] -type _DictValidatorType = Callable[[dict[str, Any]], dict[str, Any]] -type _ClassValidatorType = Callable[[object | str | None], Type[Any] | None] -type _UserGroupValidatorType = Callable[[str | int | None], int] -type _AddressValidatorType = Callable[[str | None], _AddressType | None] +_OnStartingHookType: TypeAlias = Callable[[Arbiter], None] +_OnReloadHookType: TypeAlias = Callable[[Arbiter], None] +_WhenReadyHookType: TypeAlias = Callable[[Arbiter], None] +_PreForkHookType: TypeAlias = Callable[[Arbiter, Worker], None] +_PostForkHookType: TypeAlias = Callable[[Arbiter, Worker], None] +_PostWorkerInitHookType: TypeAlias = Callable[[Worker], None] +_WorkerIntHookType: TypeAlias = Callable[[Worker], None] +_WorkerAbortHookType: TypeAlias = Callable[[Worker], None] +_PreExecHookType: TypeAlias = Callable[[Arbiter], None] +_PreRequestHookType: TypeAlias = Callable[[Worker, Request], None] +_PostRequestHookType: TypeAlias = Callable[[Worker, Request, _EnvironType, Response], None] +_ChildExitHookType: TypeAlias = Callable[[Arbiter, Worker], None] +_WorkerExitHookType: TypeAlias = Callable[[Arbiter, Worker], None] +_NumWorkersChangedHookType: TypeAlias = Callable[[Arbiter, int, int | None], None] +_OnExitHookType: TypeAlias = Callable[[Arbiter], None] +_SSLContextHookType: TypeAlias = Callable[[Config, Callable[[], SSLContext]], SSLContext] +_BoolValidatorType: TypeAlias = Callable[[bool | str | None], bool | None] +_StringValidatorType: TypeAlias = Callable[[str | None], str | None] +_ListStringValidatorType: TypeAlias = Callable[[str | list[str] | None], list[str]] +_IntValidatorType: TypeAlias = Callable[[int | ConvertibleToInt], int] +_DictValidatorType: TypeAlias = Callable[[dict[str, Any]], dict[str, Any]] +_ClassValidatorType: TypeAlias = Callable[[object | str | None], type[Any] | None] +_UserGroupValidatorType: TypeAlias = Callable[[str | int | None], int] +_AddressValidatorType: TypeAlias = Callable[[str | None], _AddressType | None] KNOWN_SETTINGS: list[Setting] PLATFORM: str @@ -60,7 +61,7 @@ class Config: @property def worker_class_str(self) -> str: ... @property - def worker_class(self) -> Type[Worker]: ... + def worker_class(self) -> type[Worker]: ... @property def address(self) -> list[_AddressType]: ... @property @@ -70,7 +71,7 @@ class Config: @property def proc_name(self) -> str | None: ... @property - def logger_class(self) -> Type[GLogger]: ... + def logger_class(self) -> type[GLogger]: ... @property def is_ssl(self) -> bool: ... @property @@ -94,7 +95,7 @@ class Setting(metaclass=SettingMeta): section: str | None cli: list[str] | None validator: Callable[..., Any] | None - type: Type[Any] | Callable[..., Any] | None + type: type[Any] | Callable[..., Any] | None meta: str | None action: str | None default: Any @@ -140,11 +141,11 @@ def validate_list_of_existing_files(val: None) -> list[str]: ... def validate_string_to_addr_list(val: str | None) -> list[str]: ... def validate_string_to_list(val: str | None) -> list[str]: ... @overload -def validate_class(val: str) -> Type[Any]: ... +def validate_class(val: str) -> type[Any]: ... @overload def validate_class(val: None) -> None: ... @overload -def validate_class(val: object) -> Type[Any]: ... +def validate_class(val: object) -> type[Any]: ... def validate_callable(arity: int) -> Callable[[str | Callable[..., Any]], Callable[..., Any]]: ... def validate_user(val: int | str | None) -> int: ... def validate_group(val: int | str | None) -> int: ... @@ -194,7 +195,7 @@ class Backlog(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -204,7 +205,7 @@ class Workers(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -223,7 +224,7 @@ class WorkerThreads(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -233,7 +234,7 @@ class WorkerConnections(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -243,7 +244,7 @@ class MaxRequests(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -253,7 +254,7 @@ class MaxRequestsJitter(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -263,7 +264,7 @@ class Timeout(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -273,7 +274,7 @@ class GracefulTimeout(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -283,7 +284,7 @@ class Keepalive(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -293,7 +294,7 @@ class LimitRequestLine(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -303,7 +304,7 @@ class LimitRequestFields(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str @@ -313,7 +314,7 @@ class LimitRequestFieldSize(Setting): cli: list[str] meta: str validator: _IntValidatorType - type: Type[int] + type: type[int] default: int desc: str diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 856604aa9194..4a0fc94f33f5 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -2,7 +2,7 @@ import logging import threading from datetime import timedelta from socket import SocketKind -from typing import Annotated, Any, Literal, TypedDict, override, type_check_only +from typing import Annotated, Any, Literal, TypeAlias, TypedDict, override, type_check_only from gunicorn.http import Request from gunicorn.http.wsgi import Response @@ -14,12 +14,6 @@ SYSLOG_FACILITIES: dict[str, int] @type_check_only class _AtomsDict(TypedDict, total=False): - """ - Dictionary of atoms for log formatting. - Additionally contains dynamic keys in the format '{key}i' (request headers), - '{key}o' (response headers), and '{key}e' (environment variables), all with str values. - """ - h: str l: str u: str @@ -40,15 +34,14 @@ class _AtomsDict(TypedDict, total=False): L: str p: str -type _CriticalIntType = Annotated[int, "50"] -type _ErrorIntType = Annotated[int, "40"] -type _WarningIntType = Annotated[int, "30"] -type _InfoIntType = Annotated[int, "20"] -type _DebugIntType = Annotated[int, "10"] - -type _LogLevelIntType = _CriticalIntType | _ErrorIntType | _WarningIntType | _InfoIntType | _DebugIntType -type _LogLevelStrType = Literal["critical", "error", "warning", "info", "debug"] -type _LogLevelType = _LogLevelIntType | _LogLevelStrType +_CriticalIntType: TypeAlias = Annotated[int, "50"] +_ErrorIntType: TypeAlias = Annotated[int, "40"] +_WarningIntType: TypeAlias = Annotated[int, "30"] +_InfoIntType: TypeAlias = Annotated[int, "20"] +_DebugIntType: TypeAlias = Annotated[int, "10"] +_LogLevelIntType: TypeAlias = _CriticalIntType | _ErrorIntType | _WarningIntType | _InfoIntType | _DebugIntType +_LogLevelStrType: TypeAlias = Literal["critical", "error", "warning", "info", "debug"] +_LogLevelType: TypeAlias = _LogLevelIntType | _LogLevelStrType @type_check_only class _RootConfig(TypedDict): @@ -92,7 +85,7 @@ class SafeAtoms(dict[str, Any]): @override def __getitem__(self, k: str) -> str: ... -type _SyslogAddressType = ( +_SyslogAddressType: TypeAlias = ( tuple[Literal[SocketKind.SOCK_DGRAM] | None, str] # Unix Socket | tuple[Literal[SocketKind.SOCK_DGRAM, SocketKind.SOCK_STREAM], tuple[str, int]] # TCP/UDP Socket ) diff --git a/stubs/gunicorn/gunicorn/http/body.pyi b/stubs/gunicorn/gunicorn/http/body.pyi index 56d742347bea..52abf43cf62a 100644 --- a/stubs/gunicorn/gunicorn/http/body.pyi +++ b/stubs/gunicorn/gunicorn/http/body.pyi @@ -1,6 +1,6 @@ import io -from collections.abc import Generator, Iterable -from typing import Callable +from collections.abc import Callable, Generator, Iterator +from typing import TypeAlias from gunicorn.http.message import Request from gunicorn.http.unreader import Unreader @@ -32,14 +32,14 @@ class EOFReader: def __init__(self, unreader: Unreader) -> None: ... def read(self, size: int) -> bytes: ... -type _ReaderType = ChunkedReader | LengthReader | EOFReader +_ReaderType: TypeAlias = ChunkedReader | LengthReader | EOFReader class Body: reader: _ReaderType buf: io.BytesIO def __init__(self, reader: _ReaderType) -> None: ... - def __iter__(self) -> Iterable[bytes]: ... + def __iter__(self) -> Iterator[bytes]: ... def __next__(self) -> bytes: ... next: Callable[[Body], bytes] def getsize(self, size: int | None) -> int: ... diff --git a/stubs/gunicorn/gunicorn/http/wsgi.pyi b/stubs/gunicorn/gunicorn/http/wsgi.pyi index ee2413bf6f0e..08d9904cb50e 100644 --- a/stubs/gunicorn/gunicorn/http/wsgi.pyi +++ b/stubs/gunicorn/gunicorn/http/wsgi.pyi @@ -3,7 +3,8 @@ import logging import re import socket from _typeshed import ReadableBuffer -from typing import Any, Callable, override +from collections.abc import Callable +from typing import Any, override from gunicorn.config import Config from gunicorn.http import Request diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index 35c3e40744ef..d75cb7131ed8 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -1,21 +1,7 @@ import threading -from collections.abc import Iterable, Set as AbstractSet +from collections.abc import Callable, Iterable, Set as AbstractSet from re import Pattern -from typing import Callable, TypedDict, override, type_check_only - -try: - from inotify.adapters import Inotify # type: ignore[import-untyped] - from inotify.constants import ( # type: ignore[import-untyped] - IN_CREATE, - IN_DELETE, - IN_DELETE_SELF, - IN_MODIFY, - IN_MOVE_SELF, - IN_MOVED_FROM, - IN_MOVED_TO, - ) -except ImportError: - Inotify = object +from typing import TypeAlias, TypedDict, override, type_check_only COMPILED_EXT_RE: Pattern[str] @@ -42,8 +28,8 @@ class InotifyReloader(threading.Thread): @override def run(self) -> None: ... -type _PreferredReloaderType = type[InotifyReloader | Reloader] -type _ReloaderType = InotifyReloader | Reloader +_PreferredReloaderType: TypeAlias = type[InotifyReloader | Reloader] +_ReloaderType: TypeAlias = InotifyReloader | Reloader # noqa: Y047 @type_check_only class _ReloadedEngines(TypedDict): diff --git a/stubs/gunicorn/gunicorn/sock.pyi b/stubs/gunicorn/gunicorn/sock.pyi index e5e6fa9be2ed..478fd91c968e 100644 --- a/stubs/gunicorn/gunicorn/sock.pyi +++ b/stubs/gunicorn/gunicorn/sock.pyi @@ -10,7 +10,7 @@ from .config import Config class BaseSocket: def __init__(self, address: str, conf: Config, log: GLogger, fd: SupportsIndex | None = None) -> None: ... def __getattr__(self, name: str) -> Any: ... - def set_options[T: socket.socket](self, sock: T, bound: bool = False) -> T: ... + def set_options(self, sock: socket.socket, bound: bool = False) -> socket.socket: ... def bind(self, sock: socket.socket) -> None: ... def close(self) -> None: ... @@ -18,7 +18,7 @@ class TCPSocket(BaseSocket): FAMILY: ClassVar[Literal[socket.AddressFamily.AF_INET, socket.AddressFamily.AF_INET6]] @override - def set_options[T: socket.socket](self, sock: T, bound: bool = False) -> T: ... + def set_options(self, sock: socket.socket, bound: bool = False) -> socket.socket: ... class TCP6Socket(TCPSocket): FAMILY: ClassVar[Literal[socket.AddressFamily.AF_INET6]] diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index a5865578ea68..e837de8f0958 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -1,8 +1,9 @@ import types from _typeshed import FileDescriptorLike, FileDescriptorOrPath, HasFileno, StrOrBytesPath +from collections.abc import Callable from inspect import _ParameterKind from socket import socket -from typing import Any, Callable, Literal, NoReturn +from typing import Any, Literal, NoReturn from urllib.parse import SplitResult from ._types import _AddressType, _WSGIAppType diff --git a/stubs/gunicorn/gunicorn/workers/gthread.pyi b/stubs/gunicorn/gunicorn/workers/gthread.pyi index f6c68861a77a..61a558e284cd 100644 --- a/stubs/gunicorn/gunicorn/workers/gthread.pyi +++ b/stubs/gunicorn/gunicorn/workers/gthread.pyi @@ -1,6 +1,6 @@ import socket -from _typeshed import Incomplete -from concurrent.futures import ThreadPoolExecutor +from collections import deque +from concurrent.futures import Future, ThreadPoolExecutor from selectors import DefaultSelector from types import FrameType from typing import Any @@ -31,7 +31,7 @@ class ThreadWorker(base.Worker): max_keepalived: int tpool: ThreadPoolExecutor poller: DefaultSelector - futures: Incomplete + futures: deque[Future[tuple[bool, TConn]]] nr_conns: int alive: bool @@ -47,6 +47,6 @@ class ThreadWorker(base.Worker): def murder_keepalived(self) -> None: ... def is_parent_alive(self) -> bool: ... def run(self) -> None: ... - def finish_request(self, fs: Incomplete) -> None: ... + def finish_request(self, fs: Future[tuple[bool, TConn]]) -> None: ... def handle(self, conn: TConn) -> tuple[bool, TConn]: ... def handle_request(self, req: RequestParser, conn: TConn) -> bool: ... From d98998beca94616a7c695010036b4ee85b06135f Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 11:33:41 +0300 Subject: [PATCH 057/102] [gunicorn] Fix: mypy errors --- stubs/gunicorn/gunicorn/__init__.pyi | 2 +- stubs/gunicorn/gunicorn/_types.pyi | 3 ++- stubs/gunicorn/gunicorn/app/base.pyi | 3 ++- stubs/gunicorn/gunicorn/app/wsgiapp.pyi | 2 +- stubs/gunicorn/gunicorn/config.pyi | 3 ++- stubs/gunicorn/gunicorn/debug.pyi | 3 ++- stubs/gunicorn/gunicorn/glogging.pyi | 3 ++- stubs/gunicorn/gunicorn/http/body.pyi | 2 +- stubs/gunicorn/gunicorn/http/errors.pyi | 2 +- stubs/gunicorn/gunicorn/http/wsgi.pyi | 3 ++- stubs/gunicorn/gunicorn/instrument/statsd.pyi | 3 ++- stubs/gunicorn/gunicorn/reloader.pyi | 3 ++- stubs/gunicorn/gunicorn/sock.pyi | 3 ++- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 7 ++++--- stubs/gunicorn/gunicorn/workers/gtornado.pyi | 4 ++-- stubs/gunicorn/gunicorn/workers/sync.pyi | 2 +- 16 files changed, 29 insertions(+), 19 deletions(-) diff --git a/stubs/gunicorn/gunicorn/__init__.pyi b/stubs/gunicorn/gunicorn/__init__.pyi index cfee5fc04685..a5d6a2090a23 100644 --- a/stubs/gunicorn/gunicorn/__init__.pyi +++ b/stubs/gunicorn/gunicorn/__init__.pyi @@ -1,4 +1,4 @@ -from typing import LiteralString +from typing_extensions import LiteralString version_info: tuple[int, int, int] __version__: LiteralString diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index ff1bdb7030dd..696e73f02fad 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -1,5 +1,6 @@ from collections.abc import Awaitable, Callable, Iterable -from typing import Any, LiteralString, TypeAlias +from typing import Any +from typing_extensions import LiteralString, TypeAlias _StatusType: TypeAlias = str _HeadersType: TypeAlias = list[tuple[str, str]] diff --git a/stubs/gunicorn/gunicorn/app/base.pyi b/stubs/gunicorn/gunicorn/app/base.pyi index 72d69becedb5..e23a7bae71f1 100644 --- a/stubs/gunicorn/gunicorn/app/base.pyi +++ b/stubs/gunicorn/gunicorn/app/base.pyi @@ -1,5 +1,6 @@ from argparse import ArgumentParser, Namespace -from typing import Any, override +from typing import Any +from typing_extensions import override from gunicorn.config import Config from gunicorn.glogging import Logger as GLogger diff --git a/stubs/gunicorn/gunicorn/app/wsgiapp.pyi b/stubs/gunicorn/gunicorn/app/wsgiapp.pyi index 60a94ac865cc..af744d5529a7 100644 --- a/stubs/gunicorn/gunicorn/app/wsgiapp.pyi +++ b/stubs/gunicorn/gunicorn/app/wsgiapp.pyi @@ -1,5 +1,5 @@ from argparse import ArgumentParser, Namespace -from typing import override +from typing_extensions import override from gunicorn.app.base import Application diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 95238d6f248c..495e4e713fe5 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -4,7 +4,8 @@ import argparse from _typeshed import ConvertibleToInt from collections.abc import Callable, Container from ssl import SSLContext, _SSLMethod -from typing import Any, TypeAlias, overload, override +from typing import Any, overload +from typing_extensions import TypeAlias, override from gunicorn.arbiter import Arbiter from gunicorn.glogging import Logger as GLogger diff --git a/stubs/gunicorn/gunicorn/debug.pyi b/stubs/gunicorn/gunicorn/debug.pyi index e8684184a0b7..f4fa97c10f3e 100644 --- a/stubs/gunicorn/gunicorn/debug.pyi +++ b/stubs/gunicorn/gunicorn/debug.pyi @@ -2,7 +2,8 @@ __all__ = ["spew", "unspew"] from collections.abc import Container from types import FrameType -from typing import Any, Self +from typing import Any +from typing_extensions import Self class Spew: trace_names: Container[str] | None = None diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 4a0fc94f33f5..2ebb87c2ed02 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -2,7 +2,8 @@ import logging import threading from datetime import timedelta from socket import SocketKind -from typing import Annotated, Any, Literal, TypeAlias, TypedDict, override, type_check_only +from typing import Annotated, Any, Literal, TypedDict, type_check_only +from typing_extensions import TypeAlias, override from gunicorn.http import Request from gunicorn.http.wsgi import Response diff --git a/stubs/gunicorn/gunicorn/http/body.pyi b/stubs/gunicorn/gunicorn/http/body.pyi index 52abf43cf62a..9537dfcb40ec 100644 --- a/stubs/gunicorn/gunicorn/http/body.pyi +++ b/stubs/gunicorn/gunicorn/http/body.pyi @@ -1,6 +1,6 @@ import io from collections.abc import Callable, Generator, Iterator -from typing import TypeAlias +from typing_extensions import TypeAlias from gunicorn.http.message import Request from gunicorn.http.unreader import Unreader diff --git a/stubs/gunicorn/gunicorn/http/errors.pyi b/stubs/gunicorn/gunicorn/http/errors.pyi index eae2f468f5d8..27c3e3e12db7 100644 --- a/stubs/gunicorn/gunicorn/http/errors.pyi +++ b/stubs/gunicorn/gunicorn/http/errors.pyi @@ -1,4 +1,4 @@ -from collections.abc import Buffer +from typing_extensions import Buffer from gunicorn.http import Message diff --git a/stubs/gunicorn/gunicorn/http/wsgi.pyi b/stubs/gunicorn/gunicorn/http/wsgi.pyi index 08d9904cb50e..619cf02bd45f 100644 --- a/stubs/gunicorn/gunicorn/http/wsgi.pyi +++ b/stubs/gunicorn/gunicorn/http/wsgi.pyi @@ -4,7 +4,8 @@ import re import socket from _typeshed import ReadableBuffer from collections.abc import Callable -from typing import Any, override +from typing import Any +from typing_extensions import override from gunicorn.config import Config from gunicorn.http import Request diff --git a/stubs/gunicorn/gunicorn/instrument/statsd.pyi b/stubs/gunicorn/gunicorn/instrument/statsd.pyi index e9a450cc9e35..bb0d7b29f31a 100644 --- a/stubs/gunicorn/gunicorn/instrument/statsd.pyi +++ b/stubs/gunicorn/gunicorn/instrument/statsd.pyi @@ -1,6 +1,7 @@ import socket from datetime import timedelta -from typing import Any, override +from typing import Any +from typing_extensions import override from gunicorn.config import Config from gunicorn.glogging import Logger diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index d75cb7131ed8..d9bb531c30a3 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -1,7 +1,8 @@ import threading from collections.abc import Callable, Iterable, Set as AbstractSet from re import Pattern -from typing import TypeAlias, TypedDict, override, type_check_only +from typing import TypedDict, type_check_only +from typing_extensions import TypeAlias, override COMPILED_EXT_RE: Pattern[str] diff --git a/stubs/gunicorn/gunicorn/sock.pyi b/stubs/gunicorn/gunicorn/sock.pyi index 478fd91c968e..a26d9c787378 100644 --- a/stubs/gunicorn/gunicorn/sock.pyi +++ b/stubs/gunicorn/gunicorn/sock.pyi @@ -1,7 +1,8 @@ import socket from collections.abc import Iterable from ssl import SSLContext, SSLSocket -from typing import Any, ClassVar, Literal, SupportsIndex, override +from typing import Any, ClassVar, Literal, SupportsIndex +from typing_extensions import override from gunicorn.glogging import Logger as GLogger diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index 0beea545649f..f4895107c8bf 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -1,8 +1,9 @@ from types import FrameType -from typing import Any, override +from typing import Any +from typing_extensions import override -from eventlet.greenio import GreenSocket # type: ignore[import-untyped] -from eventlet.wsgi import local # type: ignore[import-untyped] +from eventlet.greenio import GreenSocket # type: ignore[import-not-found] +from eventlet.wsgi import local # type: ignore[import-not-found] from gunicorn.workers.base_async import AsyncWorker from .._types import _AddressType diff --git a/stubs/gunicorn/gunicorn/workers/gtornado.pyi b/stubs/gunicorn/gunicorn/workers/gtornado.pyi index d64ac26a1391..e79906abf9d5 100644 --- a/stubs/gunicorn/gunicorn/workers/gtornado.pyi +++ b/stubs/gunicorn/gunicorn/workers/gtornado.pyi @@ -1,8 +1,8 @@ from types import FrameType -from typing import override +from typing_extensions import override from gunicorn.workers.base import Worker -from tornado.ioloop import IOLoop, PeriodicCallback +from tornado.ioloop import IOLoop, PeriodicCallback # type: ignore[import-not-found] TORNADO5: bool diff --git a/stubs/gunicorn/gunicorn/workers/sync.pyi b/stubs/gunicorn/gunicorn/workers/sync.pyi index 3efb37486f5e..061e501df0a5 100644 --- a/stubs/gunicorn/gunicorn/workers/sync.pyi +++ b/stubs/gunicorn/gunicorn/workers/sync.pyi @@ -1,5 +1,5 @@ import socket -from typing import override +from typing_extensions import override from gunicorn.http import Request from gunicorn.workers.base import Worker From cb7f7f455ff2afa9999c942abbbc1d1e123104f2 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 11:52:16 +0300 Subject: [PATCH 058/102] [gunicorn] Fix: pyright errors --- stubs/gunicorn/gunicorn/config.pyi | 32 +++++++++---------- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 4 +-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 495e4e713fe5..34f662846cbe 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -712,7 +712,7 @@ class OnStarting(Setting): default: _OnStartingHookType desc: str - def on_starting(server: Arbiter) -> None: ... # type: ignore[misc] + def on_starting(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class OnReload(Setting): name: str @@ -722,7 +722,7 @@ class OnReload(Setting): default: _OnReloadHookType desc: str - def on_reload(server: Arbiter) -> None: ... # type: ignore[misc] + def on_reload(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class WhenReady(Setting): name: str @@ -732,7 +732,7 @@ class WhenReady(Setting): default: _WhenReadyHookType desc: str - def when_ready(server: Arbiter) -> None: ... # type: ignore[misc] + def when_ready(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class Prefork(Setting): name: str @@ -742,7 +742,7 @@ class Prefork(Setting): default: _PreForkHookType desc: str - def pre_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] + def pre_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class Postfork(Setting): name: str @@ -752,7 +752,7 @@ class Postfork(Setting): default: _PostForkHookType desc: str - def post_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] + def post_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class PostWorkerInit(Setting): name: str @@ -762,7 +762,7 @@ class PostWorkerInit(Setting): default: _PostWorkerInitHookType desc: str - def post_worker_init(worker: Worker) -> None: ... # type: ignore[misc] + def post_worker_init(worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class WorkerInt(Setting): name: str @@ -772,7 +772,7 @@ class WorkerInt(Setting): default: _WorkerIntHookType desc: str - def worker_int(worker: Worker) -> None: ... # type: ignore[misc] + def worker_int(worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class WorkerAbort(Setting): name: str @@ -782,7 +782,7 @@ class WorkerAbort(Setting): default: _WorkerAbortHookType desc: str - def worker_abort(worker: Worker) -> None: ... # type: ignore[misc] + def worker_abort(worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class PreExec(Setting): name: str @@ -792,7 +792,7 @@ class PreExec(Setting): default: _PreExecHookType desc: str - def pre_exec(server: Arbiter) -> None: ... # type: ignore[misc] + def pre_exec(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class PreRequest(Setting): name: str @@ -802,7 +802,7 @@ class PreRequest(Setting): default: _PreRequestHookType desc: str - def pre_request(worker: Worker, req: Request) -> None: ... # type: ignore[misc] + def pre_request(worker: Worker, req: Request) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class PostRequest(Setting): name: str @@ -812,7 +812,7 @@ class PostRequest(Setting): default: _PostRequestHookType desc: str - def post_request(worker: Worker, req: Request, environ: _EnvironType, resp: Response) -> None: ... # type: ignore[misc] + def post_request(worker: Worker, req: Request, environ: _EnvironType, resp: Response) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class ChildExit(Setting): name: str @@ -822,7 +822,7 @@ class ChildExit(Setting): default: _ChildExitHookType desc: str - def child_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] + def child_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class WorkerExit(Setting): name: str @@ -832,7 +832,7 @@ class WorkerExit(Setting): default: _WorkerExitHookType desc: str - def worker_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] + def worker_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class NumWorkersChanged(Setting): name: str @@ -842,7 +842,7 @@ class NumWorkersChanged(Setting): default: _NumWorkersChangedHookType desc: str - def nworkers_changed(server: Arbiter, new_value: int, old_value: int | None) -> None: ... # type: ignore[misc] + def nworkers_changed(server: Arbiter, new_value: int, old_value: int | None) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class OnExit(Setting): name: str @@ -851,7 +851,7 @@ class OnExit(Setting): default: _OnExitHookType desc: str - def on_exit(server: Arbiter) -> None: ... # type: ignore[misc] + def on_exit(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class NewSSLContext(Setting): name: str @@ -861,7 +861,7 @@ class NewSSLContext(Setting): default: _SSLContextHookType desc: str - def ssl_context(config: Config, default_ssl_context_factory: Callable[[], SSLContext]) -> SSLContext: ... # type: ignore[misc] + def ssl_context(config: Config, default_ssl_context_factory: Callable[[], SSLContext]) -> SSLContext: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class ProxyProtocol(Setting): name: str diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index f4895107c8bf..9dff6901cc6e 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -2,8 +2,8 @@ from types import FrameType from typing import Any from typing_extensions import override -from eventlet.greenio import GreenSocket # type: ignore[import-not-found] -from eventlet.wsgi import local # type: ignore[import-not-found] +from eventlet.greenio import GreenSocket # type: ignore[import-not-found] # pyright: ignore[reportMissingTypeStubs] +from eventlet.wsgi import local # type: ignore[import-not-found] # pyright: ignore[reportMissingTypeStubs] from gunicorn.workers.base_async import AsyncWorker from .._types import _AddressType From 23a67540634353ce18013322d69d5611776f5c54 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 12:04:35 +0300 Subject: [PATCH 059/102] [gunicorn] Use _DictConfigArgs annotation instead custom TypedDict --- stubs/gunicorn/gunicorn/glogging.pyi | 36 ++-------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 2ebb87c2ed02..c42a8450d164 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -1,6 +1,7 @@ import logging import threading from datetime import timedelta +from logging.config import _DictConfigArgs from socket import SocketKind from typing import Annotated, Any, Literal, TypedDict, type_check_only from typing_extensions import TypeAlias, override @@ -44,40 +45,7 @@ _LogLevelIntType: TypeAlias = _CriticalIntType | _ErrorIntType | _WarningIntType _LogLevelStrType: TypeAlias = Literal["critical", "error", "warning", "info", "debug"] _LogLevelType: TypeAlias = _LogLevelIntType | _LogLevelStrType -@type_check_only -class _RootConfig(TypedDict): - level: str - handlers: list[str] - -@type_check_only -class _LoggerConfig(TypedDict): - level: _LogLevelStrType - handlers: list[str] - propagate: bool - qualname: str - -@type_check_only -class _HandlerConfig(TypedDict, total=False): - # class: str [Should be provided!] - formatter: str - stream: str - -@type_check_only -class _FormatterConfig(TypedDict, total=False): - # class: str [Should be provided!] - format: str - datefmt: str - -@type_check_only -class _ConfigDefaults(TypedDict): - version: int - disable_existing_loggers: bool - root: _RootConfig - loggers: dict[str, _LoggerConfig] - handlers: dict[str, _HandlerConfig] - formatters: dict[str, _FormatterConfig] - -CONFIG_DEFAULTS: _ConfigDefaults +CONFIG_DEFAULTS: _DictConfigArgs def loggers() -> list[logging.Logger]: ... From ad13dea148bd4ea8d4dca99b824902ad73da1aaf Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 12:08:04 +0300 Subject: [PATCH 060/102] [gunicorn] Supress mypy imports --- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index 9dff6901cc6e..a81a9c893a5b 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -2,8 +2,8 @@ from types import FrameType from typing import Any from typing_extensions import override -from eventlet.greenio import GreenSocket # type: ignore[import-not-found] # pyright: ignore[reportMissingTypeStubs] -from eventlet.wsgi import local # type: ignore[import-not-found] # pyright: ignore[reportMissingTypeStubs] +from eventlet.greenio import GreenSocket # type: ignore[import-not-found,import-untyped] # pyright: ignore[reportMissingTypeStubs] +from eventlet.wsgi import local # type: ignore[import-not-found,import-untyped] # pyright: ignore[reportMissingTypeStubs] from gunicorn.workers.base_async import AsyncWorker from .._types import _AddressType From 9d38f825508f1282ac57b32763d8477da6eb4534 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 12:38:35 +0300 Subject: [PATCH 061/102] [gunicorn] Supress pyright, mypy imports --- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index a81a9c893a5b..b6b9775f0bf0 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -2,8 +2,8 @@ from types import FrameType from typing import Any from typing_extensions import override -from eventlet.greenio import GreenSocket # type: ignore[import-not-found,import-untyped] # pyright: ignore[reportMissingTypeStubs] -from eventlet.wsgi import local # type: ignore[import-not-found,import-untyped] # pyright: ignore[reportMissingTypeStubs] +from eventlet.greenio import GreenSocket # type: ignore # pyright: ignore[reportMissingTypeStubs] # noqa: PGH003 +from eventlet.wsgi import local # type: ignore # pyright: ignore[reportMissingTypeStubs] # noqa: PGH003 from gunicorn.workers.base_async import AsyncWorker from .._types import _AddressType From 2678a6234885f436815264b6b15db2aec9298718 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 12:49:01 +0300 Subject: [PATCH 062/102] [gunicorn] Add ClassVar annotations --- stubs/gunicorn/gunicorn/arbiter.pyi | 19 +- stubs/gunicorn/gunicorn/config.pyi | 1308 +++++++++---------- stubs/gunicorn/gunicorn/glogging.pyi | 16 +- stubs/gunicorn/gunicorn/http/parser.pyi | 5 +- stubs/gunicorn/gunicorn/workers/base.pyi | 5 +- stubs/gunicorn/gunicorn/workers/ggevent.pyi | 16 +- 6 files changed, 685 insertions(+), 684 deletions(-) diff --git a/stubs/gunicorn/gunicorn/arbiter.pyi b/stubs/gunicorn/gunicorn/arbiter.pyi index bb6a192c88e4..0f7ae45f5def 100644 --- a/stubs/gunicorn/gunicorn/arbiter.pyi +++ b/stubs/gunicorn/gunicorn/arbiter.pyi @@ -1,5 +1,6 @@ import socket from types import FrameType +from typing import ClassVar from gunicorn.app.base import BaseApplication from gunicorn.config import Config @@ -10,15 +11,15 @@ from ._types import _AddressType from .pidfile import Pidfile class Arbiter: - WORKER_BOOT_ERROR: int - APP_LOAD_ERROR: int - START_CTX: dict[int | str, str | list[str]] - LISTENERS: list[socket.socket] - WORKERS: dict[int, Worker] - PIPE: list[int] - SIG_QUEUE: list[int] - SIGNALS: list[int] - SIG_NAMES: dict[int, str] + WORKER_BOOT_ERROR: ClassVar[int] + APP_LOAD_ERROR: ClassVar[int] + START_CTX: ClassVar[dict[int | str, str | list[str]]] + LISTENERS: ClassVar[list[socket.socket]] + WORKERS: ClassVar[dict[int, Worker]] + PIPE: ClassVar[list[int]] + SIG_QUEUE: ClassVar[list[int]] + SIGNALS: ClassVar[list[int]] + SIG_NAMES: ClassVar[dict[int, str]] log: GLogger | None pidfile: Pidfile | None systemd: bool diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 34f662846cbe..56359c9c0207 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -1,10 +1,8 @@ -# This file is part of gunicorn released under the MIT license. -# See the NOTICE for more information. import argparse from _typeshed import ConvertibleToInt from collections.abc import Callable, Container from ssl import SSLContext, _SSLMethod -from typing import Any, overload +from typing import Any, ClassVar, overload from typing_extensions import TypeAlias, override from gunicorn.arbiter import Arbiter @@ -91,20 +89,20 @@ class SettingMeta(type): def fmt_desc(cls, desc: str) -> None: ... class Setting(metaclass=SettingMeta): - name: str | None + name: ClassVar[str | None] value: Any - section: str | None - cli: list[str] | None - validator: Callable[..., Any] | None - type: type[Any] | Callable[..., Any] | None - meta: str | None - action: str | None - default: Any - short: str | None - desc: str | None - nargs: int | str | None - const: bool | None - order: int + section: ClassVar[str | None] + cli: ClassVar[list[str] | None] + validator: ClassVar[Callable[..., Any] | None] + type: ClassVar[type[Any] | Callable[..., Any] | None] + meta: ClassVar[str | None] + action: ClassVar[str | None] + default: ClassVar[Any] + short: ClassVar[str | None] + desc: ClassVar[str | None] + nargs: ClassVar[int | str | None] + const: ClassVar[bool | None] + order: ClassVar[int] def __init__(self) -> None: ... def add_option(self, parser: argparse.ArgumentParser) -> None: ... @@ -164,858 +162,858 @@ def validate_header_map_behaviour(val: None) -> None: ... def get_default_config_file() -> str | None: ... class ConfigFile(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class WSGIApp(Setting): - name: str - section: str - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class Bind(Setting): - name: str - action: str - section: str - cli: list[str] - meta: str - validator: _ListStringValidatorType - default: list[str] - desc: str + name: ClassVar[str] + action: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_ListStringValidatorType] + default: ClassVar[list[str]] + desc: ClassVar[str] class Backlog(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class Workers(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class WorkerClass(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _ClassValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_ClassValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class WorkerThreads(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class WorkerConnections(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class MaxRequests(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class MaxRequestsJitter(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class Timeout(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class GracefulTimeout(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class Keepalive(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class LimitRequestLine(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class LimitRequestFields(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class LimitRequestFieldSize(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: type[int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[type[int]] + default: ClassVar[int] + desc: ClassVar[str] class Reload(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class ReloadEngine(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: Callable[[str], str] - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[Callable[[str], str]] + default: ClassVar[str] + desc: ClassVar[str] class ReloadExtraFiles(Setting): - name: str - action: str - section: str - cli: list[str] - meta: str - validator: _ListStringValidatorType - default: list[str] - desc: str + name: ClassVar[str] + action: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_ListStringValidatorType] + default: ClassVar[list[str]] + desc: ClassVar[str] class Spew(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class ConfigCheck(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class PrintConfig(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class PreloadApp(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class Sendfile(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - const: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + const: ClassVar[bool] + desc: ClassVar[str] class ReusePort(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class Chdir(Setting): - name: str - section: str - cli: list[str] - validator: Callable[[str], str] - default: str - default_doc: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[Callable[[str], str]] + default: ClassVar[str] + default_doc: ClassVar[str] + desc: ClassVar[str] class Daemon(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class Env(Setting): - name: str - action: str - section: str - cli: list[str] - meta: str - validator: _ListStringValidatorType - default: list[str] - desc: str + name: ClassVar[str] + action: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_ListStringValidatorType] + default: ClassVar[list[str]] + desc: ClassVar[str] class Pidfile(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class WorkerTmpDir(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class User(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _UserGroupValidatorType - default: int - default_doc: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_UserGroupValidatorType] + default: ClassVar[int] + default_doc: ClassVar[str] + desc: ClassVar[str] class Group(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _UserGroupValidatorType - default: int - default_doc: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_UserGroupValidatorType] + default: ClassVar[int] + default_doc: ClassVar[str] + desc: ClassVar[str] class Umask(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _IntValidatorType - type: Callable[[Any, str], int] - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_IntValidatorType] + type: ClassVar[Callable[[Any, str], int]] + default: ClassVar[int] + desc: ClassVar[str] class Initgroups(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class TmpUploadDir(Setting): - name: str - section: str - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class SecureSchemeHeader(Setting): - name: str - section: str - validator: _DictValidatorType - default: dict[str, str] - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[_DictValidatorType] + default: ClassVar[dict[str, str]] + desc: ClassVar[str] class ForwardedAllowIPS(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _ListStringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_ListStringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class AccessLog(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class DisableRedirectAccessToSyslog(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class AccessLogFormat(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class ErrorLog(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class Loglevel(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class CaptureOutput(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class LoggerClass(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _ClassValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_ClassValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class LogConfig(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class LogConfigDict(Setting): - name: str - section: str - validator: _DictValidatorType - default: dict[str, Any] - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[_DictValidatorType] + default: ClassVar[dict[str, Any]] + desc: ClassVar[str] class LogConfigJson(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class SyslogTo(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class Syslog(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class SyslogPrefix(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class SyslogFacility(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class EnableStdioInheritance(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - default: bool - action: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + default: ClassVar[bool] + action: ClassVar[str] + desc: ClassVar[str] class StatsdHost(Setting): - name: str - section: str - cli: list[str] - meta: str - default: None - validator: _AddressValidatorType - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + default: ClassVar[None] + validator: ClassVar[_AddressValidatorType] + desc: ClassVar[str] class DogstatsdTags(Setting): - name: str - section: str - cli: list[str] - meta: str - default: str - validator: _StringValidatorType - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + default: ClassVar[str] + validator: ClassVar[_StringValidatorType] + desc: ClassVar[str] class StatsdPrefix(Setting): - name: str - section: str - cli: list[str] - meta: str - default: str - validator: _StringValidatorType - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + default: ClassVar[str] + validator: ClassVar[_StringValidatorType] + desc: ClassVar[str] class Procname(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class DefaultProcName(Setting): - name: str - section: str - validator: _StringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class PythonPath(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class Paste(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class OnStarting(Setting): - name: str - section: str - validator: Callable[[str | _OnStartingHookType], _OnStartingHookType] - type: Callable[..., Any] - default: _OnStartingHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _OnStartingHookType], _OnStartingHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_OnStartingHookType] + desc: ClassVar[str] def on_starting(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class OnReload(Setting): - name: str - section: str - validator: Callable[[str | _OnReloadHookType], _OnReloadHookType] - type: Callable[..., Any] - default: _OnReloadHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _OnReloadHookType], _OnReloadHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_OnReloadHookType] + desc: ClassVar[str] def on_reload(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class WhenReady(Setting): - name: str - section: str - validator: Callable[[str | _WhenReadyHookType], _WhenReadyHookType] - type: Callable[..., Any] - default: _WhenReadyHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _WhenReadyHookType], _WhenReadyHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_WhenReadyHookType] + desc: ClassVar[str] def when_ready(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class Prefork(Setting): - name: str - section: str - validator: Callable[[str | _PreForkHookType], _PreForkHookType] - type: Callable[..., Any] - default: _PreForkHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _PreForkHookType], _PreForkHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_PreForkHookType] + desc: ClassVar[str] def pre_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class Postfork(Setting): - name: str - section: str - validator: Callable[[str | _PostForkHookType], _PostForkHookType] - type: Callable[..., Any] - default: _PostForkHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _PostForkHookType], _PostForkHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_PostForkHookType] + desc: ClassVar[str] def post_fork(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class PostWorkerInit(Setting): - name: str - section: str - validator: Callable[[str | _PostWorkerInitHookType], _PostWorkerInitHookType] - type: Callable[..., Any] - default: _PostWorkerInitHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _PostWorkerInitHookType], _PostWorkerInitHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_PostWorkerInitHookType] + desc: ClassVar[str] def post_worker_init(worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class WorkerInt(Setting): - name: str - section: str - validator: Callable[[str | _WorkerIntHookType], _WorkerIntHookType] - type: Callable[..., Any] - default: _WorkerIntHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _WorkerIntHookType], _WorkerIntHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_WorkerIntHookType] + desc: ClassVar[str] def worker_int(worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class WorkerAbort(Setting): - name: str - section: str - validator: Callable[[str | _WorkerAbortHookType], _WorkerAbortHookType] - type: Callable[..., Any] - default: _WorkerAbortHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _WorkerAbortHookType], _WorkerAbortHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_WorkerAbortHookType] + desc: ClassVar[str] def worker_abort(worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class PreExec(Setting): - name: str - section: str - validator: Callable[[str | _PreExecHookType], _PreExecHookType] - type: Callable[..., Any] - default: _PreExecHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _PreExecHookType], _PreExecHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_PreExecHookType] + desc: ClassVar[str] def pre_exec(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class PreRequest(Setting): - name: str - section: str - validator: Callable[[str | _PreRequestHookType], _PreRequestHookType] - type: Callable[..., Any] - default: _PreRequestHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _PreRequestHookType], _PreRequestHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_PreRequestHookType] + desc: ClassVar[str] def pre_request(worker: Worker, req: Request) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class PostRequest(Setting): - name: str - section: str - validator: Callable[[str | Callable[..., Any]], _PostRequestHookType] - type: Callable[..., Any] - default: _PostRequestHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | Callable[..., Any]], _PostRequestHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_PostRequestHookType] + desc: ClassVar[str] def post_request(worker: Worker, req: Request, environ: _EnvironType, resp: Response) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class ChildExit(Setting): - name: str - section: str - validator: Callable[[str | _ChildExitHookType], _ChildExitHookType] - type: Callable[..., Any] - default: _ChildExitHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _ChildExitHookType], _ChildExitHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_ChildExitHookType] + desc: ClassVar[str] def child_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class WorkerExit(Setting): - name: str - section: str - validator: Callable[[str | _WorkerExitHookType], _WorkerExitHookType] - type: Callable[..., Any] - default: _WorkerExitHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _WorkerExitHookType], _WorkerExitHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_WorkerExitHookType] + desc: ClassVar[str] def worker_exit(server: Arbiter, worker: Worker) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class NumWorkersChanged(Setting): - name: str - section: str - validator: Callable[[str | _NumWorkersChangedHookType], _NumWorkersChangedHookType] - type: Callable[..., Any] - default: _NumWorkersChangedHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _NumWorkersChangedHookType], _NumWorkersChangedHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_NumWorkersChangedHookType] + desc: ClassVar[str] def nworkers_changed(server: Arbiter, new_value: int, old_value: int | None) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class OnExit(Setting): - name: str - section: str - validator: Callable[[str | _OnExitHookType], _OnExitHookType] - default: _OnExitHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _OnExitHookType], _OnExitHookType]] + default: ClassVar[_OnExitHookType] + desc: ClassVar[str] def on_exit(server: Arbiter) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class NewSSLContext(Setting): - name: str - section: str - validator: Callable[[str | _SSLContextHookType], _SSLContextHookType] - type: Callable[..., Any] - default: _SSLContextHookType - desc: str + name: ClassVar[str] + section: ClassVar[str] + validator: ClassVar[Callable[[str | _SSLContextHookType], _SSLContextHookType]] + type: ClassVar[Callable[..., Any]] + default: ClassVar[_SSLContextHookType] + desc: ClassVar[str] def ssl_context(config: Config, default_ssl_context_factory: Callable[[], SSLContext]) -> SSLContext: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class ProxyProtocol(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - default: bool - action: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + default: ClassVar[bool] + action: ClassVar[str] + desc: ClassVar[str] class ProxyAllowFrom(Setting): - name: str - section: str - cli: list[str] - validator: _ListStringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_ListStringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class KeyFile(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class CertFile(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class SSLVersion(Setting): - name: str - section: str - cli: list[str] - validator: Callable[[_SSLMethod], _SSLMethod] - default: _SSLMethod - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[Callable[[_SSLMethod], _SSLMethod]] + default: ClassVar[_SSLMethod] + desc: ClassVar[str] class CertReqs(Setting): - name: str - section: str - cli: list[str] - validator: _IntValidatorType - default: int - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_IntValidatorType] + default: ClassVar[int] + desc: ClassVar[str] class CACerts(Setting): - name: str - section: str - cli: list[str] - meta: str - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class SuppressRaggedEOFs(Setting): - name: str - section: str - cli: list[str] - action: str - default: bool - validator: _BoolValidatorType - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + action: ClassVar[str] + default: ClassVar[bool] + validator: ClassVar[_BoolValidatorType] + desc: ClassVar[str] class DoHandshakeOnConnect(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class Ciphers(Setting): - name: str - section: str - cli: list[str] - validator: _StringValidatorType - default: None - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_StringValidatorType] + default: ClassVar[None] + desc: ClassVar[str] class PasteGlobalConf(Setting): - name: str - action: str - section: str - cli: list[str] - meta: str - validator: _ListStringValidatorType - default: list[str] - desc: str + name: ClassVar[str] + action: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + meta: ClassVar[str] + validator: ClassVar[_ListStringValidatorType] + default: ClassVar[list[str]] + desc: ClassVar[str] class PermitObsoleteFolding(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class StripHeaderSpaces(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class PermitUnconventionalHTTPMethod(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class PermitUnconventionalHTTPVersion(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class CasefoldHTTPMethod(Setting): - name: str - section: str - cli: list[str] - validator: _BoolValidatorType - action: str - default: bool - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_BoolValidatorType] + action: ClassVar[str] + default: ClassVar[bool] + desc: ClassVar[str] class ForwarderHeaders(Setting): - name: str - section: str - cli: list[str] - validator: _ListStringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_ListStringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] class HeaderMap(Setting): - name: str - section: str - cli: list[str] - validator: _StringValidatorType - default: str - desc: str + name: ClassVar[str] + section: ClassVar[str] + cli: ClassVar[list[str]] + validator: ClassVar[_StringValidatorType] + default: ClassVar[str] + desc: ClassVar[str] diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index c42a8450d164..579cdbd2a74e 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -3,7 +3,7 @@ import threading from datetime import timedelta from logging.config import _DictConfigArgs from socket import SocketKind -from typing import Annotated, Any, Literal, TypedDict, type_check_only +from typing import Annotated, Any, ClassVar, Literal, TypedDict, type_check_only from typing_extensions import TypeAlias, override from gunicorn.http import Request @@ -69,13 +69,13 @@ class _LogLevels(TypedDict): debug: _DebugIntType class Logger: - LOG_LEVELS: _LogLevels - loglevel: _LogLevelIntType - error_fmt: str - datefmt: str - access_fmt: str - syslog_fmt: str - atoms_wrapper_class: type[SafeAtoms] + LOG_LEVELS: ClassVar[_LogLevels] + loglevel: ClassVar[_LogLevelIntType] + error_fmt: ClassVar[str] + datefmt: ClassVar[str] + access_fmt: ClassVar[str] + syslog_fmt: ClassVar[str] + atoms_wrapper_class: ClassVar[type[SafeAtoms]] error_log: logging.Logger access_log: logging.Logger error_handlers: list[logging.Handler] diff --git a/stubs/gunicorn/gunicorn/http/parser.pyi b/stubs/gunicorn/gunicorn/http/parser.pyi index 2c4c4bb79161..644581644b70 100644 --- a/stubs/gunicorn/gunicorn/http/parser.pyi +++ b/stubs/gunicorn/gunicorn/http/parser.pyi @@ -1,5 +1,6 @@ import socket from collections.abc import Callable, Iterable, Iterator +from typing import ClassVar from gunicorn.config import Config from gunicorn.http.message import Request @@ -8,7 +9,7 @@ from gunicorn.http.unreader import Unreader from .._types import _AddressType class Parser: - mesg_class: type[Request] | None + mesg_class: ClassVar[type[Request] | None] cfg: Config unreader: Unreader mesg: Request | None @@ -22,4 +23,4 @@ class Parser: next: Callable[[Parser], Request] class RequestParser(Parser): - mesg_class: type[Request] + mesg_class: ClassVar[type[Request]] diff --git a/stubs/gunicorn/gunicorn/workers/base.pyi b/stubs/gunicorn/gunicorn/workers/base.pyi index d95fa3a7f289..aa0d5fc3a76a 100644 --- a/stubs/gunicorn/gunicorn/workers/base.pyi +++ b/stubs/gunicorn/gunicorn/workers/base.pyi @@ -1,5 +1,6 @@ import socket from types import FrameType +from typing import ClassVar from gunicorn.app.base import BaseApplication from gunicorn.config import Config @@ -11,8 +12,8 @@ from .._types import _AddressType, _WSGIAppType from ..reloader import _ReloaderType class Worker: - SIGNALS: list[int] - PIPE: list[int] + SIGNALS: ClassVar[list[int]] + PIPE: ClassVar[list[int]] age: int pid: str ppid: int diff --git a/stubs/gunicorn/gunicorn/workers/ggevent.pyi b/stubs/gunicorn/gunicorn/workers/ggevent.pyi index 1a6443f66943..3ebf48025c85 100644 --- a/stubs/gunicorn/gunicorn/workers/ggevent.pyi +++ b/stubs/gunicorn/gunicorn/workers/ggevent.pyi @@ -1,5 +1,5 @@ from types import FrameType -from typing import Any +from typing import Any, ClassVar from typing_extensions import override from gevent import pywsgi @@ -14,8 +14,8 @@ from .._types import _AddressType VERSION: str class GeventWorker(AsyncWorker): - server_class: type[StreamServer] | None - wsgi_handler: type[WSGIHandler] | None + server_class: ClassVar[type[StreamServer] | None] + wsgi_handler: ClassVar[type[WSGIHandler] | None] sockets: list[GeventSocket] def patch(self) -> None: ... @@ -37,9 +37,9 @@ class GeventWorker(AsyncWorker): def init_process(self) -> None: ... class GeventResponse: - status: str | None - headers: dict[str, str] | None - sent: int | None + status: ClassVar[str | None] + headers: ClassVar[dict[str, str] | None] + sent: ClassVar[int | None] def __init__(self, status: str, headers: dict[str, str], clength: int | None) -> None: ... @@ -50,5 +50,5 @@ class PyWSGIHandler(pywsgi.WSGIHandler): class PyWSGIServer(pywsgi.WSGIServer): ... class GeventPyWSGIWorker(GeventWorker): - server_class: type[PyWSGIServer] | None - wsgi_handler: type[PyWSGIHandler] | None + server_class: ClassVar[type[PyWSGIServer] | None] + wsgi_handler: ClassVar[type[PyWSGIHandler] | None] From 0aa8e18223938f317cba6edc2dcfae12981cb42a Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 13:36:39 +0300 Subject: [PATCH 063/102] [gunicorn] Add supported_platforms and ci_platforms in METADATA.toml --- stubs/gunicorn/METADATA.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/gunicorn/METADATA.toml b/stubs/gunicorn/METADATA.toml index ce0d76b59093..a0914575f469 100644 --- a/stubs/gunicorn/METADATA.toml +++ b/stubs/gunicorn/METADATA.toml @@ -1,3 +1,5 @@ version = "23.0.*" upstream_repository = "https://github.com/benoitc/gunicorn" requires = ["types-gevent", "types-tornado"] +supported_platforms = ["linux", "darwin"] +ci_platforms = ["linux", "darwin"] From 616d3817da39c0d48932bafc25441bb115340231 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 16:04:46 +0300 Subject: [PATCH 064/102] [gunicorn] Add [tool.stubtest] --- stubs/gunicorn/METADATA.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubs/gunicorn/METADATA.toml b/stubs/gunicorn/METADATA.toml index a0914575f469..9568cdc16d03 100644 --- a/stubs/gunicorn/METADATA.toml +++ b/stubs/gunicorn/METADATA.toml @@ -1,5 +1,8 @@ version = "23.0.*" upstream_repository = "https://github.com/benoitc/gunicorn" requires = ["types-gevent", "types-tornado"] + +[tool.stubtest] supported_platforms = ["linux", "darwin"] ci_platforms = ["linux", "darwin"] +stubtest_requirements = ["gevent", "eventlet", "tornado", "setproctitle", "PasteDeploy", "inotify"] From 1e72ba7ffaeff325fdb6f007465a0102c4f837dc Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 16:05:16 +0300 Subject: [PATCH 065/102] [gunicorn] Fix: InotifyReloader.get_dirs return annotation --- stubs/gunicorn/gunicorn/reloader.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index d9bb531c30a3..30035f4d6386 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -1,5 +1,5 @@ import threading -from collections.abc import Callable, Iterable, Set as AbstractSet +from collections.abc import Callable, Iterable from re import Pattern from typing import TypedDict, type_check_only from typing_extensions import TypeAlias, override @@ -25,7 +25,7 @@ class InotifyReloader(threading.Thread): def __init__(self, extra_files: Iterable[str] | None = None, callback: Callable[[str], None] | None = None) -> None: ... def add_extra_file(self, filename: str) -> None: ... - def get_dirs(self) -> AbstractSet[str]: ... + def get_dirs(self) -> set[str]: ... @override def run(self) -> None: ... From 99b2e8991f98f4b9d802d195f8ecb579260decd7 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 16:30:44 +0300 Subject: [PATCH 066/102] [gunicorn] Add stub for UnixSocket --- stubs/gunicorn/gunicorn/sock.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/sock.pyi b/stubs/gunicorn/gunicorn/sock.pyi index a26d9c787378..f2e7cf8d35da 100644 --- a/stubs/gunicorn/gunicorn/sock.pyi +++ b/stubs/gunicorn/gunicorn/sock.pyi @@ -1,4 +1,5 @@ import socket +import sys from collections.abc import Iterable from ssl import SSLContext, SSLSocket from typing import Any, ClassVar, Literal, SupportsIndex @@ -25,7 +26,10 @@ class TCP6Socket(TCPSocket): FAMILY: ClassVar[Literal[socket.AddressFamily.AF_INET6]] class UnixSocket(BaseSocket): - FAMILY: ClassVar[Literal[socket.AddressFamily.AF_UNIX]] + if sys.platform != "win32": + FAMILY: ClassVar[Literal[socket.AddressFamily.AF_UNIX]] + else: + FAMILY: ClassVar[Literal[0]] # Stub for windows def __init__(self, addr: str, conf: Config, log: GLogger, fd: SupportsIndex | None = None) -> None: ... @override From 1a91edfba23b239753928837f449c7938a213e26 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 16:31:09 +0300 Subject: [PATCH 067/102] [gunicorn] Suppress eventlet imports --- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index b6b9775f0bf0..c202ef4e9829 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -2,8 +2,8 @@ from types import FrameType from typing import Any from typing_extensions import override -from eventlet.greenio import GreenSocket # type: ignore # pyright: ignore[reportMissingTypeStubs] # noqa: PGH003 -from eventlet.wsgi import local # type: ignore # pyright: ignore[reportMissingTypeStubs] # noqa: PGH003 +from eventlet.greenio import GreenSocket # type: ignore # pyright: ignore # noqa: PGH003 +from eventlet.wsgi import local # type: ignore # pyright: ignore # noqa: PGH003 from gunicorn.workers.base_async import AsyncWorker from .._types import _AddressType From 366f6fd333f2f2b24448bacb338d679df0b21c29 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 16:34:53 +0300 Subject: [PATCH 068/102] [gunicorn] Suppress tornado imports --- stubs/gunicorn/gunicorn/workers/gtornado.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/workers/gtornado.pyi b/stubs/gunicorn/gunicorn/workers/gtornado.pyi index e79906abf9d5..bad356967d37 100644 --- a/stubs/gunicorn/gunicorn/workers/gtornado.pyi +++ b/stubs/gunicorn/gunicorn/workers/gtornado.pyi @@ -2,7 +2,7 @@ from types import FrameType from typing_extensions import override from gunicorn.workers.base import Worker -from tornado.ioloop import IOLoop, PeriodicCallback # type: ignore[import-not-found] +from tornado.ioloop import IOLoop, PeriodicCallback # type: ignore # pyright: ignore # noqa: PGH003 TORNADO5: bool From 71121bc8c588174aaf158a80dd29bd5f3c61cc46 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 16:50:59 +0300 Subject: [PATCH 069/102] [gunicorn] Add stubtest_allowlist_darwin.txt --- stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt diff --git a/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt b/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt new file mode 100644 index 000000000000..9050e18ea168 --- /dev/null +++ b/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt @@ -0,0 +1,3 @@ +gunicorn.reloader.InotifyReloader.add_extra_file +gunicorn.reloader.InotifyReloader.get_dirs +gunicorn.reloader.InotifyReloader.run From eb159a7e0f7d88fdda14ec0e0fd7977cd25a05f2 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Wed, 10 Sep 2025 17:02:51 +0300 Subject: [PATCH 070/102] [gunicorn] Delete types-tornado from requires --- stubs/gunicorn/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/METADATA.toml b/stubs/gunicorn/METADATA.toml index 9568cdc16d03..12cbb095adac 100644 --- a/stubs/gunicorn/METADATA.toml +++ b/stubs/gunicorn/METADATA.toml @@ -1,6 +1,6 @@ version = "23.0.*" upstream_repository = "https://github.com/benoitc/gunicorn" -requires = ["types-gevent", "types-tornado"] +requires = ["types-gevent"] [tool.stubtest] supported_platforms = ["linux", "darwin"] From 0fb06173831e8de780180cd2e597ec0e379fb944 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Thu, 11 Sep 2025 16:16:11 +0300 Subject: [PATCH 071/102] [gunicorn] Remove suppress import error --- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 8 ++++---- stubs/gunicorn/gunicorn/workers/gtornado.pyi | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index c202ef4e9829..e3c23e51c029 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -1,14 +1,14 @@ from types import FrameType from typing import Any -from typing_extensions import override +from typing_extensions import TypeAlias, override -from eventlet.greenio import GreenSocket # type: ignore # pyright: ignore # noqa: PGH003 -from eventlet.wsgi import local # type: ignore # pyright: ignore # noqa: PGH003 from gunicorn.workers.base_async import AsyncWorker from .._types import _AddressType -EVENTLET_WSGI_LOCAL: local | None +GreenSocket: TypeAlias = Any # eventlet GreenSocket class + +EVENTLET_WSGI_LOCAL: Any # eventlet local instance EVENTLET_ALREADY_HANDLED: bool | None def patch_sendfile() -> None: ... diff --git a/stubs/gunicorn/gunicorn/workers/gtornado.pyi b/stubs/gunicorn/gunicorn/workers/gtornado.pyi index bad356967d37..2c55c7c62b86 100644 --- a/stubs/gunicorn/gunicorn/workers/gtornado.pyi +++ b/stubs/gunicorn/gunicorn/workers/gtornado.pyi @@ -1,8 +1,12 @@ from types import FrameType -from typing_extensions import override +from typing_extensions import TypeAlias, override from gunicorn.workers.base import Worker -from tornado.ioloop import IOLoop, PeriodicCallback # type: ignore # pyright: ignore # noqa: PGH003 + +from typing import Any + +IOLoop: TypeAlias = Any # tornado IOLoop class +PeriodicCallback: TypeAlias = Any # tornado PeriodicCallback class TORNADO5: bool From 044532485b10556fc330225313da072cec68673d Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Thu, 11 Sep 2025 16:35:34 +0300 Subject: [PATCH 072/102] [gunicorn] Add stubtest_requirements versions --- stubs/gunicorn/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/METADATA.toml b/stubs/gunicorn/METADATA.toml index 12cbb095adac..f79a6d707ad7 100644 --- a/stubs/gunicorn/METADATA.toml +++ b/stubs/gunicorn/METADATA.toml @@ -5,4 +5,4 @@ requires = ["types-gevent"] [tool.stubtest] supported_platforms = ["linux", "darwin"] ci_platforms = ["linux", "darwin"] -stubtest_requirements = ["gevent", "eventlet", "tornado", "setproctitle", "PasteDeploy", "inotify"] +stubtest_requirements = ["gevent>=1.4.0", "eventlet>=0.24.1,!=0.36.0", "tornado>=0.2", "setproctitle", "PasteDeploy", "inotify"] From fa28ecf3ab4f048828d8aa8215c5fefc3a3bf709 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 11 Sep 2025 13:38:15 +0000 Subject: [PATCH 073/102] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/gunicorn/gunicorn/workers/gtornado.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/gtornado.pyi b/stubs/gunicorn/gunicorn/workers/gtornado.pyi index 2c55c7c62b86..13b0a3f96a40 100644 --- a/stubs/gunicorn/gunicorn/workers/gtornado.pyi +++ b/stubs/gunicorn/gunicorn/workers/gtornado.pyi @@ -1,10 +1,9 @@ from types import FrameType +from typing import Any from typing_extensions import TypeAlias, override from gunicorn.workers.base import Worker -from typing import Any - IOLoop: TypeAlias = Any # tornado IOLoop class PeriodicCallback: TypeAlias = Any # tornado PeriodicCallback class From 6aac2eb728380e936094969e3f8a2fc6196c974f Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 18:59:33 +0300 Subject: [PATCH 074/102] [gunicorn] Add description for stubtest allowlist (InotifyReloader methods) --- stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt b/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt index 9050e18ea168..15a1a1e74ce0 100644 --- a/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt +++ b/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt @@ -1,3 +1,6 @@ +# InotifyReloader methods are absent on Darwin because inotify is Linux-only. +# Defined in stub for type checking, but missing in runtime, causing stubtest errors. + gunicorn.reloader.InotifyReloader.add_extra_file gunicorn.reloader.InotifyReloader.get_dirs gunicorn.reloader.InotifyReloader.run From 864a9c6aa76d4be25f1c2edc914240cd499d7882 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 19:00:34 +0300 Subject: [PATCH 075/102] [gunicorn] Add different stubs for different OS for InotifyReloader --- stubs/gunicorn/gunicorn/reloader.pyi | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index 30035f4d6386..a49e138f1318 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -1,8 +1,9 @@ +import sys import threading from collections.abc import Callable, Iterable from re import Pattern from typing import TypedDict, type_check_only -from typing_extensions import TypeAlias, override +from typing_extensions import TypeAlias, override, NoReturn COMPILED_EXT_RE: Pattern[str] @@ -19,15 +20,22 @@ class Reloader(threading.Thread): has_inotify: bool -class InotifyReloader(threading.Thread): - event_mask: int - daemon: bool - - def __init__(self, extra_files: Iterable[str] | None = None, callback: Callable[[str], None] | None = None) -> None: ... - def add_extra_file(self, filename: str) -> None: ... - def get_dirs(self) -> set[str]: ... - @override - def run(self) -> None: ... +if sys.platform == "linux": + class InotifyReloader(threading.Thread): + event_mask: int + daemon: bool + + def __init__(self, extra_files: Iterable[str] | None = None, callback: Callable[[str], None] | None = None) -> None: ... + def add_extra_file(self, filename: str) -> None: ... + def get_dirs(self) -> set[str]: ... + @override + def run(self) -> None: ... + +else: + class InotifyReloader: + def __init__( + self, extra_files: Iterable[str] | None = None, interval: int = 1, callback: Callable[[str], None] | None = None + ) -> NoReturn: ... _PreferredReloaderType: TypeAlias = type[InotifyReloader | Reloader] _ReloaderType: TypeAlias = InotifyReloader | Reloader # noqa: Y047 From 568a9b79c9040dfef860177a9dffae55de8a62bb Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 19:08:58 +0300 Subject: [PATCH 076/102] [gunicorn] Add description about helper _types.pyi file --- stubs/gunicorn/@tests/stubtest_allowlist.txt | 2 +- stubs/gunicorn/gunicorn/_types.pyi | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/stubs/gunicorn/@tests/stubtest_allowlist.txt b/stubs/gunicorn/@tests/stubtest_allowlist.txt index ac02eb7acc3d..309ce487f84d 100644 --- a/stubs/gunicorn/@tests/stubtest_allowlist.txt +++ b/stubs/gunicorn/@tests/stubtest_allowlist.txt @@ -1,4 +1,4 @@ -# Helper +# Is not present in runtime. For more details, see the file itself. gunicorn._types gunicorn.__main__ diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index 696e73f02fad..1248221d2982 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -1,3 +1,5 @@ +### This .pyi file is a helper for centralized storage types that are reused across different runtime modules. ### + from collections.abc import Awaitable, Callable, Iterable from typing import Any from typing_extensions import LiteralString, TypeAlias From 86b3615ca76ba77779db8521e3923905f8e62962 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 19:11:48 +0300 Subject: [PATCH 077/102] [gunicorn] Add link to pep instead of duplicating documentation --- stubs/gunicorn/gunicorn/_types.pyi | 64 +----------------------------- 1 file changed, 1 insertion(+), 63 deletions(-) diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index 1248221d2982..e51b28b077be 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -7,69 +7,7 @@ from typing_extensions import LiteralString, TypeAlias _StatusType: TypeAlias = str _HeadersType: TypeAlias = list[tuple[str, str]] -_EnvironType: TypeAlias = dict[str, Any] -# """ -# WSGI environment dictionary containing request and server information. -# -# Keys and their types: -# - wsgi.version: tuple[int, int] -# WSGI version (e.g., (1, 0)). Required. -# - wsgi.url_scheme: str -# URL scheme (e.g., 'http', 'https'). Required. -# - wsgi.input: io.BytesIO -# Input stream for request body. Required. -# - wsgi.errors: WSGIErrorsWrapper -# Error stream for logging. Required. -# - wsgi.multithread: bool -# Indicates if the server supports multithreading (False in Gunicorn). Required. -# - wsgi.multiprocess: bool -# Indicates if the server supports multiprocessing (based on cfg.workers). Required. -# - wsgi.run_once: bool -# Indicates if the application runs once (False in Gunicorn). Required. -# - wsgi.file_wrapper: type[FileWrapper] -# Type of FileWrapper class for file handling. Required. -# - wsgi.input_terminated: bool -# Indicates if the input stream is terminated (True in Gunicorn). Required. -# - SERVER_SOFTWARE: str -# Server software description. Required. -# - gunicorn.socket: socket.socket -# Socket for the connection. Required. -# - REQUEST_METHOD: str -# HTTP request method (e.g., 'GET', 'POST'). Required. -# - QUERY_STRING: str -# Query string (may be empty). Required. -# - RAW_URI: str -# Raw URI of the request. Required. -# - SERVER_PROTOCOL: str -# HTTP protocol version (e.g., 'HTTP/1.1'). Required. -# - SERVER_NAME: str -# Server name. Required. -# - SERVER_PORT: str -# Server port (may be empty for Unix sockets). Required. -# - PATH_INFO: str -# Request path, excluding SCRIPT_NAME. Required. -# - SCRIPT_NAME: str -# Application path prefix (may be empty). Required. -# - REMOTE_ADDR: str -# Client IP address. Required. -# - REMOTE_PORT: str -# Client port. Optional. -# - CONTENT_TYPE: str -# Content type from request headers. Optional. -# - CONTENT_LENGTH: str -# Content length from request headers. Optional. -# - HTTP_HOST: str -# Host header value. Optional. -# - HTTP_*: str -# Other HTTP headers (e.g., HTTP_ACCEPT, HTTP_USER_AGENT). Optional. -# - PROXY_PROTOCOL: str -# Proxy protocol, if proxy_protocol_info is present. Optional. -# - PROXY_ADDR: str -# Proxy address, if proxy_protocol_info is present. Optional. -# - PROXY_PORT: str -# Proxy port, if proxy_protocol_info is present. Optional. -# """ - +_EnvironType: TypeAlias = dict[str, Any] # See https://peps.python.org/pep-0333/ _StartResponseType: TypeAlias = Callable[[_StatusType, _HeadersType], None] _ResponseBodyType: TypeAlias = Iterable[bytes] _WSGIAppType: TypeAlias = Callable[[_EnvironType, _StartResponseType], _ResponseBodyType] # noqa: Y047 From 85b153ad9d0d4ac860a82ace1279ddd2e0d453f4 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 19:20:30 +0300 Subject: [PATCH 078/102] [gunicorn] Use collection.abc interface instead of its specific implementations --- stubs/gunicorn/gunicorn/_types.pyi | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index e51b28b077be..cbe38ddfd655 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -1,23 +1,23 @@ ### This .pyi file is a helper for centralized storage types that are reused across different runtime modules. ### - -from collections.abc import Awaitable, Callable, Iterable +from _typeshed import FileDescriptor +from collections.abc import Awaitable, Callable, Iterable, MutableMapping from typing import Any from typing_extensions import LiteralString, TypeAlias _StatusType: TypeAlias = str -_HeadersType: TypeAlias = list[tuple[str, str]] +_HeadersType: TypeAlias = Iterable[tuple[str, str]] -_EnvironType: TypeAlias = dict[str, Any] # See https://peps.python.org/pep-0333/ +_EnvironType: TypeAlias = MutableMapping[str, Any] # See https://peps.python.org/pep-0333/ _StartResponseType: TypeAlias = Callable[[_StatusType, _HeadersType], None] _ResponseBodyType: TypeAlias = Iterable[bytes] _WSGIAppType: TypeAlias = Callable[[_EnvironType, _StartResponseType], _ResponseBodyType] # noqa: Y047 -_ScopeType: TypeAlias = dict[str, Any] -_ReceiveType: TypeAlias = Callable[[], Awaitable[dict[str, Any]]] -_SendType: TypeAlias = Callable[[dict[str, Any]], Awaitable[None]] +_ScopeType: TypeAlias = MutableMapping[str, Any] +_MessageType: TypeAlias = MutableMapping[str, Any] +_ReceiveType: TypeAlias = Callable[[], Awaitable[_MessageType]] +_SendType: TypeAlias = Callable[[_MessageType], Awaitable[None]] _ASGIAppType: TypeAlias = Callable[[_ScopeType, _ReceiveType, _SendType], Awaitable[None]] # noqa: Y047 _UnixSocketPathType: TypeAlias = str -_FileDescriptorType: TypeAlias = int _TcpAddressType: TypeAlias = tuple[LiteralString, int] # noqa: Y047 -_AddressType: TypeAlias = _UnixSocketPathType | _FileDescriptorType | _TcpAddressType # noqa: Y047 +_AddressType: TypeAlias = _UnixSocketPathType | FileDescriptor | _TcpAddressType # noqa: Y047 From 7f4167c65ad06857c815394ee218497ce97aac0a Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 19:33:37 +0300 Subject: [PATCH 079/102] [gunicorn] Change returning from `None` to `object` --- stubs/gunicorn/gunicorn/config.pyi | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 56359c9c0207..4f5259e5c7f5 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -13,22 +13,25 @@ from gunicorn.workers.base import Worker from ._types import _AddressType, _EnvironType -_OnStartingHookType: TypeAlias = Callable[[Arbiter], None] -_OnReloadHookType: TypeAlias = Callable[[Arbiter], None] -_WhenReadyHookType: TypeAlias = Callable[[Arbiter], None] -_PreForkHookType: TypeAlias = Callable[[Arbiter, Worker], None] -_PostForkHookType: TypeAlias = Callable[[Arbiter, Worker], None] -_PostWorkerInitHookType: TypeAlias = Callable[[Worker], None] -_WorkerIntHookType: TypeAlias = Callable[[Worker], None] -_WorkerAbortHookType: TypeAlias = Callable[[Worker], None] -_PreExecHookType: TypeAlias = Callable[[Arbiter], None] -_PreRequestHookType: TypeAlias = Callable[[Worker, Request], None] -_PostRequestHookType: TypeAlias = Callable[[Worker, Request, _EnvironType, Response], None] -_ChildExitHookType: TypeAlias = Callable[[Arbiter, Worker], None] -_WorkerExitHookType: TypeAlias = Callable[[Arbiter, Worker], None] -_NumWorkersChangedHookType: TypeAlias = Callable[[Arbiter, int, int | None], None] -_OnExitHookType: TypeAlias = Callable[[Arbiter], None] +# Hooks +_OnStartingHookType: TypeAlias = Callable[[Arbiter], object] +_OnReloadHookType: TypeAlias = Callable[[Arbiter], object] +_WhenReadyHookType: TypeAlias = Callable[[Arbiter], object] +_PreForkHookType: TypeAlias = Callable[[Arbiter, Worker], object] +_PostForkHookType: TypeAlias = Callable[[Arbiter, Worker], object] +_PostWorkerInitHookType: TypeAlias = Callable[[Worker], object] +_WorkerIntHookType: TypeAlias = Callable[[Worker], object] +_WorkerAbortHookType: TypeAlias = Callable[[Worker], object] +_PreExecHookType: TypeAlias = Callable[[Arbiter], object] +_PreRequestHookType: TypeAlias = Callable[[Worker, Request], object] +_PostRequestHookType: TypeAlias = Callable[[Worker, Request, _EnvironType, Response], object] +_ChildExitHookType: TypeAlias = Callable[[Arbiter, Worker], object] +_WorkerExitHookType: TypeAlias = Callable[[Arbiter, Worker], object] +_NumWorkersChangedHookType: TypeAlias = Callable[[Arbiter, int, int | None], object] +_OnExitHookType: TypeAlias = Callable[[Arbiter], object] _SSLContextHookType: TypeAlias = Callable[[Config, Callable[[], SSLContext]], SSLContext] + +# Validators _BoolValidatorType: TypeAlias = Callable[[bool | str | None], bool | None] _StringValidatorType: TypeAlias = Callable[[str | None], str | None] _ListStringValidatorType: TypeAlias = Callable[[str | list[str] | None], list[str]] From c0294c8ba3dc0df682190c97396489ef0bf05d57 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 19:57:11 +0300 Subject: [PATCH 080/102] [gunicorn] Fix parse_chunked func return type --- stubs/gunicorn/gunicorn/http/body.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/http/body.pyi b/stubs/gunicorn/gunicorn/http/body.pyi index 9537dfcb40ec..cc2735015b6a 100644 --- a/stubs/gunicorn/gunicorn/http/body.pyi +++ b/stubs/gunicorn/gunicorn/http/body.pyi @@ -13,7 +13,7 @@ class ChunkedReader: def __init__(self, req: Request, unreader: Unreader) -> None: ... def read(self, size: int) -> bytes: ... def parse_trailers(self, unreader: Unreader, data: bytes) -> None: ... - def parse_chunked(self, unreader: Unreader) -> Generator[bytes, None, None]: ... + def parse_chunked(self, unreader: Unreader) -> Generator[bytes]: ... def parse_chunk_size(self, unreader: Unreader, data: bytes | None = None) -> tuple[int, bytes | None]: ... def get_data(self, unreader: Unreader, buf: io.BytesIO) -> None: ... From e99ae0d86173d40f872e382d8bc41be759216f5d Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 20:14:42 +0300 Subject: [PATCH 081/102] [gunicorn] Add function signature mapping to logging.Logger --- stubs/gunicorn/gunicorn/glogging.pyi | 72 ++++++++++++++-- stubs/gunicorn/gunicorn/instrument/statsd.pyi | 82 +++++++++++++++++-- 2 files changed, 138 insertions(+), 16 deletions(-) diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 579cdbd2a74e..f5fde561830a 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -1,5 +1,6 @@ import logging import threading +from collections.abc import Mapping from datetime import timedelta from logging.config import _DictConfigArgs from socket import SocketKind @@ -86,13 +87,70 @@ class Logger: def __init__(self, cfg: Config) -> None: ... def setup(self, cfg: Config) -> None: ... - def critical(self, msg: str, *args: Any, **kwargs: Any) -> None: ... - def error(self, msg: str, *args: Any, **kwargs: Any) -> None: ... - def warning(self, msg: str, *args: Any, **kwargs: Any) -> None: ... - def info(self, msg: str, *args: Any, **kwargs: Any) -> None: ... - def debug(self, msg: str, *args: Any, **kwargs: Any) -> None: ... - def exception(self, msg: str, *args: Any, **kwargs: Any) -> None: ... - def log(self, lvl: _LogLevelType, msg: str, *args: Any, **kwargs: Any) -> None: ... + def critical( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... + def error( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... + def warning( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... + def info( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... + def debug( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... + def exception( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = True, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... + def log( + self, + lvl: _LogLevelType, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... def atoms(self, resp: Response, req: Request, environ: _EnvironType, request_time: timedelta) -> _AtomsDict: ... def access(self, resp: Response, req: Request, environ: _EnvironType, request_time: timedelta) -> None: ... def now(self) -> str: ... diff --git a/stubs/gunicorn/gunicorn/instrument/statsd.pyi b/stubs/gunicorn/gunicorn/instrument/statsd.pyi index bb0d7b29f31a..cc00ba875fc4 100644 --- a/stubs/gunicorn/gunicorn/instrument/statsd.pyi +++ b/stubs/gunicorn/gunicorn/instrument/statsd.pyi @@ -1,6 +1,7 @@ +import logging import socket +from collections.abc import Mapping from datetime import timedelta -from typing import Any from typing_extensions import override from gunicorn.config import Config @@ -26,21 +27,84 @@ class Statsd(Logger): def __init__(self, cfg: Config) -> None: ... @override - def critical(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def critical( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... @override - def error(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def error( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... @override - def warning(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def warning( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... @override - def exception(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def info( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... @override - def info(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def debug( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... @override - def debug(self, msg: str, *args: Any, **kwargs: Any) -> None: ... + def exception( + self, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = True, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... @override - def log(self, lvl: _LogLevelType, msg: str, *args: Any, **kwargs: Any) -> None: ... + def log( + self, + lvl: _LogLevelType, + msg: object, + *args: object, + exc_info: logging._ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... @override - def access(self, resp: Response, req: Request, environ: _EnvironType, request_time: timedelta) -> None: ... + def access( + self, + resp: Response, + req: Request, + environ: _EnvironType, + request_time: timedelta, + ) -> None: ... def gauge(self, name: str, value: float) -> None: ... def increment(self, name: str, value: int, sampling_rate: float = 1.0) -> None: ... def decrement(self, name: str, value: int, sampling_rate: float = 1.0) -> None: ... From 8564c9f5cc369fe063a19d70f1a1b5cd94ca8042 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 22:38:23 +0300 Subject: [PATCH 082/102] [gunicorn] Add stubs for respiter arg --- stubs/gunicorn/gunicorn/workers/base_async.pyi | 4 +--- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/stubs/gunicorn/gunicorn/workers/base_async.pyi b/stubs/gunicorn/gunicorn/workers/base_async.pyi index 96f8206ed30b..6b8523770077 100644 --- a/stubs/gunicorn/gunicorn/workers/base_async.pyi +++ b/stubs/gunicorn/gunicorn/workers/base_async.pyi @@ -1,5 +1,4 @@ import socket -from typing import Any from gunicorn.http import Request from gunicorn.workers import base @@ -12,8 +11,7 @@ class AsyncWorker(base.Worker): worker_connections: int alive: bool - def __init__(self, *args: Any, **kwargs: Any) -> None: ... def timeout_ctx(self) -> None: ... - def is_already_handled(self, respiter: Any) -> bool: ... + def is_already_handled(self, respiter: object) -> bool: ... def handle(self, listener: socket.socket, client: socket.socket, addr: _AddressType) -> None: ... def handle_request(self, listener_name: str, req: Request, sock: socket.socket, addr: _AddressType) -> bool: ... diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index e3c23e51c029..5bbcd54c432d 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -16,7 +16,7 @@ def patch_sendfile() -> None: ... class EventletWorker(AsyncWorker): def patch(self) -> None: ... @override - def is_already_handled(self, respiter: Any) -> bool: ... + def is_already_handled(self, respiter: object) -> bool: ... @override def init_process(self) -> None: ... @override From f3d740ea47f488d59f8a6a5d7d11f7471bb3ba82 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 22:40:08 +0300 Subject: [PATCH 083/102] [gunicorn] Delete __init__ method from ThreadWorker --- stubs/gunicorn/gunicorn/workers/gthread.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/workers/gthread.pyi b/stubs/gunicorn/gunicorn/workers/gthread.pyi index 61a558e284cd..bcbfb540d0bd 100644 --- a/stubs/gunicorn/gunicorn/workers/gthread.pyi +++ b/stubs/gunicorn/gunicorn/workers/gthread.pyi @@ -35,7 +35,6 @@ class ThreadWorker(base.Worker): nr_conns: int alive: bool - def __init__(self, *args: Any, **kwargs: Any) -> None: ... @classmethod def check_config(cls, cfg: Config, log: GLogger) -> None: ... def init_process(self) -> None: ... From f0a76859c56786795b04b3f924ae2c1459f7ad2f Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 22:58:20 +0300 Subject: [PATCH 084/102] [gunicorn] Add _ConfigValueType --- stubs/gunicorn/gunicorn/config.pyi | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 4f5259e5c7f5..5453bb0c57cd 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -13,7 +13,11 @@ from gunicorn.workers.base import Worker from ._types import _AddressType, _EnvironType -# Hooks +_ConfigValueType: TypeAlias = Any +# Any: Value type depends on the setting's validator (e.g., validate_bool, validate_pos_int). +# Maybe types: bool, int, str, list[str], dict[str, Any], Callable[..., object], type[object], ssl.PROTOCOL_*. +# Validator ensures type correctness at runtime. + _OnStartingHookType: TypeAlias = Callable[[Arbiter], object] _OnReloadHookType: TypeAlias = Callable[[Arbiter], object] _WhenReadyHookType: TypeAlias = Callable[[Arbiter], object] @@ -57,7 +61,7 @@ class Config: def __getattr__(self, name: str) -> Any: ... @override def __setattr__(self, name: str, value: Any) -> None: ... - def set(self, name: str, value: Any) -> None: ... + def set(self, name: str, value: _ConfigValueType) -> None: ... def get_cmd_args_from_env(self) -> list[str]: ... def parser(self) -> argparse.ArgumentParser: ... @property @@ -93,7 +97,7 @@ class SettingMeta(type): class Setting(metaclass=SettingMeta): name: ClassVar[str | None] - value: Any + value: _ConfigValueType section: ClassVar[str | None] cli: ClassVar[list[str] | None] validator: ClassVar[Callable[..., Any] | None] @@ -110,8 +114,8 @@ class Setting(metaclass=SettingMeta): def __init__(self) -> None: ... def add_option(self, parser: argparse.ArgumentParser) -> None: ... def copy(self) -> Setting: ... - def get(self) -> Any: ... - def set(self, val: Any) -> None: ... + def get(self) -> _ConfigValueType: ... + def set(self, val: _ConfigValueType) -> None: ... def __lt__(self, other: Setting) -> bool: ... __cmp__ = __lt__ From d3cc1e2720e2090db04d19a7a0b7b7d32c2ea5e7 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 23:27:40 +0300 Subject: [PATCH 085/102] [gunicorn] Add _AnyValidatorType --- stubs/gunicorn/gunicorn/config.pyi | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 5453bb0c57cd..752e03c601f2 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -45,6 +45,17 @@ _ClassValidatorType: TypeAlias = Callable[[object | str | None], type[Any] | Non _UserGroupValidatorType: TypeAlias = Callable[[str | int | None], int] _AddressValidatorType: TypeAlias = Callable[[str | None], _AddressType | None] +_AnyValidatorType: TypeAlias = ( + _BoolValidatorType + | _StringValidatorType + | _ListStringValidatorType + | _IntValidatorType + | _DictValidatorType + | _ClassValidatorType + | _UserGroupValidatorType + | _AddressValidatorType +) + KNOWN_SETTINGS: list[Setting] PLATFORM: str @@ -100,8 +111,7 @@ class Setting(metaclass=SettingMeta): value: _ConfigValueType section: ClassVar[str | None] cli: ClassVar[list[str] | None] - validator: ClassVar[Callable[..., Any] | None] - type: ClassVar[type[Any] | Callable[..., Any] | None] + validator: ClassVar[_AnyValidatorType | None] meta: ClassVar[str | None] action: ClassVar[str | None] default: ClassVar[Any] From d497e64ab020ee1dc97727c7f052d009750f5f45 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 23:29:09 +0300 Subject: [PATCH 086/102] [gunicorn] Fix Setting.type stub --- stubs/gunicorn/gunicorn/config.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 752e03c601f2..5ce0507e6a1a 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -112,6 +112,7 @@ class Setting(metaclass=SettingMeta): section: ClassVar[str | None] cli: ClassVar[list[str] | None] validator: ClassVar[_AnyValidatorType | None] + type: ClassVar[argparse._ActionType | None] meta: ClassVar[str | None] action: ClassVar[str | None] default: ClassVar[Any] From c917fa4ce12132e3c20d171e000fcd53d80405c2 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 23:35:30 +0300 Subject: [PATCH 087/102] [gunicorn] Delete Any annotations from validators --- stubs/gunicorn/gunicorn/config.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 5ce0507e6a1a..0d30d5fd9186 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -45,7 +45,7 @@ _ClassValidatorType: TypeAlias = Callable[[object | str | None], type[Any] | Non _UserGroupValidatorType: TypeAlias = Callable[[str | int | None], int] _AddressValidatorType: TypeAlias = Callable[[str | None], _AddressType | None] -_AnyValidatorType: TypeAlias = ( +_ValidatorType: TypeAlias = ( _BoolValidatorType | _StringValidatorType | _ListStringValidatorType @@ -111,7 +111,7 @@ class Setting(metaclass=SettingMeta): value: _ConfigValueType section: ClassVar[str | None] cli: ClassVar[list[str] | None] - validator: ClassVar[_AnyValidatorType | None] + validator: ClassVar[_ValidatorType | None] type: ClassVar[argparse._ActionType | None] meta: ClassVar[str | None] action: ClassVar[str | None] @@ -158,15 +158,15 @@ def validate_list_of_existing_files(val: None) -> list[str]: ... def validate_string_to_addr_list(val: str | None) -> list[str]: ... def validate_string_to_list(val: str | None) -> list[str]: ... @overload -def validate_class(val: str) -> type[Any]: ... +def validate_class(val: str) -> str: ... @overload def validate_class(val: None) -> None: ... @overload -def validate_class(val: object) -> type[Any]: ... -def validate_callable(arity: int) -> Callable[[str | Callable[..., Any]], Callable[..., Any]]: ... +def validate_class(val: object) -> object: ... +def validate_callable(arity: int) -> Callable[[str | _ValidatorType], _ValidatorType]: ... def validate_user(val: int | str | None) -> int: ... def validate_group(val: int | str | None) -> int: ... -def validate_post_request(val: str | Callable[..., Any]) -> _PostRequestHookType: ... +def validate_post_request(val: str | _ValidatorType) -> _PostRequestHookType: ... def validate_chdir(val: str) -> str: ... @overload def validate_statsd_address(val: str) -> _AddressType: ... From 07a1f3ce30f8d32a4c6352bc9ebbe2e6490089bf Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 23:37:53 +0300 Subject: [PATCH 088/102] [gunicorn] Add comment for `Any` annotation --- stubs/gunicorn/gunicorn/debug.pyi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/debug.pyi b/stubs/gunicorn/gunicorn/debug.pyi index f4fa97c10f3e..8eb3ff642c20 100644 --- a/stubs/gunicorn/gunicorn/debug.pyi +++ b/stubs/gunicorn/gunicorn/debug.pyi @@ -10,7 +10,12 @@ class Spew: show_values: bool def __init__(self, trace_names: Container[str] | None = None, show_values: bool = True) -> None: ... - def __call__(self, frame: FrameType, event: str, arg: Any) -> Self: ... + def __call__( + self, + frame: FrameType, + event: str, + arg: Any, # `arg` is not used inside the function, stub is set Any + ) -> Self: ... def spew(trace_names: Container[str] | None = None, show_values: bool = False) -> None: ... def unspew() -> None: ... From 60c219f975d0f9b17d96e5822005eace3819d666 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 23:54:41 +0300 Subject: [PATCH 089/102] [gunicorn] Fix validate_callable annotation --- stubs/gunicorn/gunicorn/config.pyi | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 0d30d5fd9186..1f2b8209b5ae 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -35,6 +35,24 @@ _NumWorkersChangedHookType: TypeAlias = Callable[[Arbiter, int, int | None], obj _OnExitHookType: TypeAlias = Callable[[Arbiter], object] _SSLContextHookType: TypeAlias = Callable[[Config, Callable[[], SSLContext]], SSLContext] +_HookType: TypeAlias = ( + _OnStartingHookType + | _OnReloadHookType + | _WhenReadyHookType + | _PreForkHookType + | _PostForkHookType + | _PostWorkerInitHookType + | _WorkerIntHookType + | _WorkerAbortHookType + | _PreExecHookType + | _PreRequestHookType + | _PostRequestHookType + | _ChildExitHookType + | _WorkerExitHookType + | _NumWorkersChangedHookType + | _OnExitHookType + | _SSLContextHookType +) # Validators _BoolValidatorType: TypeAlias = Callable[[bool | str | None], bool | None] _StringValidatorType: TypeAlias = Callable[[str | None], str | None] @@ -163,7 +181,7 @@ def validate_class(val: str) -> str: ... def validate_class(val: None) -> None: ... @overload def validate_class(val: object) -> object: ... -def validate_callable(arity: int) -> Callable[[str | _ValidatorType], _ValidatorType]: ... +def validate_callable(arity: int) -> Callable[[str | _HookType], _HookType]: ... def validate_user(val: int | str | None) -> int: ... def validate_group(val: int | str | None) -> int: ... def validate_post_request(val: str | _ValidatorType) -> _PostRequestHookType: ... From 448c4bb54b40e19faaf5ed6d0e1c1d3fbdbd7334 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Fri, 19 Sep 2025 23:55:55 +0300 Subject: [PATCH 090/102] [gunicorn] Fix load_entry_point `Any` return annotation --- stubs/gunicorn/gunicorn/util.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index e837de8f0958..5ed25d5b03fd 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -1,24 +1,24 @@ import types from _typeshed import FileDescriptorLike, FileDescriptorOrPath, HasFileno, StrOrBytesPath -from collections.abc import Callable from inspect import _ParameterKind from socket import socket from typing import Any, Literal, NoReturn from urllib.parse import SplitResult from ._types import _AddressType, _WSGIAppType +from .config import _HookType REDIRECT_TO: str hop_headers: set[str] -def load_entry_point(distribution: str, group: str, name: str) -> Any: ... +def load_entry_point(distribution: str, group: str, name: str) -> type[object]: ... def load_class( uri: str | object, default: str = "gunicorn.workers.sync.SyncWorker", section: str = "gunicorn.workers" ) -> type[Any]: ... positionals: tuple[Literal[_ParameterKind.POSITIONAL_ONLY], Literal[_ParameterKind.POSITIONAL_OR_KEYWORD]] -def get_arity(f: Callable[..., Any]) -> int: ... +def get_arity(f: _HookType) -> int: ... def get_username(uid: int) -> str: ... def set_owner_process(uid: int, gid: int, initgroups: bool = False) -> None: ... def chown(path: FileDescriptorOrPath, uid: int, gid: int) -> None: ... From 343f4f440b71b53123ffe9ee9026d2c63454e19a Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 00:19:56 +0300 Subject: [PATCH 091/102] [gunicorn] Fix validate_post_request annotation --- stubs/gunicorn/gunicorn/config.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 1f2b8209b5ae..b3aa49bf8c7f 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -184,7 +184,7 @@ def validate_class(val: object) -> object: ... def validate_callable(arity: int) -> Callable[[str | _HookType], _HookType]: ... def validate_user(val: int | str | None) -> int: ... def validate_group(val: int | str | None) -> int: ... -def validate_post_request(val: str | _ValidatorType) -> _PostRequestHookType: ... +def validate_post_request(val: str | _HookType) -> _PostRequestHookType: ... def validate_chdir(val: str) -> str: ... @overload def validate_statsd_address(val: str) -> _AddressType: ... From 32434311bfffc1c2843c49ebe3fa54d15e19623e Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 00:20:07 +0300 Subject: [PATCH 092/102] [gunicorn] Add `_CallableValidatorType` type --- stubs/gunicorn/gunicorn/config.pyi | 36 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index b3aa49bf8c7f..27f2b72886b9 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -62,6 +62,7 @@ _DictValidatorType: TypeAlias = Callable[[dict[str, Any]], dict[str, Any]] _ClassValidatorType: TypeAlias = Callable[[object | str | None], type[Any] | None] _UserGroupValidatorType: TypeAlias = Callable[[str | int | None], int] _AddressValidatorType: TypeAlias = Callable[[str | None], _AddressType | None] +_CallableValidatorType: TypeAlias = Callable[[str | _HookType], _HookType] _ValidatorType: TypeAlias = ( _BoolValidatorType @@ -72,6 +73,7 @@ _ValidatorType: TypeAlias = ( | _ClassValidatorType | _UserGroupValidatorType | _AddressValidatorType + | _CallableValidatorType ) KNOWN_SETTINGS: list[Setting] @@ -181,7 +183,7 @@ def validate_class(val: str) -> str: ... def validate_class(val: None) -> None: ... @overload def validate_class(val: object) -> object: ... -def validate_callable(arity: int) -> Callable[[str | _HookType], _HookType]: ... +def validate_callable(arity: int) -> _CallableValidatorType: ... def validate_user(val: int | str | None) -> int: ... def validate_group(val: int | str | None) -> int: ... def validate_post_request(val: str | _HookType) -> _PostRequestHookType: ... @@ -741,7 +743,7 @@ class Paste(Setting): class OnStarting(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _OnStartingHookType], _OnStartingHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_OnStartingHookType] desc: ClassVar[str] @@ -751,7 +753,7 @@ class OnStarting(Setting): class OnReload(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _OnReloadHookType], _OnReloadHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_OnReloadHookType] desc: ClassVar[str] @@ -761,7 +763,7 @@ class OnReload(Setting): class WhenReady(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _WhenReadyHookType], _WhenReadyHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_WhenReadyHookType] desc: ClassVar[str] @@ -771,7 +773,7 @@ class WhenReady(Setting): class Prefork(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _PreForkHookType], _PreForkHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_PreForkHookType] desc: ClassVar[str] @@ -781,7 +783,7 @@ class Prefork(Setting): class Postfork(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _PostForkHookType], _PostForkHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_PostForkHookType] desc: ClassVar[str] @@ -791,7 +793,7 @@ class Postfork(Setting): class PostWorkerInit(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _PostWorkerInitHookType], _PostWorkerInitHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_PostWorkerInitHookType] desc: ClassVar[str] @@ -801,7 +803,7 @@ class PostWorkerInit(Setting): class WorkerInt(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _WorkerIntHookType], _WorkerIntHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_WorkerIntHookType] desc: ClassVar[str] @@ -811,7 +813,7 @@ class WorkerInt(Setting): class WorkerAbort(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _WorkerAbortHookType], _WorkerAbortHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_WorkerAbortHookType] desc: ClassVar[str] @@ -821,7 +823,7 @@ class WorkerAbort(Setting): class PreExec(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _PreExecHookType], _PreExecHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_PreExecHookType] desc: ClassVar[str] @@ -831,7 +833,7 @@ class PreExec(Setting): class PreRequest(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _PreRequestHookType], _PreRequestHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_PreRequestHookType] desc: ClassVar[str] @@ -841,7 +843,7 @@ class PreRequest(Setting): class PostRequest(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | Callable[..., Any]], _PostRequestHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_PostRequestHookType] desc: ClassVar[str] @@ -851,7 +853,7 @@ class PostRequest(Setting): class ChildExit(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _ChildExitHookType], _ChildExitHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_ChildExitHookType] desc: ClassVar[str] @@ -861,7 +863,7 @@ class ChildExit(Setting): class WorkerExit(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _WorkerExitHookType], _WorkerExitHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_WorkerExitHookType] desc: ClassVar[str] @@ -871,7 +873,7 @@ class WorkerExit(Setting): class NumWorkersChanged(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _NumWorkersChangedHookType], _NumWorkersChangedHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_NumWorkersChangedHookType] desc: ClassVar[str] @@ -881,7 +883,7 @@ class NumWorkersChanged(Setting): class OnExit(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _OnExitHookType], _OnExitHookType]] + validator: ClassVar[_CallableValidatorType] default: ClassVar[_OnExitHookType] desc: ClassVar[str] @@ -890,7 +892,7 @@ class OnExit(Setting): class NewSSLContext(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[Callable[[str | _SSLContextHookType], _SSLContextHookType]] + validator: ClassVar[_CallableValidatorType] type: ClassVar[Callable[..., Any]] default: ClassVar[_SSLContextHookType] desc: ClassVar[str] From 1d41e83ccf761e87a97b351d49e7df4c0c66af07 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 00:59:26 +0300 Subject: [PATCH 093/102] [gunicorn] Change Setting.validator to common stub with comment --- stubs/gunicorn/gunicorn/config.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 27f2b72886b9..5d684c80b6e2 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -131,7 +131,7 @@ class Setting(metaclass=SettingMeta): value: _ConfigValueType section: ClassVar[str | None] cli: ClassVar[list[str] | None] - validator: ClassVar[_ValidatorType | None] + validator: ClassVar[Callable[..., Any] | None] # See `_ValidatorType` type: ClassVar[argparse._ActionType | None] meta: ClassVar[str | None] action: ClassVar[str | None] From a365ecc3f7f5a748fa4864bd7fd3a813f5c205c3 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 01:25:05 +0300 Subject: [PATCH 094/102] [gunicorn] Add @overload decorators to validate_bool, validate_string, validate_file_exists --- stubs/gunicorn/gunicorn/config.pyi | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 5d684c80b6e2..662e6ae258c1 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -2,8 +2,8 @@ import argparse from _typeshed import ConvertibleToInt from collections.abc import Callable, Container from ssl import SSLContext, _SSLMethod -from typing import Any, ClassVar, overload -from typing_extensions import TypeAlias, override +from typing import Annotated, Any, ClassVar +from typing_extensions import TypeAlias, overload, override from gunicorn.arbiter import Arbiter from gunicorn.glogging import Logger as GLogger @@ -131,7 +131,7 @@ class Setting(metaclass=SettingMeta): value: _ConfigValueType section: ClassVar[str | None] cli: ClassVar[list[str] | None] - validator: ClassVar[Callable[..., Any] | None] # See `_ValidatorType` + validator: ClassVar[Callable[..., Any] | None] # See `_ValidatorType` type: ClassVar[argparse._ActionType | None] meta: ClassVar[str | None] action: ClassVar[str | None] @@ -154,15 +154,23 @@ class Setting(metaclass=SettingMeta): @overload def validate_bool(val: bool) -> bool: ... @overload -def validate_bool(val: str | None) -> bool | None: ... +def validate_bool(val: None) -> None: ... +@overload +def validate_bool(val: Annotated[str, "Case-insensitive boolean string ('true'/'false' in any case)"]) -> bool: ... def validate_dict(val: dict[str, Any]) -> dict[str, Any]: ... @overload def validate_pos_int(val: int) -> int: ... @overload def validate_pos_int(val: ConvertibleToInt) -> int: ... def validate_ssl_version(val: _SSLMethod) -> _SSLMethod: ... -def validate_string(val: str | None) -> str | None: ... -def validate_file_exists(val: str | None) -> str | None: ... +@overload +def validate_string(val: str) -> str: ... +@overload +def validate_string(val: None) -> None: ... +@overload +def validate_file_exists(val: str) -> str: ... +@overload +def validate_file_exists(val: None) -> None: ... @overload def validate_list_string(val: str) -> list[str]: ... @overload @@ -743,7 +751,7 @@ class Paste(Setting): class OnStarting(Setting): name: ClassVar[str] section: ClassVar[str] - validator: ClassVar[_CallableValidatorType] + validator: ClassVar[_CallableValidatorType] = ... type: ClassVar[Callable[..., Any]] default: ClassVar[_OnStartingHookType] desc: ClassVar[str] From b0735d15098eb10ddf107daf1f8fc933dc3b8c2d Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 01:37:10 +0300 Subject: [PATCH 095/102] [gunicorn] run `pre-commit run --all-files` --- stubs/gunicorn/gunicorn/config.pyi | 6 +++--- stubs/gunicorn/gunicorn/debug.pyi | 5 +---- stubs/gunicorn/gunicorn/instrument/statsd.pyi | 8 +------- stubs/gunicorn/gunicorn/reloader.pyi | 4 ++-- stubs/gunicorn/gunicorn/workers/gthread.pyi | 1 - 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index 662e6ae258c1..f3f638538f49 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -2,8 +2,8 @@ import argparse from _typeshed import ConvertibleToInt from collections.abc import Callable, Container from ssl import SSLContext, _SSLMethod -from typing import Annotated, Any, ClassVar -from typing_extensions import TypeAlias, overload, override +from typing import Annotated, Any, ClassVar, overload +from typing_extensions import TypeAlias, override from gunicorn.arbiter import Arbiter from gunicorn.glogging import Logger as GLogger @@ -64,7 +64,7 @@ _UserGroupValidatorType: TypeAlias = Callable[[str | int | None], int] _AddressValidatorType: TypeAlias = Callable[[str | None], _AddressType | None] _CallableValidatorType: TypeAlias = Callable[[str | _HookType], _HookType] -_ValidatorType: TypeAlias = ( +_ValidatorType: TypeAlias = ( # noqa: Y047 _BoolValidatorType | _StringValidatorType | _ListStringValidatorType diff --git a/stubs/gunicorn/gunicorn/debug.pyi b/stubs/gunicorn/gunicorn/debug.pyi index 8eb3ff642c20..8769f873c587 100644 --- a/stubs/gunicorn/gunicorn/debug.pyi +++ b/stubs/gunicorn/gunicorn/debug.pyi @@ -11,10 +11,7 @@ class Spew: def __init__(self, trace_names: Container[str] | None = None, show_values: bool = True) -> None: ... def __call__( - self, - frame: FrameType, - event: str, - arg: Any, # `arg` is not used inside the function, stub is set Any + self, frame: FrameType, event: str, arg: Any # `arg` is not used inside the function, stub is set Any ) -> Self: ... def spew(trace_names: Container[str] | None = None, show_values: bool = False) -> None: ... diff --git a/stubs/gunicorn/gunicorn/instrument/statsd.pyi b/stubs/gunicorn/gunicorn/instrument/statsd.pyi index cc00ba875fc4..94b8ca80d018 100644 --- a/stubs/gunicorn/gunicorn/instrument/statsd.pyi +++ b/stubs/gunicorn/gunicorn/instrument/statsd.pyi @@ -98,13 +98,7 @@ class Statsd(Logger): extra: Mapping[str, object] | None = None, ) -> None: ... @override - def access( - self, - resp: Response, - req: Request, - environ: _EnvironType, - request_time: timedelta, - ) -> None: ... + def access(self, resp: Response, req: Request, environ: _EnvironType, request_time: timedelta) -> None: ... def gauge(self, name: str, value: float) -> None: ... def increment(self, name: str, value: int, sampling_rate: float = 1.0) -> None: ... def decrement(self, name: str, value: int, sampling_rate: float = 1.0) -> None: ... diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index a49e138f1318..7fe7f30ec1e2 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -2,8 +2,8 @@ import sys import threading from collections.abc import Callable, Iterable from re import Pattern -from typing import TypedDict, type_check_only -from typing_extensions import TypeAlias, override, NoReturn +from typing import NoReturn, TypedDict, type_check_only +from typing_extensions import TypeAlias, override COMPILED_EXT_RE: Pattern[str] diff --git a/stubs/gunicorn/gunicorn/workers/gthread.pyi b/stubs/gunicorn/gunicorn/workers/gthread.pyi index bcbfb540d0bd..c3057c7e26b5 100644 --- a/stubs/gunicorn/gunicorn/workers/gthread.pyi +++ b/stubs/gunicorn/gunicorn/workers/gthread.pyi @@ -3,7 +3,6 @@ from collections import deque from concurrent.futures import Future, ThreadPoolExecutor from selectors import DefaultSelector from types import FrameType -from typing import Any from gunicorn.config import Config from gunicorn.glogging import Logger as GLogger From 588640aae10332e6c3f714f2450483565e7a76c5 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 01:57:25 +0300 Subject: [PATCH 096/102] [gunicorn] Remove extra argument --- stubs/gunicorn/gunicorn/reloader.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index 7fe7f30ec1e2..e666355e2638 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -34,7 +34,7 @@ if sys.platform == "linux": else: class InotifyReloader: def __init__( - self, extra_files: Iterable[str] | None = None, interval: int = 1, callback: Callable[[str], None] | None = None + self, extra_files: Iterable[str] | None = None, callback: Callable[[str], None] | None = None ) -> NoReturn: ... _PreferredReloaderType: TypeAlias = type[InotifyReloader | Reloader] From e1344794628e7f0f7e3c6b17f889b9b95c66dc02 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 02:04:23 +0300 Subject: [PATCH 097/102] [gunicorn] delete allowlist darwin --- stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt b/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt index 15a1a1e74ce0..e69de29bb2d1 100644 --- a/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt +++ b/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt @@ -1,6 +0,0 @@ -# InotifyReloader methods are absent on Darwin because inotify is Linux-only. -# Defined in stub for type checking, but missing in runtime, causing stubtest errors. - -gunicorn.reloader.InotifyReloader.add_extra_file -gunicorn.reloader.InotifyReloader.get_dirs -gunicorn.reloader.InotifyReloader.run From abd30fb19e415650b31461ebb7dd190648d3b595 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 02:04:35 +0300 Subject: [PATCH 098/102] [gunicorn] add comment about gunicorn.__main__ --- stubs/gunicorn/@tests/stubtest_allowlist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/gunicorn/@tests/stubtest_allowlist.txt b/stubs/gunicorn/@tests/stubtest_allowlist.txt index 309ce487f84d..47e466ac9ec9 100644 --- a/stubs/gunicorn/@tests/stubtest_allowlist.txt +++ b/stubs/gunicorn/@tests/stubtest_allowlist.txt @@ -1,4 +1,5 @@ # Is not present in runtime. For more details, see the file itself. gunicorn._types +# .pyi file doesn't exist gunicorn.__main__ From 79b3948788e9ab8ce83e084261f510171f64a656 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 11:25:14 +0300 Subject: [PATCH 099/102] [gunicorn] Fix 'get_arity' func 'f' annotation --- stubs/gunicorn/gunicorn/util.pyi | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stubs/gunicorn/gunicorn/util.pyi b/stubs/gunicorn/gunicorn/util.pyi index 5ed25d5b03fd..5ec09516cb2f 100644 --- a/stubs/gunicorn/gunicorn/util.pyi +++ b/stubs/gunicorn/gunicorn/util.pyi @@ -1,12 +1,11 @@ import types from _typeshed import FileDescriptorLike, FileDescriptorOrPath, HasFileno, StrOrBytesPath -from inspect import _ParameterKind +from inspect import _IntrospectableCallable, _ParameterKind from socket import socket from typing import Any, Literal, NoReturn from urllib.parse import SplitResult from ._types import _AddressType, _WSGIAppType -from .config import _HookType REDIRECT_TO: str hop_headers: set[str] @@ -18,7 +17,7 @@ def load_class( positionals: tuple[Literal[_ParameterKind.POSITIONAL_ONLY], Literal[_ParameterKind.POSITIONAL_OR_KEYWORD]] -def get_arity(f: _HookType) -> int: ... +def get_arity(f: _IntrospectableCallable) -> int: ... def get_username(uid: int) -> str: ... def set_owner_process(uid: int, gid: int, initgroups: bool = False) -> None: ... def chown(path: FileDescriptorOrPath, uid: int, gid: int) -> None: ... From d7aeca808d2a0426a5b813b39cf9f3f6e0b811ed Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 11:25:53 +0300 Subject: [PATCH 100/102] [gunicorn] Fix 'SettingMeta' method '__new__' return type --- stubs/gunicorn/gunicorn/config.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index f3f638538f49..c1420b1714c4 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -123,7 +123,7 @@ class Config: def paste_global_conf(self) -> dict[str, str] | None: ... class SettingMeta(type): - def __new__(cls, name: str, bases: tuple[type, ...], attrs: dict[str, Any]) -> type: ... + def __new__(cls, name: str, bases: tuple[type, ...], attrs: dict[str, Any]) -> SettingMeta: ... def fmt_desc(cls, desc: str) -> None: ... class Setting(metaclass=SettingMeta): From aea18a24b1617f3103722493855a8a0fe7057266 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 11:37:48 +0300 Subject: [PATCH 101/102] [gunicorn] Fix '__version__' type --- stubs/gunicorn/gunicorn/__init__.pyi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stubs/gunicorn/gunicorn/__init__.pyi b/stubs/gunicorn/gunicorn/__init__.pyi index a5d6a2090a23..dff515c23298 100644 --- a/stubs/gunicorn/gunicorn/__init__.pyi +++ b/stubs/gunicorn/gunicorn/__init__.pyi @@ -1,6 +1,4 @@ -from typing_extensions import LiteralString - version_info: tuple[int, int, int] -__version__: LiteralString +__version__: str SERVER: str SERVER_SOFTWARE: str From 003db6a2acfd0ce319a0765d32b95b53a2882c38 Mon Sep 17 00:00:00 2001 From: Eugene Liukin Date: Sat, 20 Sep 2025 12:57:50 +0300 Subject: [PATCH 102/102] [gunicorn] Delete stubtest_allowlist_darwin.txt --- stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt diff --git a/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt b/stubs/gunicorn/@tests/stubtest_allowlist_darwin.txt deleted file mode 100644 index e69de29bb2d1..000000000000