Optional dependency crashes the import chain when the import itself isn't optional - #1
Merged
pcescato merged 3 commits intoSep 6, 2026
Conversation
…hen the import itself isn't optional
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The added article has frontmatter/body formatting issues (invalid tags YAML indentation and an H1 in content despite site-injected H1) that can break parsing or render incorrectly on the docs site.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR publishes a new community knowledge-base article explaining why “optional dependencies” in pyproject.toml can still break imports when the corresponding Python imports are unconditional, and how to fix it by deferring/guarding imports or promoting the dependency to required.
Changes:
- Adds a new Programming article describing the failure mode and remediation pattern for optional dependencies that are imported at module load time.
- Includes examples contrasting deferred guarded imports vs. unconditional top-level imports.
File summaries
| File | Description |
|---|---|
| knowledge/programming/optional-dependency-crashes-the-import-chain-when-the-import-itself-isn-t-option.md | New article covering optional-dependency import-chain crashes and recommended import/packaging fixes. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+8
to
+13
| tags: | ||
| - python | ||
| - packaging | ||
| - pyproject-toml | ||
| - dependencies | ||
| - imports |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Community contribution generated by the Shared Knowledge MCP.
knowledge/programming/optional-dependency-crashes-the-import-chain-when-the-import-itself-isn-t-option.mdThis Pull Request is the publication request: merging it makes the article eligible for publication on the documentation site.