Fixed mypy sp check guidelines
Description
Fixing mypy sp check guidelines
Some major changes I did:
-
In
src/pybamm/expression_tree/binary_operators.pyI've replacedself.__ class __in line 131 with new_instance because earlier when we were usingself.__ class __it showed a third arg was not getting passed:error: Missing positional argument "right_child" in call to "BinaryOperator" [call-arg]but this function was always getting called from instance of its child classes which don't need to pass 3 arguments, so i thought it was better to make a new_instance method which can be overrided in child classes
-
In
src/pybamm/expression_tree/broadcasts.pyI've forced child classes ofBroadcastto implement_unary_new_copybecause earlier we were usingself.broadcast_domainin this function in Broadcast class but it does not have any attributeself.broadcast_domain, this function was only getting called by instance of their child classes which has self.broadcast_domain property. -
In
tests/unit/test_expression_tree/test_operations/test_copy.pyintest_symbol_create_copy_new_childrentest I've added an extra argumentperform_simplifications=Falsetocreate_copymethod to ensure 100% coverage of new_instance methods.
Related to #3489
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #)
Important checks:
Please confirm the following before marking the PR as ready for review:
- [x] No style issues:
nox -s pre-commit - [x] All tests pass:
nox -s tests - [x] The documentation builds:
nox -s doctests - [x] Code is commented for hard-to-understand areas
- [ ] Tests added that prove fix is effective or that feature works
Still 25 mypy errors are left, drafting this so that its easier to communicate changes
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 98.70%. Comparing base (
8f91615) to head (e1b1aec). Report is 1 commits behind head on develop.
Additional details and impacted files
@@ Coverage Diff @@
## develop #4887 +/- ##
===========================================
- Coverage 98.71% 98.70% -0.01%
===========================================
Files 304 304
Lines 23509 23542 +33
===========================================
+ Hits 23207 23238 +31
- Misses 302 304 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: 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.
It would be great to have repo-review as a pre-commit hook! @agriyakhetarpal maybe you can create a new independent issue for that?
I've changed the PR description to related to and I also think it would be great to have a pre-commit hook for sp-check-guidelines, I'll investigate its speed after this PR is done
I've fixed the remaining errors too
@agriyakhetarpal Thanks for the review, I've left comments for the major changes, should I write these major changes in PR description too?
@agriyakhetarpal Thanks for the review, I've left comments for the major changes, should I write these major changes in PR description too?
Yes, please do!
@agriyakhetarpal I've updated the PR description, can you please review it?