From the course: Accelerate DevOps and Software Development with AI: Modern Tools and Workflows for Enhanced Software Delivery

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Coding project: Refactor Python code with AI

Coding project: Refactor Python code with AI

- Now, let's see how AI helps with refactoring. Refactoring is about cleaning code without changing behavior. I'll highlight the sorting function in the list books method and use a prompt that says to refactor list books. So the sorting functionality is moved into a helper function. Keep behavior identical. Okay, so I like that it's broken. It steps down into a checklist, and the last step is actually the most important step because that's where we're going to verify if the behavior remains the same after refactoring. So it has a suggestion, I'm going to accept it. Okay, now it's saying we can run the test_book_service file. So we'll try that. Okay. It's running into some issues. It's going to try running it this time with Python 3. Okay. It can't find a module. Okay. It's saying that there's some issues with the Python version compatibility. So it's going to check what version of Python we're running right now.…

Contents