Skip to content

refactor: Split exceptions into a package - #14176

Open
ichard26 wants to merge 9 commits into
pypa:mainfrom
ichard26:errors/refactor
Open

refactor: Split exceptions into a package#14176
ichard26 wants to merge 9 commits into
pypa:mainfrom
ichard26:errors/refactor

Conversation

@ichard26

@ichard26 ichard26 commented Jul 15, 2026

Copy link
Copy Markdown
Member

I'm planning to add even more diagnostic errors, but exceptions.py is starting to become unwieldy. I've converted it into a package to permit for further growth. To start, I've moved the following exceptions to their own submodules.

Group Exceptions moved
pyproject MissingPyProjectBuildRequires, InvalidPyProjectBuildRequires
wheel InvalidWheelFilename, UnsupportedWheel, InvalidWheel
hashes HashErrors, HashError, VcsHashUnsupported, DirectoryUrlHashUnsupported, HashMissing, HashUnpinned, HashMismatch
uninstall UninstallMissingRecord, LegacyDistutilsInstall
build_env BuildDependencyInstallError, VenvImportError, VenvCreationError
network NetworkConnectionError, ConnectionFailedError, ConnectionTimeoutError, SSLMissingError, SSLVerificationError, ProxyConnectionError, IncompleteDownloadError

I've left the remaining exceptions alone in exceptions/__init__.py. I'm happy to hear suggestions for more groupings.

In the near-to-medium future, I'm planning to add new diagnostic errors to wheel (and possibly a new resolution group).

Tip

This is probably much easier to review commit-by-commit.

@ichard26 ichard26 added skip news Does not need a NEWS file entry (eg: trivial changes) skip PR template check Silence the PR template check in CI labels Jul 15, 2026
@ichard26
ichard26 force-pushed the errors/refactor branch 2 times, most recently from a4ed1eb to 9d0cea7 Compare July 15, 2026 03:31
@ichard26

Copy link
Copy Markdown
Member Author

I've rebased this onto current main and massively simplified the diff by re-exporting the moved exceptions in exceptions/__init__.py to avoid impacting imports in ~30 pip source files.

Since this is going to conflict with the other error improvement work I'm doing, I'd like to get this landed sooner than later. Unless someone objects, I'll merge this within a few days.

Comment thread src/pip/_internal/exceptions/hashes.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news Does not need a NEWS file entry (eg: trivial changes) skip PR template check Silence the PR template check in CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants