flake8-restrict-imports


Nameflake8-restrict-imports JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/fylein/flake8-restrict-imports
SummaryFlake8 plugin for restricting unwanted imports in a module.
upload_time2024-01-10 06:16:16
maintainer
docs_urlNone
authorSiva Narayanan
requires_python
licenseMIT
keywords flake8 imports python restrict
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Flake8 Restrict Imports Plugin
==============================

Overview
--------

This Flake8 plugin provides a mechanism to restrict imports based on a specified configuration. The plugin allows you to define sets of denied and allowed imports, helping you enforce coding standards and maintain a clean codebase.

### Features

-   Denied Imports: Specify a configuration that defines imports to be denied for specific modules/packages.
-   Allowed Imports: Specify a configuration that defines allowed imports for specific modules/packages.

Installation
------------

Install the plugin using `pip`:


`pip install flake8-restrict-imports`

Usage
-----

Once the plugin is installed, you can run Flake8 with the plugin enabled:


`flake8 your_project_directory`

### Configuration

You need to configure the plugin in your Flake8 configuration file (e.g., `.flake8`):


```[flake8]
denied_imports_config = {'libs': ['db', 'tests'],'db': ['libs', 'tests']}
allowed_imports_config = {'api.tests.utils': ['db', 'libs'], 'db': ['tests']}
```

Adjust the configurations based on your project's needs.

### Example

Consider the following code snippet:


```
# your_module.py

# Denied import
from core import some_module  # This import is denied according to the configuration

# Allowed import
from api.tests.event_utils import some_function  # This import is allowed according to the configuration
```

# Denied import
`from core import some_module` This import is denied according to the configuration

# Allowed import
`from api.tests.event_utils import some_function` This import is allowed according to the configuration`

When Flake8 is run, it will raise a warning for the denied import and ensure compliance with your defined import restrictions.

Contribution
------------

Feel free to contribute to the development of this Flake8 plugin. Fork the repository, make your changes, and submit a pull request.

License
-------

This Flake8 plugin is licensed under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fylein/flake8-restrict-imports",
    "name": "flake8-restrict-imports",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "flake8,imports,python,restrict",
    "author": "Siva Narayanan",
    "author_email": "siva@fylehq.com",
    "download_url": "https://files.pythonhosted.org/packages/0a/b5/09dd3c434425e6560f9483b2c877ab1ecec2682728b551e4fd4e1d4d5db5/flake8-restrict-imports-0.1.1.tar.gz",
    "platform": null,
    "description": "Flake8 Restrict Imports Plugin\n==============================\n\nOverview\n--------\n\nThis Flake8 plugin provides a mechanism to restrict imports based on a specified configuration. The plugin allows you to define sets of denied and allowed imports, helping you enforce coding standards and maintain a clean codebase.\n\n### Features\n\n-   Denied Imports: Specify a configuration that defines imports to be denied for specific modules/packages.\n-   Allowed Imports: Specify a configuration that defines allowed imports for specific modules/packages.\n\nInstallation\n------------\n\nInstall the plugin using `pip`:\n\n\n`pip install flake8-restrict-imports`\n\nUsage\n-----\n\nOnce the plugin is installed, you can run Flake8 with the plugin enabled:\n\n\n`flake8 your_project_directory`\n\n### Configuration\n\nYou need to configure the plugin in your Flake8 configuration file (e.g., `.flake8`):\n\n\n```[flake8]\ndenied_imports_config = {'libs': ['db', 'tests'],'db': ['libs', 'tests']}\nallowed_imports_config = {'api.tests.utils': ['db', 'libs'], 'db': ['tests']}\n```\n\nAdjust the configurations based on your project's needs.\n\n### Example\n\nConsider the following code snippet:\n\n\n```\n# your_module.py\n\n# Denied import\nfrom core import some_module  # This import is denied according to the configuration\n\n# Allowed import\nfrom api.tests.event_utils import some_function  # This import is allowed according to the configuration\n```\n\n# Denied import\n`from core import some_module` This import is denied according to the configuration\n\n# Allowed import\n`from api.tests.event_utils import some_function` This import is allowed according to the configuration`\n\nWhen Flake8 is run, it will raise a warning for the denied import and ensure compliance with your defined import restrictions.\n\nContribution\n------------\n\nFeel free to contribute to the development of this Flake8 plugin. Fork the repository, make your changes, and submit a pull request.\n\nLicense\n-------\n\nThis Flake8 plugin is licensed under the MIT License.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Flake8 plugin for restricting unwanted imports in a module.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/fylein/flake8-restrict-imports"
    },
    "split_keywords": [
        "flake8",
        "imports",
        "python",
        "restrict"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "920c76567d2d5213efa268133d137576e39d1fbe8ddf243039f92dc191dc3444",
                "md5": "f8cd41648d7666d19ac07a902df13323",
                "sha256": "6d8bfda97bbedffb6af41849c4eb1d5b105867f7a267e7f42b622076da4472aa"
            },
            "downloads": -1,
            "filename": "flake8_restrict_imports-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f8cd41648d7666d19ac07a902df13323",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4671,
            "upload_time": "2024-01-10T06:16:14",
            "upload_time_iso_8601": "2024-01-10T06:16:14.143523Z",
            "url": "https://files.pythonhosted.org/packages/92/0c/76567d2d5213efa268133d137576e39d1fbe8ddf243039f92dc191dc3444/flake8_restrict_imports-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ab509dd3c434425e6560f9483b2c877ab1ecec2682728b551e4fd4e1d4d5db5",
                "md5": "43967a1cc9393970302eea3bbbbb026a",
                "sha256": "46773ba0d26017a8a7a7483e861f6844f030958115aa9cea6fdc8b6037b9a3e0"
            },
            "downloads": -1,
            "filename": "flake8-restrict-imports-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "43967a1cc9393970302eea3bbbbb026a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4492,
            "upload_time": "2024-01-10T06:16:16",
            "upload_time_iso_8601": "2024-01-10T06:16:16.008592Z",
            "url": "https://files.pythonhosted.org/packages/0a/b5/09dd3c434425e6560f9483b2c877ab1ecec2682728b551e4fd4e1d4d5db5/flake8-restrict-imports-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-10 06:16:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fylein",
    "github_project": "flake8-restrict-imports",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "flake8-restrict-imports"
}
        
Elapsed time: 0.22566s