Open ngnpope opened 1 year ago
CFQ003 would be truly awesome to have
Sounds like "challenge accepted"? 😂
The features of Mr. Proper should be useable attributes to discover violations:
- that function has no blacklisted calls (like print) and blacklisted attributes access (like smth.count);
- that function not uses global objects (only local vars and function arguments);
- that function has al least one return;
- that function not mutates it's arguments;
- that function has no local imports;
- that function has no arguments of forbidden types (like ORM objects);
- that function not uses self, class or super;
- that function has calls of only pure functions.
Mostly this requires no type checking!
You mind if I implement too-many-return-statements
?
Go ahead! 🙂
Why CFQ001 and CFQ004 is done? PLR0915/PLR0911 is not equal rule for CFQ001/CFQ004!
I've unticked CFQ001
-- you're right, that does seem distinct from PLR0915
to me. CFQ004
does look basically the same as PLR0911
to me, though -- would you mind explaining to me how they are different, @mirecl?
(N.B. Just because I've "unticked" the rule doesn't necessarily mean that we'll accept a PR. CFQ001
is a very opinionated rule, so we probably wouldn't accept this rule until https://github.com/astral-sh/ruff/issues/1774 is completed and we have a better way of marking rules as disabled by default.)
GitHub, PyPI.
CFQ001
: Function ... has length {function_length} that exceeds max allowed length {max_function_length}too-many-statements
(PLR0915
) frompylint
, this counts the literal number of lines that the function takes up on the page, rather than the number of statements in the function.CFQ002
: Function ... has {arguments_amount} arguments that exceeds max allowed {max_parameters_amount}too-many-arguments
(PLR0913
) frompylint
CFQ003
: Function ... is not puremr-proper
under the hood to check that a function is "pure"CFQ004
: Function ... has {returns_amount} returns that exceeds max allowed {max_returns_amount}too-many-return-statements
(PLR0911
) frompylint
Configuration options:
max-function-length
implemented aspylint:max-statements
max-parameters-amount
implemented aspylint:max-args
max-returns-amount
to be implemented aspylint:max-returns
Other than
CFQ003
which is dubious, these will all be covered bypylint
rules... So this can be closed if desired, but this will be useful to refer to when aliases are implemented.