Return if the AST ``statement`` is a call to the setup() function.
(statement)
| 2388 | |
| 2389 | |
| 2390 | def is_setup_call(statement): |
| 2391 | """ |
| 2392 | Return if the AST ``statement`` is a call to the setup() function. |
| 2393 | """ |
| 2394 | return ( |
| 2395 | isinstance(statement, (ast.Expr, ast.Call, ast.Assign)) |
| 2396 | and isinstance(statement.value, ast.Call) |
| 2397 | and ( |
| 2398 | # we look for setup and main as this is used sometimes instead of setup() |
| 2399 | ( |
| 2400 | isinstance(statement.value.func, ast.Name) |
| 2401 | and statement.value.func.id in ('setup', 'main') |
| 2402 | ) |
| 2403 | or |
| 2404 | # we also look for setuptools.setup when used instead of setup() |
| 2405 | ( |
| 2406 | isinstance(statement.value.func, ast.Attribute) |
| 2407 | and statement.value.func.attr == 'setup' |
| 2408 | and isinstance(statement.value.func.value, ast.Name) |
| 2409 | and statement.value.func.value.id == 'setuptools' |
| 2410 | ) |
| 2411 | ) |
| 2412 | ) |
| 2413 | |
| 2414 | |
| 2415 | def get_setup_py_args_legacy(location, include_not_parsable=False): |
no outgoing calls
no test coverage detected