-
Notifications
You must be signed in to change notification settings - Fork 876
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
Enable more ruff rules including A
, DTZ
, PGH
and more
#3871
Conversation
…tgen into pgh-ruff-rules
@DanielYang59 could you trigger the atomate2 tests? |
@JaGeo Thanks for commenting. Can you let me how to achieve that? It should only be possible when pushing to pymatgen/.github/workflows/test.yml Line 94 in 624e6eb
This PR is still a type annotation improvement, and I don't expect much code functionality change :) |
@DanielYang59 ah okay. Then, we will see after merging! Thanks! |
tests/analysis/chemenv/coordination_environments/test_structure_environments.py
Outdated
Show resolved
Hide resolved
@janosh I replaced some already multi-lined dictionary constructor From my side, the speed up is something I really want to have (2x - 4x, though being in the nanosecond level) :) |
@shyuep Can I have your approval on the following potentially breaking change/fix (change some
|
If the errors are not the type that are meant to be caught, it is fine to change the error type. What I mean is that if the error is something that happens because of a bad use of code. Rather than something like catching an expected exception case and then handling it in some way. |
Thanks for your reply! Yes I could confirm those are exceptions we Mostly in the following pattern: if not isinstance(variable, expected_type):
- raise ValueError("variable should be in {expected_type}")
+ raise TypeError("variable should be in {expected_type}") Still it could be breaking if any downstream operation replies on catching a |
Thanks I have merged them,. |
Thanks! |
Summary
ruff
rulesio.lobster.inputs
in Simplify case handling inlobster.inputs
#3848 (comment)Enable more
ruff
rulesThe following requires code change:
PGH
for stricter typingA
to avoid shadowing of builtinsCaution
b1aa5bb and 50e9b7d changed multiple
ValueError
to more semanticTypeError
to fixTRY004
. this is breaking. however, downstream repercussions are expected to be small.pinging @mkhorton @shyuep for approval
Future PR
datetime.datetime.utcnow()
deprecated and replacement breaksstrptime
#3791S
andNPY
Other format tweaks
match.group(x)
withmatch[x]
array[0:x]
slicing witharray[:x]
dict()
constructor with{}
for speed (almost 2x-4x speedup).