Metadata-Version: 2.5
Name: qblox-deprecation
Version: 0.2.0
Summary: Tools for deprecation warnings
Project-URL: Homepage, https://www.qblox.com/
Project-URL: Repository, https://gitlab.com/qblox/packages/software/qblox-deprecation
Project-URL: Bug Tracker, https://gitlab.com/qblox/packages/software/qblox-deprecation/-/issues
Project-URL: Changelog, https://gitlab.com/qblox/packages/software/qblox-deprecation/-/blob/main/CHANGELOG.md
License-Expression: BSD-3-Clause
License-File: LICENSES/BSD-3-Clause.txt
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Typing :: Typed
Requires-Python: >=3.11
Provides-Extra: pytest
Requires-Dist: pytest; extra == 'pytest'
Description-Content-Type: text/markdown

<!--
SPDX-FileCopyrightText: © 2026 Qblox <https://qblox.com>
SPDX-License-Identifier: BSD-3-Clause
-->

# Qblox-deprecation

Useful decorators to mark functions, classes, parameters, etc, as deprecated.

## Examples

```python
from qblox_deprecation.deprecate import (
    deprecate_positional_args_from,
    deprecated,
    deprecated_arg_alias,
)


def new_function(foo):
    return foo + foo


# Emit a future warning and call new_function instead
@deprecated("1.0", new_function)
def deprecated_function():
    return foo * foo


# Emit a future warning, extended with the message, and call the original function.
@deprecated("1.0", "Please use new_function instead.")
def deprecated_function():
    return 2


class NewClass:
    def __init__(self) -> None:
        pass


# Emit a future warning and construct an instance of NewClass instead
@deprecated("1.0", NewClass)
class OldClass:
    def __init__(self) -> None:
        pass


# Emit a future warning, extended with the message, and use the original class.
@deprecated("1.0", "Please use NewClass instead.")
class OldClass:
    def __init__(self) -> None:
        self.foo = "foo"


# Emit a future warning, and replace any usage of 'quux' with 'baz'.
@deprecated_arg_alias("1.3", quux="baz")
def foo(bar, baz, qux):
    pass


# Emit a future warning if any argument after 'b' is specified as a positional argument.
# This prepares for a refactor to `my_func(a, b, *, c, d)`
@deprecate_positional_args_from("c")
def my_func(a, b, c, d):
    pass


# You can use it on classes too!
@deprecate_positional_args_from("c")
class MyClass:
    def __init__(self, a, b, c, d):
        pass
```

## Fixtures

The package also contains optional fixtures. Install `qblox-deprecation` with the optional
`[pytest]` dependency to use them. Examples:

```toml
# pyproject.toml
[tool.pytest]
markers = ["deprecated"]
```

```python
# conftest.py
from qblox_deprecation.fixtures import handle_deprecated_marker


# test_xyz.py
@pytest.mark.deprecated("1.13", "my-package")
def test_xyz(): ...
```
