Commit Graph

67 Commits

Author SHA1 Message Date
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
Pradyun Gedam 599fc57114
Merge pull request #9633 from jdufresne/blacken-utils
Blacken src/pip/_internal/utils directory
2021-02-21 15:58:25 +00:00
Jon Dufresne 83c596ff70 Blacken src/pip/_internal/cli directory
In autocompletion.py, the should_list_installed boolean expression was
flipped to workaround upstream black bug:

https://github.com/psf/black/issues/1629

The bug makes black fail to stabilize formatting when the list isn't the
last piece of the expression.
2021-02-21 07:29:15 -08:00
Jon Dufresne a9d4446dc4 Blacken src/pip/_internal/utils directory 2021-02-21 07:24:35 -08:00
Pradyun Gedam 51f0fb2781
Tweak and blacken noxfile.py 2021-02-21 13:03:38 +00:00
Jon Dufresne 8a6f6ac19b Blacken src/pip/_internal/resolution directory 2021-02-20 06:51:44 -08:00
Jon Dufresne 7ffd0ca13e Complete typing of noxfile.py
Allows removing a "mypy: disallow-untyped-defs=False" comment.

To workaround a mypy bug, map(os.path.basename, distribution_files) was
changed to use a generator expression. See:
https://github.com/python/mypy/issues/9864

To verify correct usage of the nox API, it is now a dependency during
pre-commit mypy runs.

The mypy configuration "follow_imports = silent" allowed erroneous code
to pass, so it has been removed. Now, all imports must be available
during type.
2021-02-19 05:47:55 -08:00
Stéphane Bidoul fe3aec0f5e
Better way to run slow linters in CI only
Taking advantage of pre-commit's manual stage.
2021-01-24 15:39:51 +01:00
Stéphane Bidoul e25b183459
Update pre-commit hooks 2021-01-24 15:25:37 +01:00
Pradyun Gedam 1eebb12550
Merge pull request #9335 from hugovk/rm-2
Remove redundant Python 2.7 code
2020-12-23 17:49:30 +00:00
Stéphane Bidoul 41e4547542
Merge pull request #9333 from sbidoul/pre-commit-speed-sbi
Improve local pre-commit experience
2020-12-23 12:47:20 +01:00
Hugo van Kemenade 817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Stéphane Bidoul ccbf085095
Improve local pre-commit experience 2020-12-21 20:10:44 +01:00
Jon Dufresne c0a7444de6 Update isort URL: timothycrosley/isort → PyCQA/isort 2020-12-19 15:28:02 -08:00
Nguyễn Gia Phong cf6ecab627 Bump mypy to 0.790 for Python 3.9 compat
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.
2020-10-12 17:37:55 +07:00
Pradyun Gedam c5744d5643
Enforce news/*.{correct-kind}.rst naming 2020-10-03 16:48:51 +05:30
Pradyun Gedam e5deff909c
Add black to pre-commit, ignoring all files
Each of the lines in this "exclude" pattern will get a dedicated PR
to remove it and would blacken that part of the codebase.
2020-09-24 15:36:38 +05:30
Pradyun Gedam 25ab172b55
Update linter: isort 2020-09-23 19:52:28 +05:30
Pradyun Gedam 89dad17b87
Update linter: pygrep-hooks 2020-09-23 19:52:20 +05:30
Pradyun Gedam e93c0ba6a3
Update linters
None of these require any changes to the codebase.
2020-09-23 19:50:53 +05:30
Nguyễn Gia Phong f8b06a3906 Enable flake8-logging-format 2020-07-17 14:33:19 +07:00
Devesh Kumar Singh 9a52dcd62b Add flake8-bugbear to pre-commit 2020-06-05 02:40:26 +05:30
Devesh Kumar Singh 60f00b837a Upgrade flake8 to 3.8.1
Co-Authored-By: Anthony Sottile <asottile@umich.edu>
2020-05-18 21:58:26 +05:30