Skip to content

Importing Phase enum raise a deprecation warning #2485

@noirbizarre

Description

@noirbizarre

Describe the problem

#1948 introduced the copier.types.Phase enum exposed in a _copier_phase to fix an issue in copier-template-extensions. It allowed to scope template extensions processing to phases with exit conditions like:

if context.get("_copier_phase") is not Phase.RENDER:
    return

#2069 deprecated direct access to copier.types making all templates using it raise a deprecation warning.

Template

N/A

To Reproduce

  1. Create a template using copier-template-extensions
  2. Add an exit condition on the phase like
from copier_template_extensions import ContextHook

class ContextUpdater(ContextHook):
    def hook(self, context: dict[str, Any]) -> dict[str, Any] | None:
        if context.get("_copier_phase") is not Phase.RENDER:
            return
  1. Apply or update the template

Logs

DeprecationWarning: Importing `Phase` from `copier.types` is deprecated. This module member is intended for internal use only and will become inaccessible in the future. If you have any questions or concerns, please raise an issue at <https://github.com/copier-org/copier/issues>.

Expected behavior

copier.types.Phase is considered part of the public API and does not raise a DeprecationWarning.
(Maybe it needs to be moved somewhere else, in a module dedicated to public types)

Screenshots/screencasts/logs

No response

Operating system

Linux

Operating system distribution and version

Archlinux

Copier version

9.11.3

Python version

3.13

Installation method

uvx+pypi

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriageTrying to make sure if this is valid or not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions