{"id":28423,"library":"types-gunicorn","title":"types-gunicorn","description":"Typing stubs for gunicorn (version 25.3.0.20260508). Provides type annotations for gunicorn's API, enabling static type checking in Python projects. Part of the typeshed project and updated regularly to match new gunicorn releases.","status":"active","version":"25.3.0.20260508","language":"python","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","gunicorn","type-hints","python"],"install":[{"cmd":"pip install types-gunicorn","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Runtime dependency; stubs only provide type information, gunicorn must be installed to actually run.","package":"gunicorn","optional":false}],"imports":[{"note":"No common mistake; import is straightforward.","wrong":"import gunicorn as gunicorn","symbol":"gunicorn","correct":"import gunicorn"}],"quickstart":{"code":"import gunicorn\nfrom gunicorn.app.base import BaseApplication\n\nclass MyApp(BaseApplication):\n    def __init__(self, app, options=None):\n        self.application = app\n        self.options = options or {}\n        super().__init__()\n\n    def load_config(self):\n        cfg = self.cfg\n        for key, value in self.options.items():\n            if key in cfg.settings:\n                cfg.set(key.lower(), value)\n\n    def load(self):\n        return self.application\n\ndef dummy_app(environ, start_response):\n    start_response('200 OK', [('Content-Type', 'text/plain')])\n    return [b'Hello, World!']\n\nif __name__ == '__main__':\n    app = MyApp(dummy_app, {'bind': 'localhost:8000', 'workers': 2})\n    app.run()","lang":"python","description":"Creates a minimal gunicorn application using BaseApplication with proper type annotations."},"warnings":[{"fix":"Run pip install gunicorn types-gunicorn.","message":"Stubs are not a runtime replacement: installing types-gunicorn does not install gunicorn itself. You must separately install gunicorn (e.g., pip install gunicorn).","severity":"gotcha","affected_versions":"all"},{"fix":"Use >= matching, e.g., types-gunicorn>=25.3.0, to get latest stubs for that gunicorn version.","message":"The stub version numbers follow the pattern MAJOR.MINOR.PATCH.DATE, where the first three components correspond to the gunicorn version they are bundled with. Do not pin stubs to an exact date unless necessary; they are forward-compatible with that gunicorn major/minor.","severity":"gotcha","affected_versions":"all"},{"fix":"When type errors occur on valid gunicorn code, add a comment to ignore the line, e.g., # type: ignore[attr-defined].","message":"Third-party stubs (like types-*) are unofficial and may have incomplete coverage or minor mismatches with gunicorn internals. For dynamic attributes, you may need to add # type: ignore.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use 'from gunicorn import SERVER_SOFTWARE' if it exists at runtime, and add a type: ignore if needed.","cause":"The stub file for gunicorn does not expose the _gunicorn module or some internal constants.","error":"Module 'gunicorn' has no attribute 'SERVER_SOFTWARE'"},{"fix":"Ensure you have imported from gunicorn.app.base import BaseApplication, not gunicorn.app.BaseApplication.","cause":"Missing stub for gunicorn.app or incorrect import path.","error":"Cannot find reference 'BaseApplication' in 'gunicorn.app'"},{"fix":"Explicitly annotate variables or use --strict-optional to enforce type checking.","cause":"Stubs may not cover all gunicorn internals; type checker infers Any for some parts.","error":"Type of 'app' is partially unknown"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}