FIX: got rid of type: ignore[unreachable] comments #221#394
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Saransh-cpp
left a comment
There was a problem hiding this comment.
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] Can you please help me with this? |
f6f3c75 to
82e6c8d
Compare
There was a problem hiding this comment.
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
TypeVarbounded toVectorProtocolfor use in class-to-name mapping. - Updated
_class_to_namesignature fromtype[VectorProtocol]totype[T]to improve mypy inference and avoid unreachable-type issues.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
$ pre-commit run --all-filesor$ nox -s lint)$ pytestor$ nox -s tests)$ cd docs; make clean; make htmlor$ nox -s docs)$ xdoctest ./src/vectoror$ nox -s doctests)Before Merging