Skip to main content

Flake8 plugin that checks for relative imports up to a maximum of level two

Project description

flake8-import-relative-two

============================ Flake8 plugin that checks for relative imports up to a maximum of level two

Current Development Version:

GitHub Workflow Status codecov

Most Recent Stable Release:

pypi pypi

Info:

License Code style: black Downloads


Plugin created for linting relative imports up to a maximum of level two. One of private projects I work on has a rule that forbids relative imports deeper than two levels and need to be converted to absolute imports.

Plugin created based on flake8-absolute-import by Brian Skinn, with help from youtube video

flake8-import-relative-two uses a direct check of the AST for each from ...x import y statement to flag relative imports deeper than two levels.

Relative imports raise the IRT1 error code:

from foo import bar   # OK
from .foo import bar   # OK
from ..foo import bar   # OK
from ...foo import bar  # IRT1

Available on PyPI(pip install flake8-import-relative-two).

flake8 should automatically detect and load the plugin.

flake8>=6.0 is required.

Source on GitHub

Bug reports and feature requests are welcomed at the Issues page there.

Copyright (c) Bartosz Cholewa 2023

The lake8-import-relative-two documentation (including docstrings and README) is licensed under a Creative Commons Attribution 4.0 International License (CC-BY).

The lake8-import-relative-two codebase is released under the MIT License. See LICENSE.txt for full license terms.

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_relative_two-0.2.0.tar.gz (3.9 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