pylint-restricted-imports


Namepylint-restricted-imports JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/pexip/pylint-restricted-imports
Summarypylint-restricted-imports is a Pylint plugin to restrict what imports are allowed in different modules
upload_time2024-01-10 15:21:58
maintainer
docs_urlNone
authorPexip AS
requires_python>=3.8,<4.0
licenseMIT
keywords pylint plugin imports
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pylint-restricted-imports
=========================

About
`````

``pylint-restricted-imports`` is `Pylint`_ plugin for restricting
what imports are allowed in specific module trees.
Want to prevent django from being imported in a flask app? This plugin is for you!

.. _Pylint: http://pylint.org

Usage
`````

Ensure ``pylint-restricted-imports`` is installed and on your path, and then run pylint using
pylint-restricted-imports as a plugin::

    pip install pylint-restricted-imports
    pylint --load-plugins pylint_restricted_imports [..your module..]

Configuration
`````````````

Before the plugin will do anything, it needs configuring.
You can use pylint to generate the default configuration::

    pylint --load-plugins pylint_restricted_imports --generate-rcfile

You will end up with a block similar to below::

    [RESTRICTED-IMPORT]
    # Colon/semicolon-delimited sets of names that determine what modules are
    # allowed to be imported from another module
    restricted-imports=

    # Check restricted imports recursively
    restricted-import-recurse=no

Restricted Imports
''''''''''''''''''
``restricted-imports`` is a csv list of module/restricted imports. The format is ``<module>:<restricted module>;...``.
For example, the following would prevent ``restricted1`` and ``restricted2`` from being imported in `module1` and
``restricted3`` and ``restricted4`` from being imported in ``module2``::

    module1:restricted1;restricted2,module2:fordibben3;restricted4

Recursion
'''''''''
You can enable the transitive detection of restricted imports, however this takes a lot
more compute.

For example, if have the following files::

    # flask_app.py
    import flask
    import common_utils

    # common_utils.py
    import django

If ``flask_app`` is not allowed to import django, the transitive checker would throw an error
because importing ``common_utils`` would cause ``django`` to be imported, which is restricted.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pexip/pylint-restricted-imports",
    "name": "pylint-restricted-imports",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "pylint,plugin,imports",
    "author": "Pexip AS",
    "author_email": "packaging@pexip.com",
    "download_url": "https://files.pythonhosted.org/packages/f2/68/ebd95276e4c744752576c280927583f5bd58bef6fe91ac8bb2336ac73bde/pylint_restricted_imports-0.2.0.tar.gz",
    "platform": null,
    "description": "pylint-restricted-imports\n=========================\n\nAbout\n`````\n\n``pylint-restricted-imports`` is `Pylint`_ plugin for restricting\nwhat imports are allowed in specific module trees.\nWant to prevent django from being imported in a flask app? This plugin is for you!\n\n.. _Pylint: http://pylint.org\n\nUsage\n`````\n\nEnsure ``pylint-restricted-imports`` is installed and on your path, and then run pylint using\npylint-restricted-imports as a plugin::\n\n    pip install pylint-restricted-imports\n    pylint --load-plugins pylint_restricted_imports [..your module..]\n\nConfiguration\n`````````````\n\nBefore the plugin will do anything, it needs configuring.\nYou can use pylint to generate the default configuration::\n\n    pylint --load-plugins pylint_restricted_imports --generate-rcfile\n\nYou will end up with a block similar to below::\n\n    [RESTRICTED-IMPORT]\n    # Colon/semicolon-delimited sets of names that determine what modules are\n    # allowed to be imported from another module\n    restricted-imports=\n\n    # Check restricted imports recursively\n    restricted-import-recurse=no\n\nRestricted Imports\n''''''''''''''''''\n``restricted-imports`` is a csv list of module/restricted imports. The format is ``<module>:<restricted module>;...``.\nFor example, the following would prevent ``restricted1`` and ``restricted2`` from being imported in `module1` and\n``restricted3`` and ``restricted4`` from being imported in ``module2``::\n\n    module1:restricted1;restricted2,module2:fordibben3;restricted4\n\nRecursion\n'''''''''\nYou can enable the transitive detection of restricted imports, however this takes a lot\nmore compute.\n\nFor example, if have the following files::\n\n    # flask_app.py\n    import flask\n    import common_utils\n\n    # common_utils.py\n    import django\n\nIf ``flask_app`` is not allowed to import django, the transitive checker would throw an error\nbecause importing ``common_utils`` would cause ``django`` to be imported, which is restricted.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "pylint-restricted-imports is a Pylint plugin to restrict what imports are allowed in different modules",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/pexip/pylint-restricted-imports",
        "Repository": "https://github.com/pexip/pylint-restricted-imports"
    },
    "split_keywords": [
        "pylint",
        "plugin",
        "imports"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f12d2148b841590e5a95e3284f29746d2d7e7339a263b9806d82081e63de9ab",
                "md5": "fe19ef2e8733f8018f8d3c9f3d470f38",
                "sha256": "ebd5c6aea8cf9a1f6d64bb7ff96aec0004b66752a14f2339cbcf9bc7e521a2d6"
            },
            "downloads": -1,
            "filename": "pylint_restricted_imports-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fe19ef2e8733f8018f8d3c9f3d470f38",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 4799,
            "upload_time": "2024-01-10T15:21:57",
            "upload_time_iso_8601": "2024-01-10T15:21:57.843237Z",
            "url": "https://files.pythonhosted.org/packages/5f/12/d2148b841590e5a95e3284f29746d2d7e7339a263b9806d82081e63de9ab/pylint_restricted_imports-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f268ebd95276e4c744752576c280927583f5bd58bef6fe91ac8bb2336ac73bde",
                "md5": "d5dfdecff07d62668d8dec9c4188fab1",
                "sha256": "47e250d8c8713c232e90d4722dd27d8562c7d167f1c10ee47d9c266ef4bd243f"
            },
            "downloads": -1,
            "filename": "pylint_restricted_imports-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d5dfdecff07d62668d8dec9c4188fab1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 4250,
            "upload_time": "2024-01-10T15:21:58",
            "upload_time_iso_8601": "2024-01-10T15:21:58.869674Z",
            "url": "https://files.pythonhosted.org/packages/f2/68/ebd95276e4c744752576c280927583f5bd58bef6fe91ac8bb2336ac73bde/pylint_restricted_imports-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-10 15:21:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pexip",
    "github_project": "pylint-restricted-imports",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pylint-restricted-imports"
}
        
Elapsed time: 0.16004s