You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is similar to the closed #7660. As noted in that issue, Pylint lets you *define your own regex for acceptable variable and constant names (enforcing snake_case for example, or variable length,or both):
variable-rgx=[a-z_][a-z0-9_]{2,40}$
While C0103 in pylint is checked off in #970, one can not define explicit regex for what constitutes an acceptable naming convention. #7660 was closed with updated documentation on ignore-names globbing, but I don't think that is similar functionality to pylint that I'm requesting. I would like parity with pylint to allow regex for variable and constant names, so users can enforce snake_case or pascalcase, etc. and then mismatches with that regex triggering invalid-name, like pylint does now. Thanks!
The text was updated successfully, but these errors were encountered:
Is the main goal to enforce snake, pascal, or another predefined casing standard? Iˋm asking because Ruff canˋt offer autofixes when we allow a custom regex (and error message would probably also be somewhat cryptic).
Another reason for not allowing a regex is that ruff has other rules to enforce a certain variable lenght and we want to avoid overlapping rules
Is the main goal to enforce snake, pascal, or another predefined casing standard? Iˋm asking because Ruff canˋt offer autofixes when we allow a custom regex (and error message would probably also be somewhat cryptic).
Another reason for not allowing a regex is that ruff has other rules to enforce a certain variable lenght and we want to avoid overlapping rules
My particular use case is pretty much in the regex above; with it pylint flags non-compliant variable names: anything that isn't snake case or outside the min/max variable length.
Obviously autofix is super useful but I think it's fine to have some rules that can't be autofixed. For this example, Pylint would say something like invalid-name, doesn't match pattern [a-z_][a-z0-9_]{2,40}
Thanks for explaining. That makes sense. I suspect that the fact that the rule overlaps with other existing and proposed rules will make it challenging to have this rule accepted. I'll keep this open as an alternative to consider when deciding whether Ruff should have more variable-length restricting rules.
Yeah sorry. I should have linked to those. There was a PR for too-short-name that I closed. The rule overlaps with what you suggest and we may want to support the rule once #1774 is complete.
This is similar to the closed #7660. As noted in that issue, Pylint lets you *define your own regex for acceptable variable and constant names (enforcing snake_case for example, or variable length,or both):
While
C0103
in pylint is checked off in #970, one can not define explicit regex for what constitutes an acceptable naming convention. #7660 was closed with updated documentation on ignore-names globbing, but I don't think that is similar functionality to pylint that I'm requesting. I would like parity with pylint to allow regex for variable and constant names, so users can enforce snake_case or pascalcase, etc. and then mismatches with that regex triggeringinvalid-name
, like pylint does now. Thanks!The text was updated successfully, but these errors were encountered: