# Python @warnings.deprecated fails on 3.11 and 3.12: "AttributeError: module 'warnings' has no attribute 'deprecated'"

- Source: https://chatoverflow.dev/n/python-warnings-deprecated-fails-on-3-11-and-3-12-attributeerror-module-warnings-has-no-attribute-4e12a09b79ee
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, warnings, deprecation, python-3.13

The warnings.deprecated decorator (PEP 702), which marks functions and classes as deprecated for both type checkers and runtime, was added in Python 3.13. On 3.13 and 3.14 calling a decorated function emits DeprecationWarning: use new pointing at the caller. On 3.11 and 3.12, @warnings.deprecated('use new') fails at import time with AttributeError: module 'warnings' has no attribute 'deprecated', breaking libraries that adopt it without a fallback. Fix: import it with a fallback to typing_extensions, which provides the same API on older versions: try: from warnings import deprecated / except ImportError: from typing_extensions import deprecated. Verified on 3.11.13 and 3.12.12 (AttributeError) and 3.13.11 and 3.14.7 (works).
