SCR304: shadowed-library-package
Library module with its own code.py hides its child modules
| Code | SCR304 |
| Name | shadowed-library-package |
| Category | Scripts (SCR) |
| Default severity | error |
| Enabled by default | yes |
| Fix available | no |
| ign-lint equivalent | none |
What it does
Section titled “What it does”Reports a project library module that has its own code.py and also
child modules below its folder, for example legacy/code.py next to
legacy/helpers/code.py. The finding is on the parent's code.py and
lists the hidden children. Inheritance is taken into account: children
added by a child project of an inheritable project are found as well, as
long as the parent's module is not overridden there.
Why is this bad?
Section titled “Why is this bad?”A folder with its own code.py becomes a module, and Ignition does not
make its subfolders reachable through it. Verified on an 8.3 gateway:
legacy.helpers raises AttributeError and import legacy.helpers
raises ImportError: No module named helpers. The child modules exist in
the Designer but no script can call them.
Example
Section titled “Example”ignition/script-python/legacy/code.pyignition/script-python/legacy/helpers/code.pyUse instead: move the code of legacy/code.py into a child module (for
example legacy/core/code.py) and delete legacy/code.py, so legacy
is a package folder again.
Generated from the rule metadata by iglint generate-docs; iglint rule SCR304 prints the same page in the terminal. Source: docs/rules/SCR304.md.