scikit-hep / vector

Vector classes and utilities
https://vector.readthedocs.io
BSD 3-Clause "New" or "Revised" License
81 stars 27 forks source link

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

Open Saransh-cpp opened 2 years ago

Saransh-cpp commented 2 years ago

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 commented 2 years ago

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

Saswatsusmoy commented 1 year ago

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