Commit Graph

72 Commits

Author SHA1 Message Date
Damian Shaw 68529081c2
Enforce f-strings via Ruff (#12393) 2023-11-07 09:14:56 +00:00
Stéphane Bidoul 0621e5ad0d Add ireq.is_direct property, for readability 2023-04-16 12:01:04 +02:00
Stéphane Bidoul bc3feef9cc Remove setup.py install legacy 2023-03-31 09:47:09 +02:00
Stefano Rivera 9abb3c899a
Implement `--break-system-packages` for EXTERNALLY-MANAGED installations (#11780)
The PEP 668 expects an override mechanism to ease the transition.
This provides an override.

---------

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
2023-02-06 07:06:59 +00:00
Tzu-ping Chung 8fe6563050 Fall back to non-localized message on Windows
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.
2023-01-03 08:13:13 +08:00
Tzu-ping Chung 3d1937f420 Add tests for EXTERNALLY-MANAGED parser 2023-01-03 07:57:21 +08:00
Tzu-ping Chung 095fd850fd Isolate EXTERNALLY-MANAGED parsing logic
This makes the parser easier to test.
2023-01-03 07:57:21 +08:00
Tzu-ping Chung e27a819883 Use ExternallyManagedEnvironment to show error
This moves most of the displaying logic into the exception class so it
can better leverage DiagnosticPipError and Rich functionalities.
2023-01-03 07:57:21 +08:00
Danny McClanahan bad03ef931
Use data-dist-info-metadata (PEP 658) to decouple resolution from downloading (#11111)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2022-09-10 11:28:57 +01:00
hauntsaninja b9ec5ddc29 Use --no-implicit-optional for type checking
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
2022-08-12 18:44:48 -07:00
q0w a4f7508592
Drop the doctype check (#10906)
Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
2022-02-27 12:39:06 +00:00
Pradyun Gedam 6c92a33b6e
Place the link as "context" instead of "Link:" 2022-02-02 18:05:34 +00:00
Pradyun Gedam ea03179250
Warn on bad/missing doctype declarations instead of erroring out
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.
2022-02-01 17:58:31 +00:00
Pradyun Gedam d527e85146
Add a dedicated exception for metadata generation failures 2022-01-25 01:38:22 +00:00
Pradyun Gedam 1ee370637f
Add diagnostics to `InstallationSubprocessError`
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.
2022-01-25 01:38:22 +00:00
Pradyun Gedam 2a617d5455
Improve presentation of `LegacyInstallFailure`
These errors now more clearly note where the error occurred and what
component is at fault.
2022-01-25 01:38:22 +00:00
Pradyun Gedam 543d0b3165
Clearly document that exceptions shouldn't import any internals
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).
2022-01-25 01:38:22 +00:00
Pradyun Gedam 6b31f83187
Escape the package name, allowing rich to stylize URLs and links 2021-12-12 13:13:02 +00:00
Pradyun Gedam 961eb6f166
Stop stylizing PEP **518**
This is a slightly cleaner presentation style.
2021-12-12 13:11:36 +00:00
Pradyun Gedam d517dae1b7
Clean up where `Text` is used to wrap diagnostic messages.
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.
2021-12-12 13:11:36 +00:00
Pradyun Gedam 9f4117f2b8
Replace {attention -> note}_stmt
The new name is a closer match with what is presented to the user.
2021-12-12 13:11:36 +00:00
Pradyun Gedam 8feb24fd12
Enable the use of rich for presenting output
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.
2021-12-12 13:11:36 +00:00
Pradyun Gedam 03a87c22de
Improve DiagnosticPipError presentation
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.
2021-12-12 13:11:35 +00:00
Tzu-ping Chung e6b9ddc24a NoneMetadataError doesn't need pkg_resources now 2021-12-04 17:57:33 +08:00
Tzu-ping Chung cd01e4fd8f Remove pkg_resources usages from utils modules
Relevant functionalities are moved into pip._internal.metadata.
2021-12-04 17:57:33 +08:00
Pradyun Gedam e7c80c7b46
Merge pull request #10535 from lukasjuhrich/main 2021-11-12 09:57:11 +00:00
Lukas Juhrich 03c2ea0ff5 Improve BadZipFile reporting 2021-10-23 17:42:22 +02:00
Pradyun Gedam a00e7bcd88
Implement diagnostic errors for `build-system.requires` issues
This demonstrates how the new diagnostic errors are to implement, and
how they get presented to users.
2021-10-22 13:47:53 +01:00
Pradyun Gedam 3a02455451
Fix a typo
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
2021-10-22 13:41:48 +01:00
Pradyun Gedam 85b43482bb
Introduce `DiagnosticPipError`
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.
2021-10-22 13:41:40 +01:00
Tzu-ping Chung 135faabfd6
Remove direct pkg_resource usages from resolver and preparer 2021-08-23 02:07:33 +08:00
Pradyun Gedam 94999255d5
Reformat the codebase, with black 2021-08-20 13:37:49 +01:00
harupy 49afd8c45c Fix __bool__
Signed-off-by: harupy <hkawamura0130@gmail.com>
2021-08-07 00:58:21 +09:00
Harutaka Kawamura 75981eccd2
Merge branch 'main' into type-annotations-internal 2021-08-06 18:59:56 +09:00
Jon Dufresne 21fd93df0e Remove Python 2 __nonzero__ method definitions 2021-08-02 09:36:50 -07:00
harupy 6d665fd065 convert type comments 2021-07-24 13:13:10 +09:00
Tzu-ping Chung 7662c5961e Implement sysconfig locations and warn on mismatch 2021-02-23 01:57:42 +08:00
Jon Dufresne 0945809afc Remove typing.TYPE_CHECKING guards
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
2021-02-19 18:34:21 -08:00
Jon Dufresne a6392bd62e Replace pip._internal.utils.typing with stdlib typing
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.
2021-02-18 19:09:13 -08:00
Tzu-ping Chung 6c0e484703 Include both sources in inconsistency error 2021-01-18 19:00:52 +08:00
Stéphane Bidoul b3d348d6e7
Merge remote-tracking branch 'upstream/master' into 7969-revert-sbi 2020-12-27 17:01:58 +01:00
Stéphane Bidoul eda67075c1
Revert "Create call_subprocess just for vcs commands"
This reverts commit 8adbc216a6.
2020-12-27 16:54:56 +01:00
Tzu-ping Chung 41a30089de Re-apply invalid metadata skip
Skip candidate not providing valid metadata

This reverts commit 7165ab8cb9.
2020-12-27 04:16:24 +08:00
Jon Dufresne cdcf74fb8e Use f-strings for simple string formatting
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.
2020-12-25 16:21:20 -08:00
Pradyun Gedam f91ba6b348
Merge pull request #9354 from jdufresne/super
Use short Python3 super() syntax
2020-12-25 19:18:28 +00:00
Jon Dufresne 5e11687cbd Replace typing.Text with str
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.
2020-12-24 16:40:55 -08:00
Jon Dufresne c148bcc1aa Use short Python3 super() syntax 2020-12-24 15:11:51 -08:00
Jon Dufresne f32adaf09b Remove __future__ imports
Unnecessary since dropping Python 2.
2020-12-24 08:38:09 -08:00
Hugo van Kemenade 817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Pradyun Gedam 7165ab8cb9
Revert "Skip candidate not providing valid metadata" 2020-12-15 10:17:20 +00:00