Skip to content

Commit

Permalink
Improve support for deprecated builders without env arg (#10702)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
  • Loading branch information
jdknight and AA-Turner committed Jul 25, 2022
1 parent cc1f6cb commit 9845500
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sphinx/builders/__init__.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sphinx/registry.py
Expand Up @@ -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
Expand Down

0 comments on commit 9845500

Please sign in to comment.