Skip to main content

No project description provided

Project description

Helps to prevent import of certain modules from certain modules.

It's useful if you have many modules in your project and want to keep them kind of isolated.

After installing just add import-rules option to your setup.cfg file.

[flake8]
...
import-rules= 
	# yaml format here
	- module_one: [
		allow module_two,
		deny any
	]
	- module_two: [
		deny module_one.sub.submodule
	]
	- module_two.sumbodule: deny module_one
	- module_three: allow any

	# many section for the same module are allowed
	# for example
	- module_two: [
		deny some_other_module
	]

	# this will prevent any import everywhere
	- any: [
		deny any
	]

	# default behaviour is
	- any: [
		allow any
	]

...

Rules are checking top-down. The Order Matters.

If current module name match section name or is submodule, then it will check all imports by rules from the section.

There can be one or more rules in section. There can be one or more sections for the same module/submodule.

allow modulepath - means allow imports from modulepath and its submodules

deny modulepath - means deny imports from modulepath and its submodules.

Keyword any (or all) - menas any module (like *)

CAUTION. As .INI configparser ignores indentation use [ ... , .. ] flow for lists as in example.

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_rules-0.2.1.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

flake8_import_rules-0.2.1-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

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