{"id":1763,"library":"types-python-slugify","title":"Typing Stubs for python-slugify","description":"This package provides typing stubs for the `python-slugify` library, enabling static type checkers like MyPy or Pyright to validate usage of `python-slugify`. It does not contain any executable code itself. The current version is 8.0.2.20240310. As part of the typeshed project, its releases are typically tied to updates in the upstream `python-slugify` library or typeshed's own update cadence.","status":"active","version":"8.0.2.20240310","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","slugify","mypy","pyright","typeshed"],"install":[{"cmd":"pip install types-python-slugify","lang":"bash","label":"Install typing stubs"},{"cmd":"pip install python-slugify types-python-slugify","lang":"bash","label":"Install both runtime and stubs"}],"dependencies":[{"reason":"Provides the runtime implementation for which these stubs are supplied.","package":"python-slugify","optional":false}],"imports":[{"note":"This is a stub-only package; actual functions must be imported from the `python-slugify` runtime library.","wrong":"from types_python_slugify import slugify","symbol":"slugify","correct":"from slugify import slugify"},{"note":"This is a stub-only package; actual classes must be imported from the `python-slugify` runtime library.","wrong":"from types_python_slugify import Slugify","symbol":"Slugify","correct":"from slugify import Slugify"}],"quickstart":{"code":"import os\n# Install both packages: pip install python-slugify types-python-slugify\n\nfrom slugify import slugify, Slugify\n\ndef process_title(title: str) -> str:\n    \"\"\"Converts a title to a URL-friendly slug.\"\"\"\n    # Type checkers (like MyPy) will use types-python-slugify here\n    return slugify(title)\n\ndef create_custom_slugifier() -> Slugify:\n    \"\"\"Creates a custom slugifier instance.\"\"\"\n    # Example of using the Slugify class, also type-checked\n    return Slugify(to_lower=True, separator='_')\n\n# --- Example Usage ---\n\n# Basic slugification\noriginal_text = \"My Awesome Article Title!\"\nslugged_text = process_title(original_text)\nprint(f\"Original: '{original_text}'\\nSlugged:  '{slugged_text}'\")\n\n# Using a custom slugifier\ncustom_slg = create_custom_slugifier()\ncustom_slugged = custom_slg(\"Another-Example String\")\nprint(f\"Custom slugged: '{custom_slugged}'\")\n\n# To verify type checking, run `mypy your_script_name.py`\n# For example, calling process_title(123) would raise a type error.","lang":"python","description":"This quickstart demonstrates how to use `python-slugify` with type checking enabled by `types-python-slugify`. It shows basic slug generation and creating a custom `Slugify` instance. To use these stubs, both `python-slugify` and `types-python-slugify` must be installed. A type checker like MyPy will then automatically leverage these stubs for static analysis."},"warnings":[{"fix":"Ensure you install `python-slugify` in addition to `types-python-slugify` (e.g., `pip install python-slugify types-python-slugify`) and import symbols directly from `slugify`.","message":"`types-python-slugify` is a stub-only package. It does not contain any runnable code or provide the `slugify` function/class directly. You must install the actual `python-slugify` library to use the functionality.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `from slugify import slugify` or `from slugify import Slugify` for importing the functionality. The stub package is automatically picked up by type checkers.","message":"Do not attempt to import `slugify` or `Slugify` from `types_python_slugify` (or any variation of the stub package name). Imports should always come from `from slugify import ...` which refers to the runtime library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"While generally compatible, be aware that exact version alignment between the runtime library and its stubs is not guaranteed for every patch release. For critical applications, verify compatibility with your specific `python-slugify` version.","message":"The versioning of `types-python-slugify` (e.g., `8.0.2.20240310`) includes a typeshed timestamp (`20240310`). While the `8.0.2` often aligns with the `python-slugify` library version, minor updates to stubs may occur independently of `python-slugify`'s point releases.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}