CleanPlan#

class scikitplot.cleanprompt.CleanPlan(packs=('auto',), formats=('all',), custom=(), conflict='error', profile=None, core=True, style='placeholder', keep=(), roles=(), infer_roles=False, ner='none', language='en', hide=(), allow=(), remember=True, pattern_risk=None, surrogates=None, configured=())[source]#

Everything a cleaner needs to know, and nothing it discovers.

Parameters:
packstuple of str

Pack names, or one of ('all',), ('auto',), ('none',).

formatstuple of str

Format names or extensions, or ('all',).

customtuple of str

Paths of custom definition files.

conflict{‘error’, ‘replace’}

How custom definitions treat a built-in of the same name.

profilestr or None

A core-pattern profile: 'minimal', 'balanced' or 'strict'.

corebool

Whether the built-in structural patterns run at all.

stylestr

'placeholder' or 'surrogate'.

keeptuple of str

Artefact parts to send rather than remove.

rolestuple of (str, str)

Declared column roles.

infer_rolesbool

Whether to guess column roles from names.

nerstr

Entity engine mode; 'none' for no entity detection.

languagestr

Language for entity detection.

hidetuple of str

Literal terms to hide.

allowtuple of str

Literal terms never to hide.

rememberbool

Once a value is hidden, hide it wherever it appears later — in prose, in another file, in the next turn — not only where a pattern or field rule finds it again.

pattern_risk{‘warn’, ‘ignore’, ‘refuse’} or None

What a custom pattern with a catastrophic-backtracking shape does. None (default) defers to CLEANPROMPT_PATTERN_RISK, else 'warn'. Pin 'refuse' in a team plan file to make the check a gate.

surrogatesstr or None

Path of a custom surrogate set (_surrogate_sets) whose names replace the built-in ones. Requires style='surrogate'. The set’s identity joins the fingerprint, so editing the set file makes a saved plan stale.

Parameters:

Notes

Developer notes. Tuples, never lists or sets, so a plan is hashable and its canonical form does not depend on iteration order: every collection is sorted when it enters, by FluentCleanPrompt.

pattern_risk and surrogates are left out of as_dict while they are None, so every plan saved before the fields existed keeps its fingerprint (I12): adding a setting must not invalidate approved plan files.

allow: tuple[str, ...] = ()#
as_dict()[source]#

Return the plan as plain data.

Returns:
dict

JSON-safe. configured is left out: it records how the plan was built, not what it means. pattern_risk and surrogates are left out while they are None.

Return type:

dict[str, Any]

catalog()[source]#

Return the catalog this plan resolves against.

Returns:
Catalog

The built-ins, with the plan’s custom definitions merged in.

Return type:

Catalog

configured: tuple[str, ...] = ()#
conflict: str = 'error'#
core: bool = True#
custom: tuple[str, ...] = ()#
fingerprint()[source]#

Return a digest of the selection and the definitions it resolves to.

Returns:
str

Hex SHA-256.

Raises:
CleanPromptError

If the plan does not validate.

Return type:

str

formats: tuple[str, ...] = ('all',)#
formats_selection()[source]#

Return formats in the form Catalog.resolve_formats takes.

Return type:

str | tuple[str, …]

hide: tuple[str, ...] = ()#
infer_roles: bool = False#
keep: tuple[str, ...] = ()#
language: str = 'en'#
ner: str = 'none'#
packs: tuple[str, ...] = ('auto',)#
packs_selection()[source]#

Return packs in the form Catalog.resolve_packs takes.

Return type:

str | tuple[str, …]

pattern_findings()[source]#

Return every pattern-risk finding in this plan’s custom packs.

Returns:
list of PackFinding

Accepted findings included (accepted set), so a review can list what was waived. Built-in packs are proven clean by the test suite and are not analysed.

Return type:

list

pattern_risk: str | None = None#
pattern_risk_mode()[source]#

Return the pattern-risk mode in force for this plan.

Returns:
str

pattern_risk when set, else CLEANPROMPT_PATTERN_RISK, else 'warn'.

Raises:
ValueError

If the mode, set or from the environment, is not a known one.

Return type:

str

profile: str | None = None#
remember: bool = True#
roles: tuple[tuple[str, str], ...] = ()#
style: str = 'placeholder'#
surrogate_set()[source]#

Return the plan’s custom surrogate set, loaded and validated, or None.

Returns:
SurrogateSet or None

None when the plan names no set.

Raises:
PackError

If the set document is invalid.

CleanPromptError

If the file is missing, too large, or of an unknown type.

surrogates: str | None = None#
validate()[source]#

Return every problem with this plan, without raising.

Returns:
list of str

Empty when the plan can be materialized.

Return type:

list[str]