Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn if anything marked as deprecated is used #14221

Open
mamekoro opened this issue Nov 9, 2024 · 2 comments
Open

Warn if anything marked as deprecated is used #14221

mamekoro opened this issue Nov 9, 2024 · 2 comments
Labels
rule Implementing or modifying a lint rule type-inference Requires more advanced type inference.

Comments

@mamekoro
Copy link

mamekoro commented Nov 9, 2024

Python 3.13 introduced a decorator called @warnings.deprecated that marks classes, functions and methods as deprecated. For older versions of Python, @deprecated.deprecated is available as an alternative.

Would you consider adding the functionality to warn of the use of objects marked as deprecated by these decorators? In other words, a feature like that provided by memestra.

@sbrugman
Copy link
Contributor

sbrugman commented Nov 9, 2024

In general such a rule could be a great addition for library developers that want to do a quick check of expired deprecations before a release. Warning users of such functions would require multi-file analysis.

In practice, many libraries define their own deprecation decorator with additional functionality such as version and expiry information. My impression is that for popular packages it's more common to use a custom decorator than that to use the standard library (warnings) or a third-party (deprecated).

Since we cannot detect these custom implementations reliably, we could consider letting the user configure fully qualified names of the deprecation functions, like https://docs.astral.sh/ruff/settings/#lint_flake8-boolean-trap_extend-allowed-calls. This would make this rule effective for those users too.

Examples:

@MichaReiser
Copy link
Member

That makes sense but it does require multifile analysis. For now, you could consider using https://docs.astral.sh/ruff/rules/banned-api/

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule type-inference Requires more advanced type inference. labels Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule type-inference Requires more advanced type inference.
Projects
None yet
Development

No branches or pull requests

3 participants