summaryrefslogtreecommitdiff
path: root/src/pip/_internal/exceptions.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove setup.py install legacyStéphane Bidoul2023-03-311-14/+0
|
* Implement `--break-system-packages` for EXTERNALLY-MANAGED installations ↵Stefano Rivera2023-02-061-1/+3
| | | | | | | | | | (#11780) The PEP 668 expects an override mechanism to ease the transition. This provides an override. --------- Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
* Fall back to non-localized message on WindowsTzu-ping Chung2023-01-031-1/+11
| | | | | | Windows does not implement LC_MESSAGES, and since PEP 668 is mainly designed for Linux distributions, we simply take the easier way out until someone wants an equivalent on Windows.
* Add tests for EXTERNALLY-MANAGED parserTzu-ping Chung2023-01-031-9/+14
|
* Isolate EXTERNALLY-MANAGED parsing logicTzu-ping Chung2023-01-031-4/+12
| | | | This makes the parser easier to test.
* Use ExternallyManagedEnvironment to show errorTzu-ping Chung2023-01-031-1/+63
| | | | | This moves most of the displaying logic into the exception class so it can better leverage DiagnosticPipError and Rich functionalities.
* Use data-dist-info-metadata (PEP 658) to decouple resolution from ↵Danny McClanahan2022-09-101-6/+5
| | | | | downloading (#11111) Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
* Use --no-implicit-optional for type checkinghauntsaninja2022-08-121-1/+4
| | | | | | | | | This makes type checking PEP 484 compliant (as of 2018). mypy will change its defaults soon. See: https://github.com/python/mypy/issues/9091 https://github.com/python/mypy/pull/13401
* Drop the doctype check (#10906)q0w2022-02-271-24/+0
| | | Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
* Place the link as "context" instead of "Link:"Pradyun Gedam2022-02-021-2/+2
|
* Warn on bad/missing doctype declarations instead of erroring outPradyun Gedam2022-02-011-0/+24
| | | | | | This is a less disruptive mode of operation, and helps ensure that users who are using documents that don't declare the doctype are presented with a warning; instead of getting a hard-failure.
* Add a dedicated exception for metadata generation failuresPradyun Gedam2022-01-251-0/+19
|
* Add diagnostics to `InstallationSubprocessError`Pradyun Gedam2022-01-251-9/+36
| | | | | | This more clearly states where the error came from, presents it in a more approachable format with context provided for what this error is related to.
* Improve presentation of `LegacyInstallFailure`Pradyun Gedam2022-01-251-0/+14
| | | | | These errors now more clearly note where the error occurred and what component is at fault.
* Clearly document that exceptions shouldn't import any internalsPradyun Gedam2022-01-251-1/+6
| | | | | This file should be importable in all other modules, which means it can't be importing any of those modules (to prevent an import loop).
* Escape the package name, allowing rich to stylize URLs and linksPradyun Gedam2021-12-121-2/+3
|
* Stop stylizing PEP **518**Pradyun Gedam2021-12-121-2/+2
| | | | This is a slightly cleaner presentation style.
* Clean up where `Text` is used to wrap diagnostic messages.Pradyun Gedam2021-12-121-8/+7
| | | | | | This is only necessary on messages which may contain `[`, which needs to be escaped before printing with rich, since rich treats them as output formats.
* Replace {attention -> note}_stmtPradyun Gedam2021-12-121-12/+8
| | | | The new name is a closer match with what is presented to the user.
* Enable the use of rich for presenting outputPradyun Gedam2021-12-121-3/+3
| | | | | | | | | | This makes it possible to present output with rich markup, within the constraints of our logging infrastructure. Further, diagnostic errors can now by presented using rich, using their own special "[present-diagnostic]" marker string, since those need to be handled differently from regular log messages and passed directly through to rich's console object, after an indentation wrapper.
* Improve DiagnosticPipError presentationPradyun Gedam2021-12-121-33/+100
| | | | | | | | | | | | | Borrow error presentation logic from sphinx-theme-builder, and exhaustively test both the unicode and non-unicode presentation. Utilise rich for colours and presentation logic handling, with tests to ensure that colour degradation happens cleanly, and that the content is stylized exactly as expected. Catch diagnostic errors eagerly, and present them using rich. While this won't include the pretty presentation in user logs, those files will contain the entire traceback upto that line.
* NoneMetadataError doesn't need pkg_resources nowTzu-ping Chung2021-12-041-3/+2
|
* Remove pkg_resources usages from utils modulesTzu-ping Chung2021-12-041-6/+6
| | | | Relevant functionalities are moved into pip._internal.metadata.
* Merge pull request #10535 from lukasjuhrich/mainPradyun Gedam2021-11-121-0/+11
|\
| * Improve BadZipFile reportingLukas Juhrich2021-10-231-0/+11
| |
* | Implement diagnostic errors for `build-system.requires` issuesPradyun Gedam2021-10-221-0/+39
| | | | | | | | | | This demonstrates how the new diagnostic errors are to implement, and how they get presented to users.
* | Fix a typoPradyun Gedam2021-10-221-1/+1
| | | | | | Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
* | Introduce `DiagnosticPipError`Pradyun Gedam2021-10-221-2/+81
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces an exception and presentation model, for providing better errors messages. The motivating idea is that the better error messages contain clear wording and provide additional context to users to better understand what is happening. The `DiagnosticPipError` class introduces a structured framework in our exception model, for code authors to write their error messages. The usage explicitly requires passing "context" and a "hint" (which accept None values). This should nudge code authors to explicitly think about what additional information can/should be presented to the user, and to provide relevant hints to them whenever possible. It also makes it straightforward to identify cases where we don't do this, which may serve as clear areas for improvement in the future. The initial implementation is intentionally basic and doesn't do much; however we should be able to introduce better usage of terminal colors and other features (eg: hyperlinks!) to further improve the presentation of these errors. It does improve the presentation style by a bit, even though there are significant presentation-related improvements to be made. Additionally, having a structured framework means that these would be improvements in presentation of *all* the errors that are within this framework -- increasing the benefits of investing in the presentation of these errors.
* Remove direct pkg_resource usages from resolver and preparerTzu-ping Chung2021-08-231-2/+7
|
* Reformat the codebase, with blackPradyun Gedam2021-08-201-46/+66
|
* Fix __bool__harupy2021-08-071-1/+1
| | | | Signed-off-by: harupy <hkawamura0130@gmail.com>
* Merge branch 'main' into type-annotations-internalHarutaka Kawamura2021-08-061-3/+0
|\
| * Remove Python 2 __nonzero__ method definitionsJon Dufresne2021-08-021-5/+1
| |
* | convert type commentsharupy2021-07-241-56/+39
|/
* Implement sysconfig locations and warn on mismatchTzu-ping Chung2021-02-231-0/+15
|
* Remove typing.TYPE_CHECKING guardsJon Dufresne2021-02-191-6/+5
| | | | | | | | | | | The typing module has been available since Python 3.5. Guarding the import has been unnecessary since dropping Python 2. Some guards remain to either: - Avoid circular imports - Importing objects that are also guarded by typing.TYPE_CHECKING - Avoid mypy_extensions dependency
* Replace pip._internal.utils.typing with stdlib typingJon Dufresne2021-02-181-3/+2
| | | | | | | | The stdlib module has been available since Python 3.5 and the TYPE_CHECKING constant has been available since 3.5.2. By using stdlib, this removes the need for pip to maintain its own Python 2 typing compatibility shim.
* Include both sources in inconsistency errorTzu-ping Chung2021-01-181-6/+9
|
* Merge remote-tracking branch 'upstream/master' into 7969-revert-sbiStéphane Bidoul2020-12-271-22/+27
|\
| * Re-apply invalid metadata skipTzu-ping Chung2020-12-271-0/+15
| | | | | | | | | | | | Skip candidate not providing valid metadata This reverts commit 7165ab8cb9a0d6297b5a0dcd7d9a84350d0a0b3b.
| * Use f-strings for simple string formattingJon Dufresne2020-12-251-5/+5
| | | | | | | | | | | | | | Use pyupgrade to convert simple string formatting to use f-string syntax. pyupgrade is intentionally timid and will not create an f-string if it would make the expression longer or if the substitution parameters are anything but simple names or dotted names.
| * Merge pull request #9354 from jdufresne/superPradyun Gedam2020-12-251-3/+2
| |\ | | | | | | Use short Python3 super() syntax
| | * Use short Python3 super() syntaxJon Dufresne2020-12-241-3/+2
| | |
| * | Replace typing.Text with strJon Dufresne2020-12-241-2/+2
| |/ | | | | | | | | | | | | Using typing.Text is unnecessary since dropping Python 2 support. In Python 3, typing.Text is a simple alias of str. It exists as a backward compatibility shim for Python 2.
| * Remove __future__ importsJon Dufresne2020-12-241-2/+0
| | | | | | | | Unnecessary since dropping Python 2.
| * Remove redundant Python 2.7 codeHugo van Kemenade2020-12-221-10/+3
| |
* | Revert "Create call_subprocess just for vcs commands"Stéphane Bidoul2020-12-271-5/+0
|/ | | | This reverts commit 8adbc216a647b6b349f1b7f1eaa9e71cd3108955.
* Revert "Skip candidate not providing valid metadata"revert-9264-new-resolver-dont-abort-on-inconsistent-candidatePradyun Gedam2020-12-151-15/+0
|
* Skip candidate not providing valid metadataTzu-ping Chung2020-12-121-0/+15
| | | | | | | | | | | | | | | | | | | | | | This is done by catching InstallationError from the underlying distribution preparation logic. There are three cases to catch: 1. Candidates from indexes. These are simply ignored since we can potentially satisfy the requirement with other candidates. 2. Candidates from URLs with a dist name (PEP 508 or #egg=). A new UnsatisfiableRequirement class is introduced to represent this; it is like an ExplicitRequirement without an underlying candidate. As the name suggests, an instance of this can never be satisfied, and will cause eventual backtracking. 3. Candidates from URLs without a dist name. This is only possible for top-level user requirements, and no recourse is possible for them. So we error out eagerly. The InstallationError raised during distribution preparation is cached in the factory, like successfully prepared candidates, since we don't want to repeatedly try to build a candidate if we already know it'd fail. Plus pip's preparation logic also does not allow packages to be built multiple times anyway.
* Bump mypy to 0.790 for Python 3.9 compatNguyễn Gia Phong2020-10-121-1/+1
| | | | | | | HashError.order is now annotated as an int to allow HashErrors.errors.sort(key=lambda e: e.order). Alternatively we can define a function which assert e is not None but I prefer the more concise version, since we never raise HashError directly anyway.