Use banned-api
for deprecation checks in general
#1507
Labels
rule
Implementing or modifying a lint rule
banned-api
for deprecation checks in general
#1507
The checks for uses of deprecated standard library features are currently split up across different rules, for example:
typing.Text
is deprecated, usestr
warn
is deprecated in favor ofwarning
Since there are many more deprecated things in the standard library (e.g. the 24 superseded modules), I think it would make more sense to define these checks via the recently introduced
banned-api
mechanism rather than introducing separate checks for every single thing that is deprecated in the standard library. And I think we could reuse the flexible configuration mechanism we already have for rules.In particular I suggest the following to be a default config:
And allow users to either:
tool.ruff.banned-api.select = {}
tool.ruff.banned-api.ignore = ["optparse"]
tool.ruff.banned-api.extend-select
Since this would make
banned-api
more of a core feature I think it would make sense to move the setting out of theflake8-tidy-imports
namespace (and change the check code from TID251 to some RUF code).The steps I have in mind are:
banned-api
to be configured via select, ignore, extend-select & extend-ignoretyping.Text
andlogging.warn
as shown above)banned-api
, e.g.ruff.extend-ignore = [ "UP019" ]
would be internally converted toruff.banned-api.extend-ignore = ["typing.Text"]
autofix-to
forbanned-api
.params
setting forbanned-api
, so that e.g. UP021 could be defined asbanned-api.select."subprocess.run" = {params = {universal_newlines = {autofix-to="text"}}
What do you think of this?
The text was updated successfully, but these errors were encountered: