PyCQA/flake8

SIM113 recommendation does not make sense?

JohannesBuchner opened this issue · 1 comments

how did you install flake8?

$ pip install flake8

unmodified output of flake8 --bug-report

{
"platform": {
"python_implementation": "CPython",
"python_version": "3.12.3",
"system": "Linux"
},
"plugins": [
{
"plugin": "flake8-bugbear",
"version": "24.4.26"
},
{
"plugin": "flake8-isort",
"version": "6.1.1"
},
{
"plugin": "flake8_simplify",
"version": "0.21.0"
},
{
"plugin": "mccabe",
"version": "0.7.0"
},
{
"plugin": "pycodestyle",
"version": "2.11.1"
},
{
"plugin": "pydoclint",
"version": "0.5.9"
},
{
"plugin": "pyflakes",
"version": "3.2.0"
}
],
"version": "7.0.0"
}

describe the problem

what I expected to happen

I am getting "SIM113 Use enumerate for 'min_call_args')" for the code below, but there does not seem to be an obvious (at least to me) way to simplify that function with enumerate?

Or I am just missing how to do it.

sample code

import ast


def count_call_arguments(call):
    may_have_more = False
    min_call_args = 0
    for arg in call.args:
        if isinstance(arg, ast.Starred):
            # should not count *args
            may_have_more |= True
            continue
        min_call_args += 1
        del arg
    for arg in call.keywords:
        if arg.arg is None:  # **kwargs
            may_have_more |= True
        min_call_args += 1
    return min_call_args, may_have_more

commands ran

$ flake8 test.py

please read the template