Commit Graph

89 Commits

Author SHA1 Message Date
Damian Shaw 2a0acb595c
Update and provide fixes for mypy pre-commit (#12389)
* Update mypy to 1.6.1

* Fix mypy "Source file found twice under different module names" error

* Ignore type of intialized abstract class in tests

* Use more specific type ignore method-assign

* Type ignore for message.get_all

* Remove unused type ignore

* Add SizedBuffer type for xmlrpc.client.Transport subclass

* Add Self type for RequestHandlerClass in test

* Add type ignore for shutil.rmtree onexc handler

* Quote SizedBuffer

* Add news entry

* Remove no longer correct comment

* Update self import

* Also ignore type onerror=handler

* Update news entry

* Update news entry
2023-11-07 09:39:01 +00:00
Damian Shaw 9685f64fe8
Update ruff and config (#12390) 2023-11-06 09:30:05 +00:00
Christian Clauss dcb9dc0369 Wrap long lines 2023-10-03 09:13:55 +02:00
Christian Clauss 99a00f0a8d pre-commit autoupdate except mypy 2023-09-06 11:36:19 +02:00
Christian Clauss 69a1e956da Ruff rules C4,C90,PERF 2023-08-28 14:51:13 +02:00
Paul Moore bdef9159bd Use ruff for import sorting as well 2023-06-05 15:06:11 +01:00
Paul Moore 80cb6f443f Switch to ruff for linting 2023-06-05 14:26:05 +01:00
Pradyun Gedam 78ab4cf071
Bump all linters other than mypy (#11901) 2023-03-27 20:03:11 +01:00
Tzu-ping Chung a840f1d10c
Merge branch 'main' into keyring-multi-choice 2023-01-30 17:11:04 +08:00
Tzu-ping Chung b653b129c5 Bump pre-commit isort to 5.12.0
This release contains a critical fix for newer Poetry versions that
crashes due to "invalid" pyproject.toml syntax.
2023-01-30 17:06:13 +08:00
Dos Moonen 33cd541cc4 Make it possible to request a keyring provider: `auto`, `disabled`, `import` or `subprocess`
Refactored `_get_index_url()` to get integration tests for the subprocess backend working.

Keyring support via the 'subprocess' provider can only retrieve a password, not a username-password combo. The username therefor MUST come from the URL.
If the URL obtained from the index does not contain a username then the username from a matching index is used. `_get_index_url()` does that matching.

The problem this refactoring solves is that the URL where a wheel or sdist can be downloaded from does not always start with the index url. Azure DevOps Artifacts Feeds are an example since it replaces the friendly name of the Feed with the GUID of the Feed. Causing `url.startswith(prefix)` to evaluate as `False`.

The new behaviour is to return the index which matches the netloc and has the longest common prefix of the `path` property of the value returned by `urllib.parse.urlsplit()`. The behaviour for resolving ties is unspecified.
2023-01-30 09:00:59 +01:00
Pradyun Gedam fea8ae9f9f
Enable managing RTD redirects in-tree
This is designed as a script and a data file (in YAML format), and meant
to manage the RTD redirects with a version controlled file.

This makes it possible for pull requests to this repository to update
the redirects for this project's documentation (eg: for better error
urls) and for this evolution to be tracked as a part of version control
history.
2022-12-30 02:57:24 +00:00
Stephen Rosen 3ec4181e5e Update flake8 additional_dependencies via 'upadup' 2022-11-25 06:10:37 +00:00
Pradyun Gedam 4e48bbc31c
Move check-manifest to a CI check
This makes local runs of `nox -s lint` quicker while still providing
the relevant protections for checking the MANIFEST file.
2022-10-14 11:14:23 +01:00
Pradyun Gedam c39b2cc50c
Run `check-manifest` without build isolation
This is necessary to work in no-network environments like pre-commit.ci.
2022-10-08 13:36:08 +01:00
Pradyun Gedam 7257d5b31a
Tweak the pre-commit.ci configuration
This avoids modifying PRs and slows down the frequency of auto-update
pull requests.
2022-10-07 12:07:07 +01:00
Pradyun Gedam 2b9e3a958a
Remove pre-commit from GitHub Actions
This is a step in moving linting completely to pre-commit.ci.
2022-10-07 12:04:14 +01:00
Tzu-ping Chung 360b96305a Upgrade pre-commit hooks
Also fix some Mypy errors newly found with upgrade.
2022-07-18 15:13:12 +08:00
Pradyun Gedam 208937c6dd Update the versions of pinned packages in pre-commit environments 2022-04-22 16:09:12 +01:00
Pradyun Gedam 4085eb0236 Update pre-commit hooks
This makes the output easier to parse on failures in this.
2022-04-22 15:27:27 +01:00
Henrich Hartzer 2cfe36dc9e Update pre-commit hooks
Co-Authored-By: q0w <43147888+q0w@users.noreply.github.com>
2022-04-04 16:02:02 +03:00
q0w 8f696ee3ec Update black 2022-04-04 15:22:51 +03:00
Jon Dufresne 426691dc14 Install pytest in mypy environment
pytest includes type annotations and is PEP-561 compliant. This helps
ensure correct pytest API usage.

This caught a misuse of pytest.mark.skipif which did not include a
boolean argument. The test is now marked "network" and no longer
skipped.
2021-09-12 20:49:56 -07:00
Jon Dufresne 943af79f26 Run mypy on the tests directory
The tests are a large consumer of the pip API (both the internal API and
otherwise). By running mypy on tests, we help to:

1. Ensure the internal API is consistent with regards to typing

2. Ensure the tests are representative of real life scenarios as the API
   are used correctly.

3. Helps to recognize unnecessary tests that simply pass junk data to
   functions which can be caught by the type checker.

4. Make sure test support code in tests/lib/ is correct and consistent.
   This is especially important when refactoring such code. For example, if
   we were to replace tests/lib/path.py with pathlib.

As a first start, untyped defs are allowed. All existing typing issues
have been resolved. Overtime, we can chip away at untyped defs and
eventually remove the configuration option for stricter type checking of
tests.

The following changes were made to help make mypy pass:

Remove unused record_callback argument from make_wheel() in tests.
Unused since its introduction in
6d8a58f7e1.

Replace toml with tomli_w in tests/functional/test_pep517.py. Unlike the
toml package, tomli_w contains inline typing annotations.

Remove unnecessary make_no_network_finder(). Unnecessary since
bab1e4f8a1 where the _get_pages method was
removed.
2021-08-22 09:57:26 -06:00
Pradyun Gedam 585037a80a
Cleanup implicit string concatenation 2021-08-20 13:37:52 +01:00
Pradyun Gedam 94999255d5
Reformat the codebase, with black 2021-08-20 13:37:49 +01:00
Pradyun Gedam 4446d1a719
Merge pull request #10293 from jdufresne/nox
Upgrade nox to remove mypy ignores
2021-08-13 10:59:41 +01:00
Jon Dufresne 219def7e10 Blacken src/pip/_internal/vcs directory 2021-08-12 07:45:42 -07:00
Jon Dufresne 030b8b4ef6 Upgrade nox to remove mypy ignores 2021-08-12 07:41:30 -07:00
Nipunn Koorapati 2aab462b7f Bump mypy to 0.910
This notably gets us on a version of mypy that uses modular typeshed:
https://mypy-lang.blogspot.com/2021/05/the-upcoming-switch-to-modular-typeshed.html
which allows us to have finer control over what version of stubs we pull
in from typeshed. Also contains other routine improvements to mypy.

Required a few minor typing changes.

Add flag --show-error-code so errors look like this

src/pip/_internal/network/auth.py:70: error: Incompatible types in assignment
(expression has type "None", variable has type Module)  [assignment]

rather than

src/pip/_internal/network/auth.py:70: error: Incompatible types in assignment
(expression has type "None", variable has type Module)
2021-08-09 16:47:02 -07:00
Nipunn Koorapati 307f4d6c76 Bump black from 20.8b1 to 21.7b0 2021-08-09 01:18:42 -07:00
Pradyun Gedam 1897784d59
Blacken src/pip/_internal/index 2021-08-06 13:41:13 +01:00
Pradyun Gedam 5ab7c124db
Merge pull request #10192 from pradyunsg/blacken/commands
Blacken src/pip/_internal/commands/
2021-08-06 10:09:34 +01:00
Pradyun Gedam 069b01932a
Blacken src/pip/_internal/req
Progresses the black formatting of the codebase further.
2021-07-24 09:47:54 +01:00
Tzu-ping Chung 9ebd05c962
Merge pull request #10191 from pradyunsg/blacken/tools
Blacken tools/
2021-07-24 09:47:36 +08:00
Pradyun Gedam 1bc0eef056
Blacken src/pip/_internal/network/
Progresses the black formatting of the codebase further.
2021-07-23 20:51:50 +01:00
Pradyun Gedam 8e2e1964a4
Blacken src/pip/_internal/commands/
Progresses the black formatting of the codebase further.
2021-07-23 17:54:08 +01:00
Pradyun Gedam c7ee560e00
Blacken tools/
Progresses the black formatting of the codebase further.
2021-07-23 17:11:56 +01:00
Pradyun Gedam ebb80861ee
Blacken tests/lib 2021-04-02 11:59:57 +01:00
Pradyun Gedam 55b12ba23a
Blacken conftest.py 2021-04-02 10:22:08 +01:00
Pradyun Gedam 5bc7b33d41
Merge pull request #9755 from pradyunsg/update-setup-py-file 2021-04-02 01:57:46 +01:00
Pradyun Gedam 2495cf95a6
Blacken __main__.py 2021-04-01 23:04:23 +01:00
Pradyun Gedam df0955d535
Blacken setup.py 2021-04-01 23:00:10 +01:00
Pradyun Gedam 6ff1f7da2f
Merge pull request #9739 from pradyunsg/tests/drop-YAML-based-resolver-tests
Drop YAML tests for the resolver
2021-03-28 07:56:09 +01:00
Pradyun Gedam ad63666749
Drop YAML tests for the resolver
We've created a fairly capable setup with the new resolver tests,
which has now rendered this logic redundant and generally unnecessary.
2021-03-21 11:55:07 +00:00
Jon Dufresne 96615e92c4 Complete typing of docs directory 2021-03-06 14:14:34 -08:00
Pradyun Gedam b5d4b27aef
Enable black on docs/ 2021-03-06 11:09:14 +00:00
Pradyun Gedam 79cca313c2
Merge pull request #9641 from jdufresne/black-dist
Blacken the src/pip/_internal/distributions directory
2021-02-23 13:17:14 +00:00
Tzu-ping Chung d37fdf27d3
Merge pull request #9635 from jdufresne/blacken-cli
Blacken src/pip/_internal/cli directory
2021-02-23 04:30:42 +08:00
Jon Dufresne cd1fb590e7 Blacken the src/pip/_internal/distributions directory 2021-02-21 08:52:50 -08:00