Skip to content

Commit

Permalink
always default create optional environment for deprecated builders
Browse files Browse the repository at this point in the history
Builder implementation would originally always create an optional
environment instance, which an extended builder's implementation could
reference in their own `__init__` call. However, with the change [1] to
support an `env` argument, there is no longer a guarantee that
`self.env` will exist. This commit changes this to restore the creating
of `self.env` if `env` if not passed in.

[1]: 6ef22d2

Signed-off-by: James Knight <james.d.knight@live.com>
  • Loading branch information
jdknight committed Jul 24, 2022
1 parent 7a39a30 commit c83c83c
Showing 1 changed file with 2 additions and 1 deletion.
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 = Optional[BuildEnvironment] # type: ignore[assignment]
self.events: EventManager = app.events
self.config: Config = app.config
self.tags: Tags = app.tags
Expand Down

0 comments on commit c83c83c

Please sign in to comment.