-
-
Notifications
You must be signed in to change notification settings - Fork 529
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
Fix switch to ruff format #3492
Fix switch to ruff format #3492
Conversation
Hey @Saransh-cpp so till then if someone solve this with you then fine otherwise i will come back on 9th still you can review it give me the comments what changes you want if i am quickly able to change those thing then i will otherwise i wll come on 9th nov . |
And one more thing do you want it to auto fix everything or just check? |
Sounds good! We should autofix everything. |
Now pre-commit bot will auto commit everything which can be change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @Rjchauhan18! You should also add pre-commit's commit's hash in https://github.com/pybamm-team/PyBaMM/blob/develop/.git-blame-ignore-revs
|
||
- id: ruff-format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- id: ruff-format | |
- id: ruff-format | |
types_or: [python, pyi, jupyter] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.3"
hooks:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format
types_or: [python, pyi, jupyter]
It is removing ;
from .ipynb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a lot of the semi-colons just stop output like:
<pybamm.solvers.solution.Solution at 0x13cc02f10>
This does not seem like a huge problem.
Another way to resolve that printing is to save output objects to a discarded variable:
_ = sim.solve()
instead of
sim.solve();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, _ = sim.solve()
this is in the jupyter notebook
But for plotting graphs without line like this [<matplotlib.lines.Line2D at 0x7f4123ea7ac0>]
we need semi-colons.
One Solution is to put # fmt: off
and # fmt: on
where semi-colons appear
# fmt: off
plt.plot(sol["Time [s]"].data, sol["Voltage [V]"].data);
# fmt: on
Should I use these comments or try to find something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I would prefer to avoid adding tool specific comments if there are other ways.
In this case:
_ = plt.plot(sol["Time [s]"].data, sol["Voltage [V]"].data)
works since plot() also has a return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Saransh-cpp
which changes you prefer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The semicolon thing was fixed in ruff upstream. You might have to reset your commits and introduce ruff format in an entirely new commit, given that we want all the pre-commit related changes bundled in a single commit.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3492 +/- ##
========================================
Coverage 99.58% 99.58%
========================================
Files 256 256
Lines 20048 20048
========================================
Hits 19965 19965
Misses 83 83
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rjchauhan18 let us know if you need any help on this!
Closing this PR as it went stale, and taking up the work in #3656 |
Description
Fixes # (issue)
This PR will fixes the issue #3477
Type of change
Further checks: