Python · architecture
no-generic-single-export-module
python:no-generic-single-export-module A generic module with one public definition should be named after that definition.
- Code
- SARJ022
- Default
- error
- Fix
- none
- Languages
- python
Why
Names such as `utils` and `helpers` hide a module's responsibility and encourage unrelated additions.
Fix
Rename the module to the snake_case name of its sole public class or function.
Before / after
Executed by this rule’s unit tests.
Before
Generic module contains one public definition
def snake_case_text(value: str) -> str: ...
After
Specific module contains one public definition
class InvalidPaginationCursorError(Exception): ...
Limits
- Only known generic module stems with exactly one public definition are reported.
- Framework-owned, generated, test, and package initializer paths are excluded.
Formerly: single-public-export