Skip to content

Why does too-many-statements consider statements in nested functions? #10262

Open
@schiele

Description

@schiele

Question

If I write a lengthy function, the too-many-statements checker rightfully complains about that. The obvious solution is to factor out code into separate functions. If those functions are not useful outside this function, I nest them into the function calling them. If I do that, the checker still considers those statements for complaining about the outer function. Is this a bug in the checker implementation or is there a good reason the checker discourages form using nested functions?

Documentation for future user

Documentation should elaborate on what it includes in the calculation on the documentation page https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/too-many-statements.html.
For not obvious cases, like nested code, it should also provide rationale about the decision.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions