A tool for large language model-enabled code review.
Project description
Backseat Driver
Software developers want reviews from colleagues so that they can improve the code they write. But often, a developer's peers are too busy or lack the context to provide comments. Backseat Driver prompts a large language model to give a code base a letter grade for readability, expressiveness, and organization. It also instructs the model to explain its reasoning. Developers gain the benefits of a code review without needing another engineer.
Backseat Driver is not a linting tool. Linters check code compliance with a language-specific style guide. While linters are extremely valuable for promoting readability and standardizing practices within a team, they don't examine a code base for key elements that make code relatable to another human being. For example, linters don't comment on whether function or variable names express the intent of the author. They only ensure that names use the correct combination of lower case, upper case, and other characters. Linters also do not discuss whether functions or classes have intuitive interfaces. Backseat Driver goes beyond linting, looking for deeper ways to improve code.
Installation
TODO pip install
Usage
TODO users need to specify an OpenAI API key
Local
TODO
GitHub Actions
TODO
# TODO not sure what source-directory should be in GitHub Actions
backseat-driver:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
fail_under: B
source_directory: /
filter_files_by_suffix: ".py"
Example output
You can try Backseat Driver on the input program below to see how it works. Copy the code below into a file and run Backseat Driver with the following.
TODO show python command to reproduce this output
"""A file for testing prompt creation."""
def fib(n):
"""Returns the nth fibonacci number."""
if n <= 2:
return 1
return fib(n - 1) + fib(n - 2)
def fact(n):
"""Returns n factorial."""
if n <= 1:
return 1
return n * fact(n - 1)
def hailstone(n):
"""Returns the hailstone sequence starting with positive integer n."""
if n <= 0:
raise ValueError(f"Cannot compute hailstone of negative number {n}")
if n == 1:
return [n]
if n % 2 == 0:
return [n] + hailstone(n // 2)
return [n] + hailstone(3 * n + 1)
What Backseat Driver says:
Grade: A
This code is well-written, easy to read, and well-organized. The function names are clear and descriptive, and the docstrings provide useful information about the functions' purpose and behavior. The code also follows the recommended Python style guidelines (PEP 8), including appropriate indentation, whitespace, and naming conventions. Overall, there are no major issues with the code, and it is highly readable and maintainable.
One possible improvement could be to add some error handling to the
fib()
andfact()
functions, for cases where the input is not a positive integer. Another potential improvement could be to add some more comments to explain the logic behind thehailstone()
function. However, these are minor suggestions and are not necessary for the code to function correctly.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file backseat-driver-0.0.1.tar.gz
.
File metadata
- Download URL: backseat-driver-0.0.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c65c15c1aa6eea81c20d329ca56827ebf75caa79a346367f9e42105f52311f71 |
|
MD5 | 155f4ce23836d7b23f73536c52529115 |
|
BLAKE2b-256 | 6e164ab1db714ad6997aa9834149b706d06596d3773e9d9c532bd907cc1cf346 |
File details
Details for the file backseat_driver-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: backseat_driver-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dc2e011cfa47735ed9ac7a7875eb64097218837b1aba0d6b248482196305d71 |
|
MD5 | 4e1c0fef291910693209769100f3821e |
|
BLAKE2b-256 | a7204d6340a9066eeb811db23fa81585ea6b66210742a7ba9fc42c6be72e8229 |