Skip to content

Implement import conventions #1004

@edgarrmondragon

Description

@edgarrmondragon

There's https://github.com/joaopalmeiro/flake8-import-conventions to serve as inspiration, though I'm not sure if I'd like to replicate the behavior 100%.

It has an error code for each convention:

name2asname: Dict[str, str] = {
    "altair": "alt",   # IC001
    "numpy": "np",     # IC002
    "pandas": "pd",    # IC003
    "seaborn": "sns",  # IC004
}

The biggest problem with this approach is that it's not possible to expand with custom conventions without forking the repo.

One alternative would be to use a single error code for all conventions, default to the ones above, and allow users to configure a custom mapping:

[tool.ruff.import_conventions.aliases]
pulumi_aws = "aws"

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions