vector icon indicating copy to clipboard operation
vector copied to clipboard

Get rid of mypy's `# type: ignore[unreachable]` comments

Open Saransh-cpp opened this issue 2 years ago • 2 comments

Right now mypy throws a bunch of errors in this particular code block -

https://github.com/scikit-hep/vector/blob/02d4655bf4c27578ca96c082501b517710570e57/src/vector/backends/awkward.py#L575-L582

saying -

error: Subclass of "VectorProtocol", "Momentum", and "Vector2D" cannot exist: would have inconsistent method resolution order  [unreachable]

These errors have been suppressed using the type: ignore[unreachable] comments, but this should be fixed. The type: ignore[unreachable] comments should be removed from Vector (these are the only type: ignore[unreachable] comments left in the codebase).


Guessing it is not understanding that Type[VectorProtocol] can (sometimes) pass a subclass of Momentum check? Might be worth updating that. But not in this PR, these are (all) fine for now.

Originally posted by @henryiii in https://github.com/scikit-hep/vector/pull/219#discussion_r911539892

Saransh-cpp avatar Jul 04 '22 15:07 Saransh-cpp

https://github.com/scikit-hep/vector/pull/89 removes warn_unreachable = true for now.

Saransh-cpp avatar Oct 18 '22 08:10 Saransh-cpp

I guess the issue here is that Momentum is a subclass of VectorProtocol, while Vector2D, Vector3D etc. are also subclasses.

Saswatsusmoy avatar Oct 17 '23 21:10 Saswatsusmoy