Functions | |
| _resolve_modules () | |
Expand the module roots into (path, dotted name) pairs. | |
| str | literal_key (str module, list values) |
| Stable identity for one inline choice set. | |
| dict | find_inline_choices () |
| Every inline set of string choices in the CLI package. | |
| list | string_members (collection) |
| The string members of a literal collection, or None if it is not all strings. | |
| int | main () |
| Fail when an inline choice set is neither named nor classified. | |
Variables | |
| REPO_ROOT = Path(__file__).resolve().parents[2] | |
| str | WAIVERS = REPO_ROOT / "tests" / "tooling" / "inline_choice_waivers.json" |
| tuple | MODULE_ROOTS |
| MODULES = tuple(item[0] for item in _resolve_modules()) | |
| MODULE_DOTTED = dict(_resolve_modules()) | |
| tuple | VALID_CLASSIFICATIONS |
| int | MIN_REASON_CHARS = 40 |
| int | MINIMUM_CHOICE_SIZE = 2 |
Reject public closed choices written as inline literals.
The family census discovers `normalize_*` functions and named module-level constants.
That is a complete search of what it can see - and an inline `if value not in {"a","b"}`
is invisible to it. The census could therefore call itself exhaustive while public
choices sat in literals nobody enumerated.
This closes the loop from the other side: every inline set of string choices in the CLI
package must either become a named constant, which the census then discovers and
classifies, or be listed here with the same typed classification and a reason. A
literal that is neither is a violation.
|
protected |
Expand the module roots into (path, dotted name) pairs.
Definition at line 31 of file audit_inline_choices.py.
| str audit_inline_choices.literal_key | ( | str | module, |
| list | values | ||
| ) |
Stable identity for one inline choice set.
Keyed by module and sorted values rather than by line number, so the waiver survives edits above it and two sites sharing a set collapse to one entry - which is itself a signal that the set wants a name.
| [in] | module | Dotted module name. |
| [in] | values | The string members. |
Definition at line 63 of file audit_inline_choices.py.
| dict audit_inline_choices.find_inline_choices | ( | ) |
Every inline set of string choices in the CLI package.
Two shapes are recognised: a membership test against a literal collection, and an argparse choices= literal. Both are how a closed public set gets written without a name.
Definition at line 77 of file audit_inline_choices.py.
| list audit_inline_choices.string_members | ( | collection | ) |
The string members of a literal collection, or None if it is not all strings.
| [in] | collection | An ast Set, List, or Tuple node. |
Definition at line 112 of file audit_inline_choices.py.
| int audit_inline_choices.main | ( | ) |
Fail when an inline choice set is neither named nor classified.
Definition at line 123 of file audit_inline_choices.py.
| audit_inline_choices.REPO_ROOT = Path(__file__).resolve().parents[2] |
Definition at line 23 of file audit_inline_choices.py.
| str audit_inline_choices.WAIVERS = REPO_ROOT / "tests" / "tooling" / "inline_choice_waivers.json" |
Definition at line 24 of file audit_inline_choices.py.
| tuple audit_inline_choices.MODULE_ROOTS |
Definition at line 27 of file audit_inline_choices.py.
| audit_inline_choices.MODULES = tuple(item[0] for item in _resolve_modules()) |
Definition at line 49 of file audit_inline_choices.py.
| audit_inline_choices.MODULE_DOTTED = dict(_resolve_modules()) |
Definition at line 50 of file audit_inline_choices.py.
| tuple audit_inline_choices.VALID_CLASSIFICATIONS |
Definition at line 54 of file audit_inline_choices.py.
| int audit_inline_choices.MIN_REASON_CHARS = 40 |
Definition at line 58 of file audit_inline_choices.py.
| int audit_inline_choices.MINIMUM_CHOICE_SIZE = 2 |
Definition at line 60 of file audit_inline_choices.py.