1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
pip/news/85F7E260-68FF-4C1E-A2CB-CF8634829D2D.trivial.rst
Shantanu a19ade74a5
Use strict optional checking in req_install.py (#11379)
* Use strict optional checking in req_install.py

Suggested by pradyunsg in #11374

Since half of the API of this class depends on self.req not being None,
it seems like we should just prevent users from passing None here.
However, I wasn't able to make that change.

Rather than sprinkle asserts everywhere, I added "checked" properties.
I find this less ad hoc and easier to adapt if e.g. we're able to make
self.req never None in the future.

There are now some code paths where we have asserts that we didn't
before. I relied on other type hints in pip's code base to be accurate.
If that is not the case and we actually relied on some function being
able to accept None when not typed as such, we may hit these asserts.
But hopefully tests would catch such a thing.

* news

* black

* inline asserts

* code review

* fix up merge issue

* fix specifier bug
2023-08-05 00:07:27 +01:00

0 lines
ReStructuredText