-
Notifications
You must be signed in to change notification settings - Fork 868
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
Re-enable some useful ruff
rules
#3813
Conversation
Note Reviews PausedUse the following commands to manage reviews:
WalkthroughThe recent updates across various files in the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@coderabbitai ignore |
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.
Actionable comments posted: 0
Out of diff range and nitpick comments (5)
pymatgen/io/vasp/inputs.py (5)
Line range hint
1747-1765
: Ensure consistent use ofClassVar
for class-level constants.- functional_dir: ClassVar = { + functional_dir: ClassVar[dict[str, str]] = {
Line range hint
1766-1780
: Ensure consistent use ofClassVar
for class-level constants.- functional_tags: ClassVar = { + functional_tags: ClassVar[dict[str, dict[str, str]]] = {
Line range hint
1780-1804
: Ensure consistent use ofClassVar
for class-level constants.- parse_functions: ClassVar = { + parse_functions: ClassVar[dict[str, Callable[[str], Any]]] = {
Line range hint
1804-1823
: Consider adding type hints to the constructor parameters for clarity.- def __init__(self, data: str, symbol: str | None = None) -> None: + def __init__(self, data: str, symbol: Optional[str] = None) -> None:
Line range hint
1823-1842
: Consider adding type hints to the constructor parameters for clarity.- def __init__(self, incar: dict | Incar, kpoints: Kpoints | None, poscar: Poscar, potcar: Potcar | None, optional_files: dict[PathLike, object] | None = None, **kwargs) -> None: + def __init__(self, incar: Union[dict, Incar], kpoints: Optional[Kpoints], poscar: Poscar, potcar: Optional[Potcar], optional_files: Optional[dict[PathLike, object]] = None, **kwargs) -> None:
@coderabbitai ignore Actions PerformedReviews paused. |
ruff
stricter by enabling some rulesruff
rules
ruff
rulesruff
rules
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 actually often prefer the dict(foo=bar)
version over {"foo": bar}
since it's more compact due to not needing so many quotes. this sometimes avoids a line break which imo helps readability. i'd vote to keep C408 in the ignore list
And it seems
|
It should be ready for review now @janosh. Thanks. Let me know if want to enable any more/less I tried to enable: Line 72 in 46b018d
But it seems to force all kind of list builder into list comprehensions (especially some nested conditions list), which would greatly reduce readability. |
that inverts once you have 2 or more keys in your dict. at that point the collection call is shorter |
That's true. But if you look into the commit 38a5aa7, it appears among all changes, this case you mentioned (where a line is broken by extra characters) only happened once for: pymatgen/pymatgen/io/vasp/sets.py Line 2219 in 46b018d
And all other changes didn't introduce any additional line. But anyway, feel free to revert that commit if you really prefer not to change that (it's all automatically changed by |
This reverts commit 38a5aa7.
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 @DanielYang59, lgtm! 👍
Beautiful. Thanks for reviewing @janosh Appreciate it. |
"D105", # Missing docstring in magic method | ||
"D205", # 1 blank line required between summary line and description | ||
"D212", # Multi-line docstring summary should start at the first line | ||
"ISC001", | ||
"NPY002", # replace legacy numpy.random with numpy.random.Generator | ||
"PD901", # pandas-df-variable-name | ||
"PERF203", # try-except-in-loop | ||
"PERF401", # manual-list-comprehension (TODO fix these or wait for autofix) |
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 forgot to remove this TODO
tag for PERF401
, would do it in another PR.
I'm pretty sure we don't really want to enable this rule:
it seems to force all kind of list builder into list comprehensions (especially some nested conditions list), which would greatly reduce readability.
I just look into this speed comparison between |
Re-enable some useful
ruff
rulesCOM812
: missing-trailing-comma: no change to code baseISC001
: single-line-implicit-string-concatenation: might conflict with otherruff
rules sometimesRUF012
: mutable-class-defaultPLC1901
: compare-to-empty-string: no change to code basePYI024
collections-named-tuple: make typing ofnamedtuple
possibleREVERTED
C408
: unnecessary-collection-call (confirmed no comment is dropped)