Skip to main content

An opinionated plugin for Flake8 on how certain packages should be imported or aliased.

Project description

flake8-import-conventions

An opinionated plugin for Flake8 on how certain packages should be imported or aliased.

It is based on the pandas-vet and flake8-2020 plugins.

Development

poetry install --with dev
poetry shell

Open the manual_test.py file in VS Code to see the error messages.

pytest tests/ -v

or (to see print()s)

pytest tests/ -v -s

Deployment

poetry check
poetry version minor

or

poetry version patch
git tag
git tag "v$(poetry version --short)"
git push origin "v$(poetry version --short)"

References

Notes

Minimal boilerplate for the Plugin class:

import ast
import importlib.metadata
from typing import Any, Generator, Tuple, Type


class Plugin:
    name = __name__
    version = importlib.metadata.version(__name__)

    def __init__(self, tree: ast.AST) -> None:
        # The AST that represents a single file
        self._tree = tree

    def run(self) -> Generator[Tuple[int, int, str, Type[Any]], None, None]:
        # Tuple[line number, character offset, message]
        # Type[Any] is not being used (use `type(self)`)
        pass

Syntactic sugar for attr.ib(default=attr.Factory(f)):

@attr.s
class C(object):
    x = attr.ib(factory=list)
    # instead of
    # x = attr.ib(default=attr.Factory(list))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_import_conventions-0.0.1.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page