Open ikreb7 opened 2 years ago
You should probably try to pinpoint this error to a specific file/expression, for example by digging into the verbose output of flake8 or by running the checker on each file itself. This usually makes it much easier to fix the actual issue.
Hi, I've researched this issue. It seems that this happens when this function
def find_function(self, func_name: str) -> ASTCallable: # type: ignore[return]
for child in ast.walk(self.parent):
if (
isinstance(child, (ast.AsyncFunctionDef, ast.FunctionDef))
and child.name == func_name
):
return child
is not able to find the proper return value and returns None instead. This happens in a few scenarios.
from fastapi import FastAPI, HTTPException
app = FastAPI()
class MyClass:
...
@app.get("/") def home(): my_object = MyClass() my_object.raise_here()
And probably in some other cases.
"Quickfix" for this would be to annotate the return value of `find_function` as `Optional[ASTCallable]` and add a check if the body is not None before running `self.find_exceptions_in_body` on it.
Unfortunately, this plugin would lose the ability to detect `UndocumentedHTTPException` on functions/methods that are defined outside of the tested module.
Any progress? I am facing the same problem:(
Hello Marcelo,
sadly, I get this error message:
This is my system:
If you need any further information, let me know.