Skip to main content

flake8 plugin that reports imports of private names

Project description

# flake8_private_name_import flake8 plugin that reports imports of private names.

# Codes

<details>

<summary>PNI001 found import of private name: {name}</summary>

`python from module import _my_private_name # PNI001 found import of private name: _my_private_name `

</details>

<details>

<summary>PNI002 found import of private module: {module}</summary>

`python import _module # PNI002 found import of private module: _module import module._sub_module # PNI002 found import of private module: module._sub_module `

</details>

<details>

<summary>PNI003 found import from private module: {module}</summary>

`python from _module import name # PNI003 found import from private module: _module from module._sub_module import name # PNI003 found import from private module: module._sub_module `

</details>

# Options

### Skip names (PNI001)

console: –private-name-import-skip-names config_file: private_name_import_skip_names type: comma separated list (list for config_file)

Private names import of which must not be reported. Accepts full path (module.sub_module._name) or plain name (_name). If full path used then only that name from that module would be skipped. If plain name used then name would be skipped independent on module it imported from.

<details>

<summary>Example (specific name from specific module)</summary>

`text flake8 --private-name-import-skip-names=module.sub_module._function,module.sub_module._Class `

`python from module.sub_module import _function, _Class # both skipped from module.sub_module import _CONSTANT # PNI001 found import of private name: _CONSTANT `

</details>

<details>

<summary>Example (module independent name)</summary>

`text flake8 --private-name-import-skip-names=_function,_Class `

`python from module import _function, _Class # both skipped from module.sub_module import _function, _Class # both skipped from module.sub_module import _CONSTANT # PNI001 found import of private name: _CONSTANT `

</details>

### Skip modules (PNI002)

console: –private-name-import-skip-modules config_file: private_name_import_skip_modules type: comma separated list (list for config_file)

Private modules import of which must not be reported. Affects only imports of modules, imports of names from those modules will be reported.

<details>

<summary>Example</summary>

`text flake8 --private-name-import-skip-modules=_module,module._sub_module `

`python import _module # skipped import module._sub_module # skipped from _module import name # PNI003 found import from private module: _module `

</details>

### Skip names from modules (PNI003, PNI001)

console: –private-name-import-skip-names-from-modules config_file: private_name_import_skip_names_from_modules type: comma separated list (list for config_file)

Comma separated modules imports of private names from which must not be reported. Affects only imports of names from those modules, imports of modules will be reported.

<details>

<summary>Example</summary>

`text flake8 --private-name-import-skip-names-from-modules=_module,module._sub_module `

`python from _module import name # skipped from module._sub_module import _name # skipped (both private module and private name) import _module # PNI002 found import of private module: _module `

</details>

### Skip local imports

console: –private-name-import-skip-local config_file: private_name_import_skip_local type: flag

When option used, import inside functions will not be reported

### Skip relative imports

console: –private-name-import-skip-relative config_file: private_name_import_skip_relative type: flag

When option used, relative imports will not be reported

### Skip test files and folders

console: –private-name-import-dont-skip-test config_file: private_name_import_dont_skip_test type: flag

By default, imports in test directories/files are not reported. This option turn the feature off (test files and folders will be checked for private imports).

### Skip TYPE_CHECKING

console: –private-name-import-dont-skip-type-checking config_file: private_name_import_dont_skip_type_checking type: flag

By default, imports under TYPE_CHECKING are not reported. This option turn the feature off (TYPE_CHECKING imports will be checked for private imports).

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_private_name_import-1.0.0.tar.gz (4.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