Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Letting Gemini Fix the Bug

00:00 After Gemini explained what the bug in the application is, let’s use Gemini to apply the fixes, and to do so, let me point you to this little placeholder message in the prompt that you might have spotted already: Type your message or @path/to/file.

00:16 So we actually haven’t used this @path/to/file yet, so now is a good moment to do so. In the summary, where Gemini CLI pointed out where the issue is, it’s referenced src/todolist/exporter.py.

00:32 So when we say to Gemini to apply those fixes, it’s a good idea to point Gemini to this file directly and not let Gemini run through the whole codebase in order to find it.

00:45 So that’s a way to save some tokens and be very specific by saying, “Can you apply this fix to the”, and then use the @ symbol. And once you have typed the @, then you will see a big list of all the files in your folder.

01:04 Now since we have a virtual environment with .venv, it’s a bit annoying to traverse with the up and down arrows, although you can, but you can filter a bit more because we are looking for something that contains “export” in the name, and actually the filename is exporter.py.

01:24 Once you type @export, you will see that Gemini already suggests a file which is src/ todolist/exporter.py. And once you hit Tab, you take over this file into the prompt, and then you can press Enter to run the prompt.

01:40 And that way, you tell Gemini to apply those fixes exactly to this file.

01:46 The changes look slightly different than the one suggested. So in line 29, it’s putting a conditional statement into one line, except multiple lines as suggested above.

01:57 But overall it looks fine. I think in line 26, the optional argument None could be a bit simplified by just saying format_options=None.

02:08 But this way it’s also fine. So yes, let’s go ahead and allow Gemini to do those fixes.

02:18 And since you are still in the same thread as before, Gemini remembers that it actually found this issue by running ruff check --select ALL.

02:28 So now after implementing this change, Gemini is asking you, Hey, I can now run it again to see if it’s fixed. That is generally a good idea, but I don’t want to do it right now.

02:39 So I say no and suggest changes because I want to show you the clear slash command. So with /clear, you can actually reset a conversation and start fresh.

02:51 And that’s a good idea now, because we analyzed the codebase, we let Gemini introduce this change. So now any prompt that I will use after that, I want to use with a fresh context and not convoluted with all the changes we did so far.

03:06 So after we press /clear, it’s basically as if we were starting Gemini fresh, except that we don’t have to quit it and open it again, but we’re staying here, and now we can go on with whatever we want to do.

Become a Member to join the conversation.