Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Saransh-cpp opened this issue Jul 4, 2022 · 2 comments · May be fixed by #394
Open

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

Saransh-cpp opened this issue Jul 4, 2022 · 2 comments · May be fixed by #394
Labels
hacktoberfest help wanted Extra attention is needed

Comments

@Saransh-cpp
Copy link
Collaborator

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

def _class_to_name(cls: typing.Type[VectorProtocol]) -> str:
if issubclass(cls, Momentum):
if issubclass(cls, Vector2D): # type: ignore[unreachable]
return "Momentum2D" # type: ignore[unreachable]
elif issubclass(cls, Vector3D): # type: ignore[unreachable]
return "Momentum3D" # type: ignore[unreachable]
elif issubclass(cls, Vector4D): # type: ignore[unreachable]
return "Momentum4D" # type: ignore[unreachable]

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 #219 (comment)

@Saransh-cpp Saransh-cpp added the help wanted Extra attention is needed label Aug 17, 2022
@Saransh-cpp
Copy link
Collaborator Author

#89 removes warn_unreachable = true for now.

@Saswatsusmoy
Copy link

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

@Saswatsusmoy Saswatsusmoy linked a pull request Oct 17, 2023 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest help wanted Extra attention is needed
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants