From 9845500ffa6b75266b1e34701c15eb8e586aa17e Mon Sep 17 00:00:00 2001 From: James Knight Date: Mon, 25 Jul 2022 18:10:24 -0400 Subject: [PATCH] Improve support for deprecated builders without env arg (#10702) Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- sphinx/builders/__init__.py | 3 ++- sphinx/registry.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py index 62a369a912d..2aede5c2468 100644 --- a/sphinx/builders/__init__.py +++ b/sphinx/builders/__init__.py @@ -89,10 +89,11 @@ def __init__(self, app: "Sphinx", env: BuildEnvironment = None) -> None: self.env: BuildEnvironment = env self.env.set_versioning_method(self.versioning_method, self.versioning_compare) - elif env is not Ellipsis: + else: # ... is passed by SphinxComponentRegistry.create_builder to not show two warnings. warnings.warn("The 'env' argument to Builder will be required from Sphinx 7.", RemovedInSphinx70Warning, stacklevel=2) + self.env = None self.events: EventManager = app.events self.config: Config = app.config self.tags: Tags = app.tags diff --git a/sphinx/registry.py b/sphinx/registry.py index 561fba69b74..b4893e02cfd 100644 --- a/sphinx/registry.py +++ b/sphinx/registry.py @@ -166,7 +166,7 @@ def create_builder(self, app: "Sphinx", name: str, f"'env'argument. Report this bug to the developers of your custom builder, " f"this is likely not a issue with Sphinx. The 'env' argument will be required " f"from Sphinx 7.", RemovedInSphinx70Warning, stacklevel=2) - builder = self.builders[name](app, env=...) # type: ignore[arg-type] + builder = self.builders[name](app) if env is not None: builder.set_environment(env) return builder