Skip to content

FIX: got rid of type: ignore[unreachable] comments #221#394

Open
Saswatsusmoy wants to merge 1 commit into
scikit-hep:mainfrom
Saswatsusmoy:Saswatsusmoy-#221-Get-rid-of-mypy's-#-type-ignoreunreachable]-comments
Open

FIX: got rid of type: ignore[unreachable] comments #221#394
Saswatsusmoy wants to merge 1 commit into
scikit-hep:mainfrom
Saswatsusmoy:Saswatsusmoy-#221-Get-rid-of-mypy's-#-type-ignoreunreachable]-comments

Conversation

@Saswatsusmoy

@Saswatsusmoy Saswatsusmoy commented Oct 17, 2023

Copy link
Copy Markdown

Description

Fixes #221
To fix this, we can use a TypeVar to bound the input cls to VectorProtocol. This avoids the inconsistent inheritance issue.
We also don't need the unreachable ignores anymore since the code now typechecks correctly.

Checklist

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't any other open Pull Requests for the required change?
  • Does your submission pass pre-commit? ($ pre-commit run --all-files or $ nox -s lint)
  • Does your submission pass tests? ($ pytest or $ nox -s tests)
  • Does the documentation build with your changes? ($ cd docs; make clean; make html or $ nox -s docs)
  • Does your submission pass the doctests? ($ xdoctest ./src/vector or $ nox -s doctests)

Before Merging

  • Summarize the commit messages into a brief review of the Pull request.

@codecov-commenter

codecov-commenter commented Oct 17, 2023

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.72%. Comparing base (0c94443) to head (82e6c8d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #394   +/-   ##
=======================================
  Coverage   87.72%   87.72%           
=======================================
  Files          96       96           
  Lines       11193    11195    +2     
=======================================
+ Hits         9819     9821    +2     
  Misses       1374     1374           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Saransh-cpp Saransh-cpp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this up, @Saswatsusmoy! Could you please add warn_unreachable = true under the [tool.mypy] section in pyproject.toml to check if this works?

@Saswatsusmoy

Copy link
Copy Markdown
Author

Thanks for taking this up, @Saswatsusmoy! Could you please add warn_unreachable = true under the [tool.mypy] section in pyproject.toml to check if this works?

No, it isn't working 16 errors have popped up

src\vector_methods.py:3949: error: Statement is unreachable [unreachable]
src\vector_methods.py:4161: error: Statement is unreachable [unreachable]
src\vector\backends\object.py:430: error: Statement is unreachable [unreachable]
src\vector\backends\object.py:527: error: Statement is unreachable [unreachable]
src\vector\backends\object.py:539: error: Statement is unreachable [unreachable]
src\vector\backends\object.py:551: error: Statement is unreachable [unreachable]
src\vector\backends\numpy.py:86: error: Statement is unreachable [unreachable]
src\vector\backends\numpy.py:88: error: Statement is unreachable [unreachable]
src\vector\backends\numpy.py:91: error: Statement is unreachable [unreachable]
src\vector\backends\numpy.py:105: error: Statement is unreachable [unreachable]
src\vector\backends\numpy.py:108: error: Statement is unreachable [unreachable]
src\vector\backends\numpy.py:817: error: Statement is unreachable [unreachable]
src\vector\backends\numpy.py:928: error: Statement is unreachable [unreachable]
src\vector\backends\numpy.py:940: error: Statement is unreachable [unreachable]
src\vector\backends\numpy.py:952: error: Statement is unreachable [unreachable]
src\vector\backends\awkward.py:584: error: Statement is unreachable [unreachable]
Found 16 errors in 4 files (checked 98 source files)

Can you please help me with this?

@henryiii henryiii force-pushed the Saswatsusmoy-#221-Get-rid-of-mypy's-#-type-ignoreunreachable]-comments branch from f6f3c75 to 82e6c8d Compare June 17, 2026 21:02
Copilot AI review requested due to automatic review settings June 17, 2026 21:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses mypy’s previous “inconsistent method resolution order” unreachable typing errors by refining the typing of _class_to_name to accept a TypeVar bounded to VectorProtocol, enabling removal of # type: ignore[unreachable] suppressions and allowing the code to typecheck cleanly (per #221).

Changes:

  • Introduced a TypeVar bounded to VectorProtocol for use in class-to-name mapping.
  • Updated _class_to_name signature from type[VectorProtocol] to type[T] to improve mypy inference and avoid unreachable-type issues.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants