{"id":7150,"library":"decohints","title":"decohints","description":"decohints is a Python library that provides a decorator to help IDEs like PyCharm correctly display the parameter hints for functions wrapped by other decorators. It addresses a common pain point in Python development by preserving the original function's signature for better developer experience and type checking. The current version is 1.0.9, and it maintains an active release cadence.","status":"active","version":"1.0.9","language":"en","source_language":"en","source_url":"https://github.com/gri-gus/decohints","tags":["decorator","type-hints","pycharm","ide","development","utility","static-analysis"],"install":[{"cmd":"pip install decohints","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"decohints","correct":"from decohints import decohints"}],"quickstart":{"code":"from functools import wraps\nfrom decohints import decohints\n\n@decohints\ndef my_simple_decorator(msg: str = \"Hello\"):\n    def _decorator(func):\n        @wraps(func)\n        def wrapper(*args, **kwargs):\n            print(f\"Decorator received: {msg}\")\n            return func(*args, **kwargs)\n        return wrapper\n    return _decorator\n\n@my_simple_decorator(msg=\"Decorating this!\")\ndef greet(name: str, age: int) -> str:\n    \"\"\"A function that greets someone.\"\"\"\n    return f\"Hi {name}, you are {age} years old.\"\n\nresult = greet(\"Alice\", 30)\nprint(result)\n# In PyCharm, typing `greet(` will now show `(name: str, age: int)` hints.","lang":"python","description":"This example demonstrates how to use `decohints` to wrap your own decorator. When `my_simple_decorator` is decorated with `@decohints`, IDEs like PyCharm will correctly show the parameter hints of the `greet` function (`name: str, age: int`) instead of the generic `*args, **kwargs`."},"warnings":[{"fix":"Place `@decohints` at the very top of your decorator definition. Example: `@decohints\\n@another_decorator\\ndef your_decorator(): ...`","message":"When applying `decohints` to your own decorators, ensure that `@decohints` is the outermost decorator (i.e., placed directly above your decorator function definition) if your decorator is already wrapped in other decorators.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `decohints` version 1.0.5 or newer (`pip install --upgrade decohints`). This version includes the necessary `py.typed` marker for proper static analysis.","message":"Older versions of `decohints` (prior to 1.0.5) did not include the `py.typed` marker, which could lead to Mypy (or other static type checkers) skipping type analysis for the library or reporting 'missing library stubs' errors.","severity":"gotcha","affected_versions":"<1.0.5"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Apply the `@decohints` decorator to your custom decorator function. For instance, if you have `def my_decorator():`, change it to `@decohints\\ndef my_decorator():`.","cause":"By default, Python decorators replace the decorated function with a wrapper, causing IDEs to lose the original function's signature for parameter hinting.","error":"PyCharm/IDE does not show correct parameter hints (e.g., shows `*args, **kwargs` instead of actual parameters) for a function decorated by a custom decorator."},{"fix":"Upgrade `decohints` to version 1.0.5 or later using `pip install --upgrade decohints`. This version includes the `py.typed` marker, enabling Mypy to correctly analyze the library.","cause":"`decohints` versions prior to 1.0.5 did not properly signal to static type checkers that it provides type hints, leading Mypy to ignore its type information.","error":"Skipping analyzing 'decohints': module is installed, but missing library stubs or py.typed marker (Mypy error)"}]}