Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPS: Lazy import defusedxml only when necessary #12362

Merged
merged 1 commit into from May 11, 2024

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented May 8, 2024

Subject: Move defusedxml import into the function using it

Feature or Bugfix

  • Refactoring

Purpose

Import defusedxml inside the etree_parse() function rather than in global scope of sphinx.testing.util. This makes it possible for reverse dependencies (such as breathe) to use this module without adding an unnecessary transitive dependency on defusedxml when it's not actually used.

Detail

Relates

Import `defusedxml` inside the `etree_parse()` function rather than
in global scope of `sphinx.testing.util`.  This makes it possible
for reverse dependencies (such as `breathe`) to use this module without
adding an unnecessary transitive dependency on `defusedxml` when it's
not actually used.

See also issue sphinx-doc#12339.
@chrisjsewell
Copy link
Member

Yeh I'd agree, but will wait to @picnixz to comment before merging

TBH etree_parse should probably not be a part of sphinx.testing in the first place, since it is not a part of the actual pytest fixtures, but that would be breaking

@picnixz
Copy link
Member

picnixz commented May 9, 2024

Independently on that, I still think that we need to split the dependencies but I think this one is fine enough as a simple patch for now. Also, it reduces the import time so it's an improvement on its own.

@chrisjsewell I'll let you merge this one if you want to improve the commit message

@chrisjsewell chrisjsewell changed the title Move defusedxml import into the function using it DEPS: Move defusedxml import into the function using it May 11, 2024
@chrisjsewell chrisjsewell linked an issue May 11, 2024 that may be closed by this pull request
@chrisjsewell chrisjsewell changed the title DEPS: Move defusedxml import into the function using it DEPS: Lazy import defusedxml only when necessary May 11, 2024
@chrisjsewell chrisjsewell merged commit ce86026 into sphinx-doc:master May 11, 2024
23 checks passed
@chrisjsewell
Copy link
Member

cheers!

@mgorny mgorny deleted the defusedxml-opt-import branch May 11, 2024 18:57
@mgorny
Copy link
Contributor Author

mgorny commented May 11, 2024

Thanks a lot!

stephenfin added a commit to hoodmane/sphinx-click that referenced this pull request May 14, 2024
Until Sphinx v7.3.8 or v7.4.0 is released with [1] included.

[1] sphinx-doc/sphinx#12362

Signed-off-by: Stephen Finucane <stephen@that.guru>
stephenfin pushed a commit to hoodmane/sphinx-click that referenced this pull request May 14, 2024
Until Sphinx cuts a release with [1] included.

[1] sphinx-doc/sphinx#12362
stephenfin added a commit to click-contrib/sphinx-click that referenced this pull request May 14, 2024
Until Sphinx v7.3.8 or v7.4.0 is released with [1] included.

[1] sphinx-doc/sphinx#12362

Signed-off-by: Stephen Finucane <stephen@that.guru>
stephenfin pushed a commit to click-contrib/sphinx-click that referenced this pull request May 14, 2024
Until Sphinx cuts a release with [1] included.

[1] sphinx-doc/sphinx#12362
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should defusedxml be moved to the runtime dependencies?
3 participants