ALL-MODU0005 · module_class_count
Require one primary class at most in each source module.
This is a deterministic rule for all languages. Read its implementation.
Definition
Section titled “Definition”Count classes declared directly at module scope. A source module should normally give one primary class a name and a home. A second class usually means that two concepts share one file or that a support record has not yet been given a narrower owner.
Evidence
Section titled “Evidence”The finding names the module and its exact top-level class count. Nested implementation classes do not count. The value is the number of top-level classes.
Exceptions
Section titled “Exceptions”Type stub modules may declare the complete surface of one native extension, so their classes do not represent colocated implementations. Tiny closed type families, generated schemas, and language-mandated companion declarations can remain together through an explicit path exclusion. A package initializer should export classes from their own modules rather than define the family itself.
Examples
Section titled “Examples”A module defining Reader and Writer returns 2 and fails the standard ceiling. A module
defining Reader with a nested private cursor returns 1.
References
Section titled “References”- Cites “A Philosophy of Software Design”, chapters 4 and 5
- Generalizes wemake-python-styleguide WPS202. Open reference