Skip to content

Allow banning of certain builtins in "banned-api" #10079

Open
@jonathanslenders

Description

@jonathanslenders

I'd love to ban usage of certain builtins using the "banned-api" (TID251) rule.
Something like this:

[tool.ruff.lint.flake8-tidy-imports.banned-api]
# Don't use delattr/getattr/setattr -> too dynamic!
"__builtins__.delattr".msg = "Don't use delattr/setattr/getattr."
"__builtins__.setattr".msg = "Don't use delattr/setattr/getattr."
"__builtins__.getattr".msg = "Don't use delattr/setattr/getattr."

# Don't use `@property`, because methods are more flexible and allow access to unbound methods.
"__builtins__.property".msg = "Don't use properties in this part of the code."

# Don't print. Basically the same as the `T` rule.
"__builtins__.print".msg = "Don't use print."

"__builtins__.list".msg = "Use list literal instead."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions