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 details)

Uploaded Source

Built Distribution

File details

Details for the file flake8_private_name_import-1.0.0.tar.gz.

File metadata

File hashes

Hashes for flake8_private_name_import-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e4ae9c5f17194d8754fd239923ad6a78324e98dab013b9bb92ad5b1814029436
MD5 509fdb4b90a043af5d07b5dfb3acbf63
BLAKE2b-256 eaf8db95a3f5fe7a66cba9e683d2a0090017167fd53ee8d33450c101640a6ef5

See more details on using hashes here.

File details

Details for the file flake8_private_name_import-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_private_name_import-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d7f1fbf50aea08f8003f18fa9ed8be297c35dbd0b4eac6c63c32abf09dd0c35
MD5 a42b26a7c5f0831bd7ac3793a90e50e3
BLAKE2b-256 4ef99a7fc46d4cb4666c9037669ae08e7adaeff2198481274ca1923ee9fce775

See more details on using hashes here.

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