{"id":8739,"library":"types-chevron","title":"Typing Stubs for Chevron","description":"types-chevron is a PEP 561 type stub package that provides static type annotations for the `chevron` templating library. It is part of the `typeshed` project, the central repository for third-party library stubs, and is used by static analysis tools like mypy, pyright, and PyCharm to enable type checking and autocompletion for code using `chevron`. This package specifically targets type annotations for `chevron` version `0.14.*`. It is actively maintained with daily releases from typeshed.","status":"active","version":"0.14.2.20260408","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","type hints","typeshed","chevron","templating"],"install":[{"cmd":"pip install chevron types-chevron","lang":"bash","label":"Install chevron and its type stubs"}],"dependencies":[{"reason":"This package provides type stubs for the `chevron` templating library. The actual `chevron` runtime library is required for any functionality.","package":"chevron","optional":false}],"imports":[{"note":"You import the runtime library (`chevron`) directly. `types-chevron` provides type hints for it, but you do not import `types-chevron` itself at runtime. Type checkers automatically discover and use the installed stubs.","symbol":"chevron","correct":"import chevron"}],"quickstart":{"code":"import chevron\nfrom typing import Dict, Any\n\ndef render_template(template_str: str, data: Dict[str, Any]) -> str:\n    \"\"\"Renders a Mustache template using chevron.\"\"\"\n    rendered = chevron.render(template=template_str, data=data)\n    return rendered\n\n# Example 1: Basic string rendering\ntemplate_string = \"Hello, {{ name }}!\"\ncontext_data = {'name': 'World'}\noutput = render_template(template_string, context_data)\nprint(f\"Rendered output (string): {output}\")\n\n# Example 2: Rendering from a file (create a dummy file first)\nwith open(\"my_template.mustache\", \"w\") as f:\n    f.write(\"The secret number is {{ number }}.\")\n\nwith open('my_template.mustache', 'r') as f:\n    file_context_data = {'number': 42}\n    file_output = render_template(template_str=f, data=file_context_data)\nprint(f\"Rendered output (file): {file_output}\")\n\n# Type checking benefits:\n# If 'number' was expected to be an int but a str was passed,\n# a type checker (e.g., Mypy, Pyright) would flag a potential issue\n# even though Python itself would run the code.\n# Example: render_template(template_string, {'name': 123}) # A type checker might warn here.","lang":"python","description":"This quickstart demonstrates basic usage of the `chevron` library, for which `types-chevron` provides static type information. The `types-chevron` package is automatically used by type checkers (like mypy or Pyright) and IDEs to provide type hints, autocompletion, and error detection without requiring direct imports of `types-chevron` itself. The example includes both string and file-based template rendering."},"warnings":[{"fix":"Ensure your installed `chevron` version aligns with the `types-chevron` target version. It is good practice to pin both `chevron` and `types-chevron` to compatible versions in your `requirements.txt` or `pyproject.toml`.","message":"The `types-chevron` package aims to provide accurate annotations for `chevron==0.14.*`. Using a `chevron` version significantly different from this target might lead to inaccurate or missing type hints, potentially causing false positives or negatives in your static type checks.","severity":"gotcha","affected_versions":"all"},{"fix":"Always install both `chevron` and `types-chevron` (e.g., `pip install chevron types-chevron`) to ensure both runtime functionality and static type checking capabilities are available.","message":"`types-chevron` is a stub-only package and contains no runtime code. Installing it without the actual `chevron` library will not provide any templating functionality, only type information for a non-existent runtime dependency, leading to `ModuleNotFoundError` at runtime if `chevron` itself is not installed.","severity":"gotcha","affected_versions":"all"},{"fix":"Pin specific versions of `types-chevron` in your project dependencies (e.g., `types-chevron==0.14.2.20260408`) to maintain consistent type checking behavior, especially in CI/CD environments. Regularly review updates to `types-chevron` for changes to the stubbed API.","message":"Due to the nature of type stubs, any version bump of `types-chevron` can introduce changes that might make your code fail to type check, even if the underlying `chevron` runtime library has not changed. This is because stubs define the expected interface for static analysis, and changes to these definitions can affect type checker output.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the `chevron` library: `pip install chevron`.","cause":"You have installed `types-chevron` but not the actual `chevron` runtime library. `types-chevron` only provides type hints and does not include the functional code.","error":"ModuleNotFoundError: No module named 'chevron'"},{"fix":"1. Ensure both `chevron` and `types-chevron` are installed. 2. Verify that your `chevron` version is compatible with the `types-chevron` version you have installed (e.g., `types-chevron` provides stubs for `chevron==0.14.*`). If not, adjust versions to a compatible set. 3. Check your type checker's configuration to ensure it is correctly discovering and using installed stub packages.","cause":"Your type checker (e.g., Mypy, Pyright) is unable to find the correct type information for `chevron.render`. This can be caused by a version incompatibility between `chevron` and `types-chevron`, or an issue with the type checker resolving the stub package.","error":"error: Library \"chevron\" has no attribute \"render\" [attr-defined] (or similar type checker error)"}]}