Module 6 of 13 · Getting Started with AI Development · Beginner

Pull Requests and Code Review

Duration: 8 min

Try it in Google Colab: Open in Colab

What is a Pull Request?

A Pull Request (PR) is a way to propose changes to a repository. It allows others to review your code before merging it into the main branch.

Creating a Pull Request on GitHub

First, push your branch to GitHub:

# Create a local branch
git checkout -b feature/add-validation

# Make changes
echo 'def validate_input(x):' >> model.py
echo '    return x is not None' >> model.py

# Commit changes
git add model.py
git commit -m 'Add input validation'

# Push to GitHub
git push origin feature/add-validation
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 250 bytes, done.
To github.com:username/my-ai-project.git
 * [new branch]      feature/add-validation -> feature/add-validation

Opening a Pull Request

On GitHub, you'll see a prompt to create a PR:

  1. Click "Compare & pull request"
  2. Add a title: "Add input validation"
  3. Add a description explaining your changes
  4. Click "Create pull request"

Code Review Process

Once your PR is created, team members can:

Example review comment:

This function looks good, but consider adding error handling for None values.

Responding to Review Comments

# Make the requested changes
echo 'def validate_input(x):' > model.py
echo '    if x is None:' >> model.py
echo '        raise ValueError("Input cannot be None")' >> model.py
echo '    return True' >> model.py

# Commit and push
git add model.py
git commit -m 'Add error handling for None values'
git push origin feature/add-validation

The PR automatically updates with your new commits!

Merging a Pull Request

Once approved, merge the PR:

  1. Click "Merge pull request" on GitHub
  2. Choose merge strategy (usually "Create a merge commit")
  3. Click "Confirm merge"
  4. Delete the branch (optional but recommended)

Best Practices for PRs

Practice Why
Small PRs Easier to review, faster feedback
Clear title Reviewers understand the change
Detailed description Context helps reviewers
Link issues Tracks what problem it solves
Request reviewers Gets feedback faster

💡 Tip: Keep PRs focused on one feature. If you're adding validation AND preprocessing, make two separate PRs.

❓ What is the main purpose of a Pull Request?

← Previous Continue interactively → Next →

Related Courses