Julian / Julian/regret

Add helper to deprecate a module.

Open
#32 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
15
Forks
3
PR merge metrics
No merged PRs in 30d

Description

A warning for a module deprecation can be emitted at first import.

A package is just a module.

The important help is to make know exactly which module is deprecated (`__name__`) and where it is used (`stacklevel=2`).
And the message should be standardized.

See if `__name__` can be used to reduce boilerplate.

This is a generic helper to raise a deprecation event based right when it is called.

Example from current implementation twisted/mail/pop3client.py

```python

warnings.warn(
"twisted.mail.pop3client was deprecated in Twisted NEXT. Use twisted.mail.pop3 instead.",
DeprecationWarning,
stacklevel=2,
)
```

The API might look like

```python
regret.module(
version='1.2.3',
target=__name__,
replacement='twisted.mail.pop3',
)
```

Maybe even try to be smart and go up the stack to extract `__name__`.

Then in the most simple case we will have:

```python
regret.module(version='1.2.3')
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.