Commit Graph

91 Commits

Author SHA1 Message Date
Stéphane Bidoul 9692d48822 Drop isort and flake8 settings from setup.cfg
Since we use ruff, these are not used anymore.
2023-10-01 11:51:37 +02:00
hauntsaninja ac19f79049 Follow imports for more vendored dependencies
This will allow mypy to notice if you e.g. try to call a colorama
function that does not exist. Note we won't report any errors in
vendored code due to the ignore_errors config above.

It would also be quite easy to let mypy look at pkg_resources code, but
this would involve the addition of like three type ignores.
2023-09-23 17:50:25 -07:00
Shantanu eddd9ddb66
Enable mypy's strict equality checks (#12209)
This makes mypy check more behaviours within the codebase.

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
2023-09-23 17:10:13 +01:00
Roman Donchenko 440487792c
Include `AUTHORS.txt` in pip's wheels (#11882) 2023-03-27 11:34:43 +01:00
Pradyun Gedam 85da66d06b
Ignore mypy errors in logic from jaraco.text 2023-02-05 11:40:15 +00:00
Tzu-ping Chung 50e194f107 Selectively enable user site
The modern virtual environment structure does not allow us to enable
"fake user site" while disabling the global site, so we need to do more
fine-grained configuration to correctly set up test environments for
each test case.

