Fix ImportError from private typing module members in Python 3.8#661
Closed
Copilot wants to merge 3 commits intofeature/uv-package-managementfrom
Closed
Fix ImportError from private typing module members in Python 3.8#661Copilot wants to merge 3 commits intofeature/uv-package-managementfrom
Copilot wants to merge 3 commits intofeature/uv-package-managementfrom
Conversation
Co-authored-by: rororowyourboat <48771381+rororowyourboat@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ImportError in uv-based package management
Fix ImportError from private typing module members in Python 3.8
Jan 22, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes a Python 3.8 compatibility issue by replacing private typing module members with public APIs. The code previously imported _UnionGenericAlias and _GenericAlias from the typing module, which are internal implementation details that don't exist in Python 3.8, causing ImportError.
Changes:
- Replace private typing imports (
_UnionGenericAlias,_GenericAlias) with publicget_originAPI - Consolidate type checking logic from two separate conditions into a single check using
get_origin(x) is not None - Add explanatory comment for the generic type handling
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
rororowyourboat
approved these changes
Jan 22, 2026
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.
The code imports
_UnionGenericAliasand_GenericAliasfrom thetypingmodule, which are private APIs not guaranteed to exist across Python versions. In Python 3.8, these members don't exist, causingImportError: cannot import name '_UnionGenericAlias' from 'typing'.Changes
_UnionGenericAliasand_GenericAliaswith public APIget_origintype(x) == _UnionGenericAlias or type(x) == _GenericAlias→get_origin(x) is not NoneBefore:
After:
This maintains compatibility with Python 3.8+ using only public typing APIs.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.