Skip to content

Add public is_patched() helper in patch module #4

@jensens

Description

@jensens

Context

In 2.0, plone.registryfromenviron.patch._originals is the source of truth for "is the patch currently applied?" — but it's underscore-prefixed, i.e. private API.

registry.py currently notes in its docstring:

Use `bool(plone.registryfromenviron.patch._originals)` if that distinction matters.

…which is a workaround, not a public API.

Use case

Operators / downstream code that wants to branch on "is env-var override active?" (e.g. in a /manage view, a health probe, or a subscriber).

v1.x let users write isinstance(reg, EnvOverrideRegistry). The 2.0 alias makes that check always return True, so anyone who relied on it needs a replacement.

Suggested API

# in plone.registryfromenviron.patch

def is_patched() -> bool:
    \"\"\"Return True iff the env-var override patch is currently active.\"\"\"
    return bool(_originals)

Update the registry.py docstring to recommend the public helper instead of the private dict.

Scope

Trivial — one function, one docstring tweak, one test. Good first issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions