Nishad K
Nishad K

Reputation: 49

When I run the Python code in Visual Studio Code Editor below, I get

def post(self, request, *args, **kwargs):
        post_data = request.data
        task_id = post_data.get("task_id")
        head = post_data.get("comment_head")
        value = post_data.get("comment_description")
        code = post_data.get("code")
        task = entity_Task(task_id=task_id)
        if task and head and value:
            try:
                if code and code == DELAY_FLAG_CODE:
                    entity_Comment.add_comment_flag_delay(
                        user=user, task_id=task_id, value=collection_feedback)
                else:
                    comment = entity_Comment.add_comment_with_task_id(
                        user=request.user, task_id=task_id, head=head, value=value)
                return JSONResponse({'code': 200, 'response': {"status": "Comment Saved"}})
            except Exception as e:
                xprint(e, traceback.format_exc())
                return JSONResponse({'code': 500, 'response': {"error": str(e)}});
        return JSONResponse({'code':200,'response':'Data Insufficient'})

after running this code in vscode editor I get below error

IndentationError: unindent does not match any outer indentation level.

Upvotes: -1

Views: 48

Answers (1)

Oliver.R
Oliver.R

Reputation: 1368

Easiest way to hunt out something like this would be to use a formatter (like black) to ensure consistent formatting in your code. From inside VSCode, you can just use ctrl+shift+F to format the current file - this may be enough for your current task.

Otherwise, check the exact line from the traceback and ensure your indentation is correct / matches the rest of your file / function..

Upvotes: 0

Related Questions