Since 41a30089de, Candidate objects prepare their underlying
distribution eagerly on creation, so the error can be caught
deterministically to trigger backtracking.
This however has a negative side-effect. Since dist preparation involves
metadata validation, a remote distribution must be downloaded on
Candidate creation. This means that an sdist will be downloaded,
validated, and discarded (since its version is known to be incompatible)
during backtracking.
This commit moves version deduplication of candidates from indexes to
before the Candidate object is created, to avoid unneeded preparation.
Note that we still need another round of deduplication in FoundCandidates
to remove duplicated candidates when a distribution is already installed.
Follows the more conventional pattern of using None, instead of False,
when no value can be returned. This simplifies typing a bit by using
Optional instead of Union[bool, ...].
The method Subversion._get_svn_url_rev() will sometimes return None for
a remote URL. The calling code should handle this. If it is None, raise
a RemoteNotFoundError as prescribed by the parent class docstring.
Followup to 0b761a164c.
check_binary_allowed is only used to check
if a wheel needs to be built in 'pip install' mode.
It mixed format control and pep517 mode check.
We change it so it checks allowed formats only,
which leads to better readability of _should_build().
Previously, the Subversion subclass violated the parent's type signature
by returning an int, but it is now coerced to a str to match the
expected signature.
Unnecessary since dropping Python 2 support. In Python 3, `__ne__`
defaults to the opposite of of `__eq__`.
https://docs.python.org/3/reference/datamodel.html#object.__ne__
> For `__ne__()`, by default it delegates to `__eq__()` and inverts the
> result unless it is `NotImplemented`.
The object returned by NamedTemporaryFile delegates all functions calls
to the underlying file so can avoid the type override by relying on IO
methods.
The class was being used in a single place, passed to csv.reader().
However, per the docs, csv.reader() can handle a list of str objects.
https://docs.python.org/3/library/csv.html#csv.reader
> csvfile can be any object which supports the iterator protocol and
> returns a string each time its __next__() method is called — file
> objects and list objects are both suitable.