-
-
Notifications
You must be signed in to change notification settings - Fork 738
Fixed mypy sp check guidelines #4887
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
ad17bc6
ba437d6
77863b8
5413828
f7beff0
fba51e2
fef8148
f5f6d50
e1b1aec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -252,6 +252,10 @@ concurrency = ["multiprocessing"] | |
| ignore_missing_imports = true | ||
| allow_redefinition = true | ||
| disable_error_code = ["call-overload", "operator"] | ||
| strict = false | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given how big this PR is, it would actually be better to split it into multiple PRs, each one adding a new config option in pyproject.toml.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok so should I go ahead then and make a PR on one of the config first? or edit this one accordingly?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can keep this PR for one config, and add other configs in subsequent PRs.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok I'll create seperate PRs for different configs and then keep this one for the end, I think that would be faster for me
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed many of the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think anything that reduces the diff and keeps this PR scoped to a specific change (or a few of them) would be great. Thanks for investigating!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've created the PR with just |
||
| warn_unreachable = true | ||
| enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] | ||
| exclude = 'build/' | ||
|
|
||
| [[tool.mypy.overrides]] | ||
| module = [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
| # Binary operator classes | ||
| # | ||
| from __future__ import annotations | ||
| import numbers | ||
|
|
||
| import numpy as np | ||
| import sympy | ||
|
|
@@ -33,8 +32,8 @@ def _preprocess_binary( | |
| raise ValueError("right must be a 1D array") | ||
| right = pybamm.Vector(right) | ||
|
|
||
| # Check both left and right are pybamm Symbols | ||
| if not (isinstance(left, pybamm.Symbol) and isinstance(right, pybamm.Symbol)): | ||
| # Check right is pybamm Symbol | ||
| if not isinstance(right, pybamm.Symbol): | ||
|
||
| raise NotImplementedError( | ||
| f"BinaryOperator not implemented for symbols of type {type(left)} and {type(right)}" | ||
| ) | ||
|
|
@@ -127,7 +126,7 @@ def create_copy( | |
| children = self._children_for_copying(new_children) | ||
|
|
||
| if not perform_simplifications: | ||
| out = self.__class__(children[0], children[1]) | ||
| out = self.__class__(*children) | ||
| else: | ||
| # creates a new instance using the overloaded binary operator to perform | ||
| # additional simplifications, rather than just calling the constructor | ||
|
|
@@ -1538,7 +1537,7 @@ def source( | |
| corresponding to a source term in the bulk. | ||
| """ | ||
| # Broadcast if left is number | ||
| if isinstance(left, numbers.Number): | ||
| if isinstance(left, (int, float)): | ||
| left = pybamm.PrimaryBroadcast(left, "current collector") | ||
|
|
||
| # force type cast for mypy | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.