{"id":7153,"library":"deprecat","title":"Deprecat Decorator","description":"The `deprecat` library provides a Python `@deprecat` decorator for marking classes, functions, and methods as deprecated. It also includes functionality to deprecate specific arguments within a function using `@deprecat.deprecated_args`. Maintained on GitHub, it's currently at version 2.1.3 and has a moderate release cadence, with the latest significant updates focusing on bug fixes and new features like `remove_version`.","status":"active","version":"2.1.3","language":"en","source_language":"en","source_url":"https://github.com/mjhajharia/deprecat","tags":["decorator","deprecation","utilities","developer-tooling"],"install":[{"cmd":"pip install deprecat","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"Often confused with the similarly named but distinct `deprecated` library.","wrong":"from deprecated import deprecated","symbol":"deprecat","correct":"from deprecat import deprecat"}],"quickstart":{"code":"from deprecat import deprecat\nimport warnings\n\n@deprecat(reason=\"This function is old, use new_sum instead\", version=\"2.0.0\")\ndef old_sum(a, b):\n    return a + b\n\nclass MyClass:\n    @deprecat(reason=\"This method is outdated\", version=\"2.1.0\")\n    def old_method(self):\n        return \"Hello from old method\"\n\n@deprecat(reason=\"This function's 'b' argument is deprecated\", version='2.1.1')\n@deprecat.deprecated_args(version='2.1.1', deprecated_argument='b')\ndef my_func(a, b):\n    return a * b\n\n# Suppress deprecation warnings for cleaner output in quickstart\nwith warnings.catch_warnings():\n    warnings.simplefilter(\"ignore\", DeprecationWarning)\n    print(f\"Old sum: {old_sum(1, 2)}\")\n    obj = MyClass()\n    print(f\"Old method output: {obj.old_method()}\")\n    print(f\"Function with deprecated arg: {my_func(3, b=4)}\")","lang":"python","description":"Demonstrates basic usage of the `@deprecat` decorator on functions and methods, as well as marking specific arguments as deprecated using `@deprecat.deprecated_args`."},"warnings":[{"fix":"Always use `from deprecat import deprecat`. If you previously used the `deprecated` library, note that `deprecat` might have different behavior or features.","message":"The `deprecat` library is distinct from the similarly named `deprecated` library. Ensure you import `from deprecat import deprecat` to use this library's specific features, particularly `deprecated_args`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the decorator is always called, even if with empty parentheses: `@deprecat()`.","message":"When using `@deprecat` without any arguments (e.g., just marking something as deprecated without specifying a reason or version), you must still include the parentheses: `@deprecat()`. Omitting them (`@deprecat`) will cause the decorator to not apply correctly or raise a `TypeError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Import `deprecat` as `from deprecat import deprecat` and then use it as `@deprecat.deprecated_args(...)`.","message":"The `deprecated_args` functionality is available as an attribute of the `deprecat` decorator (i.e., `deprecat.deprecated_args`). It is not directly importable as `from deprecat import deprecated_args`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure you have installed `deprecat` (`pip install deprecat`) and are importing it correctly: `from deprecat import deprecat`.","cause":"Attempting to import `deprecated` when `deprecat` is intended, or the wrong library is installed.","error":"ModuleNotFoundError: No module named 'deprecated'"},{"fix":"Always call the decorator, even if with empty parentheses: `@deprecat()`.","cause":"Attempting to use `@deprecat` without calling it (i.e., omitting `()` when no arguments are passed).","error":"TypeError: 'NoneType' object is not callable"}]}