With this done, we can also properly support the stdlib venv ad the test
environment backend, since it basically works identically with modern
virtualenv. The incompatible_with_test_venv is thus removed.
2022-10-28 01:51:13 +08:00
hauntsaninja 4d13842ec6 fixups 2022-08-12 18:48:39 -07:00
Tzu-ping Chung c611db6514 Add /src explicitly to MYPY_PATH
Newer versions of Mypy seems to prefer packages in the site-packages
directory over those found in the project directory. This causes issues
if Mypy is installed in an environment that has an older pip version
present, e.g. pre-commit. Adding our pip into MYPY_PATH seems to fix
the issue.
2022-07-22 16:51:19 +08:00
Pradyun Gedam 840d54b5e2 Disable spurious flake8-bugbear warnings 2022-04-22 16:13:09 +01:00
Jon Dufresne c71cf88049 Complete type annotations of tests/functional/ directory 2021-11-18 18:26:17 -08:00
Hugo van Kemenade 7c9da5f512 Remove redundant Python 2 code 2021-11-08 12:02:17 +02:00
Tzu-ping Chung cb2d4b89a7
Merge pull request #10526 from uranusjr/remove-extra-merge-xfail 2021-09-30 16:34:39 +08:00
Tzu-ping Chung 5aace2a5d2 Har-fail on unexpected xfail pass 2021-09-30 15:20:13 +08:00
Jon Dufresne 72937f6520 Complete type annotations for tests/conftest.py and tests/lib/* 2021-09-29 19:57:29 -07:00
Jon Dufresne 60c274be2d Complete type annotations of tests/unit/ directory 2021-09-23 05:44:54 -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 3e640bc0ad
Merge pull request #10358 from uranusjr/sysconfig-switch-python-310
Switch install scheme backend to sysconfig
2021-08-21 18:44:30 +01:00
Jon Dufresne 7609f35ca0 Remove unused "retrying" package from mypy configuration
Unused since 64ecfc8476.
2021-08-21 06:53:13 -06:00
Tzu-ping Chung e483f533fa Switch install scheme backend to sysconfig
This is only done for Python 3.10+ so we don't disrupt too many existing
pip installations.
2021-08-21 00:53:59 +08:00
harupy 2395bc5059 Use --color=yes 2021-07-04 22:14:22 +09: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
Tzu-ping Chung e2892355d8 Default to follow-imports = normal instead 2021-03-16 00:32:35 +08:00
Tzu-ping Chung 4807de8e73 Set follow_imports = silent 2021-03-10 13:06:21 +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
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
Jon Dufresne d282fb94a3 Use unified OSError and its subclasses
Since Python 3.3, the following classes have merged into OSError. They
remain as aliases for backward compatibility.

- EnvironmentError
- IOError
- WindowsError

https://docs.python.org/3/library/exceptions.html#OSError

Python 3 also has subclasses of OSError to help identify more specific
errors. For example, FileNotFoundError. This allows simplifying some
except blocks.
2020-12-26 12:16:09 -08:00
Pradyun Gedam f2d2d10e4f
Merge pull request #9339 from jdufresne/setup-cfg-universal
Remove "universal" from "bdist_wheel" configuration
2020-12-26 10:22:27 +00:00
Jon Dufresne 53234e578f Remove obsolete "# type: ignore" comments
Obsolete since dropping Python 2 support.

Add the mypy setting "warn_unused_ignores = True" to catch these
earlier.
2020-12-23 15:42:48 -08:00
Jon Dufresne 1f3b0300df Remove "universal" from "bdist_wheel" configuration
Since dropping Python 2 support, the wheel is no longer universal. See
the wheel docs:
https://wheel.readthedocs.io/en/stable/user_guide.html#building-wheels

> If your project … is expected to work on both Python 2 and 3, you will
> want to tell wheel to produce universal wheels by adding this to your
> setup.cfg file:
2020-12-23 08:41:48 -08:00
Tzu-ping Chung 145be2eaf2 Skip pip search tests unless explicitly requested 2020-12-15 17:23:20 +08:00
Pradyun Gedam 07ec3013f0
Drop custom logic for new_resolver tests 2020-10-30 07:16:19 +05:30
Pradyun Gedam 061dbe8ed5
Merge pull request #8907 from hugovk/isort-5-config-updates 2020-09-24 21:40:57 +05:30
Hugo van Kemenade 212ba79390
Merge branch 'master' into isort-5-config-updates 2020-09-24 14:57:33 +03:00
Hugo van Kemenade 8fc985eccb Flake8: use extend-ignore to avoid needing to redefine defaults 2020-09-24 14:35:53 +03:00
Hugo van Kemenade f8fe3531b9 Remove unnecessary config for isort 5 2020-09-23 22:00:32 +03:00
Pradyun Gedam 58c594c06b
Prepare isort for black 2020-09-23 21:47:47 +05:30
Pradyun Gedam a00f85d22b
Prepare flake8 for black 2020-09-23 21:47:46 +05:30
Nguyễn Gia Phong f8b06a3906 Enable flake8-logging-format 2020-07-17 14:33:19 +07:00
Chris Hunt cb540f30e3 Add basic test coverage configuration
This handles:

* Sub-processes within unit tests (thanks pytest-cov)
* Our pytest-fixture-based virtual environments and subprocesses
  therein
* Running with xdist (e.g. `-n auto`)
* Combining results from all of the above using paths rooted with
  `src/pip/*`

This doesn't handle:

* Platform-specific branches
* Python 2
* CI integration
2020-07-07 21:58:55 -04:00
Devesh Kumar Singh 0dbd3938af Add B014 ignore 2020-06-10 00:36:03 +05:30
Devesh Kumar Singh 06654ef329 Remove explicit select and ignore src/pip for flake8-bugbear for now 2020-06-05 23:10:01 +05:30
Devesh Kumar Singh 6716a2bec5 Add flake8-bugbear rules to setup.cfg 2020-06-05 02:40:49 +05:30
Paul Moore 8346c44f1c Register the new marker 2020-05-21 15:58:43 +01:00
cjc7373 ac5702c9b3 move marker registering to setup.cfg 2020-05-21 11:57:46 +08:00
Maxim Kurnikov d1452ffabd add global disallow_any_generics=True 2019-11-12 21:08:48 +03:00
Maxim Kurnikov 3692097cca add per-file disallow_untyped_defs=False, and set it to True globally 2019-09-29 23:31:15 +02:00
Pradyun Gedam fe147309ea
Appropriately ignore the .nox folder 2019-09-05 12:40:24 +05:30
Pradyun Gedam 6e3eae5e2a
Ignore 'build' directory in linting tools 2019-08-27 14:06:17 +05:30
Pradyun Gedam f377148f6d
Use mypy's inline configuration syntax for opt-outs 2019-07-30 12:39:51 +05:30