Your code review copilot

Python and Django changes suggested right inside your pull request. Fix bugs with no context switching.

code-review-doctorbotsuggested changes just now
validation.py
1
+
values = (
2
+
    'yes',
3
+
    'correct'
Suggested changes
-
    'correct'
+
    'correct',
Expand 2 lines ...
Commit suggestion

Missing commas in tuples results in implicit string concatenation. Probably not what you intended to do.

Read more
4
+
    'agreed',
5
+
)
views.py
1
+
class HomeView(View):
2
+
    def get(self, request):
3
+
        import pdb; pdb.set_trace()
Suggested changes
-
        import pdb; pdb.set_trace()
Commit suggestion

Don't commit breakpoints. This will pause execution in prod and break the app.

Read more
4
+
        ...
async.py
1
+
async def task():
2
+
    download_files()
Suggested changes
-
    download_files()
+
    await download_files()
Expand 3 lines ...
Commit suggestion

Calling a coroutine without the await statement just returns the coroutine without actually running the function.

Read more
3
+
	
4
+
async def download_files():
5
+
    pass
helpers.py
1
+
any([item for item in items])
Suggested changes
-
any([item for item in items])
+
any(item for item in items)
Commit suggestion

all and any can take a generator, so constructing a list first may be unnecessary.

Read more
settings.py
1
+
REST_FRAMEWORK = {
2
+
    'DEFAULT_PERMISSION_CLASSES': (
3
+
        'rest_framework.permissions.IsAuthenticated'
Suggested changes
-
        'rest_framework.permissions.IsAuthenticated'
+
        'rest_framework.permissions.IsAuthenticated',
Expand 2 lines ...
Commit suggestion

A tuple with only one element must end with a comma. Python won't know it's a tuple without the comma. Probably not what you intended to do.

Read more
4
+
    )
5
+
}
mail.py
1
+
if value is 1:
Suggested changes
-
if value is 1:
+
if value == 1:
Commit suggestion

Primitive data types such as strings and integers should be compared using == and != rather than is and is not.

Read more
2
+
    pass
tests.py
1
+
class TestFeature(unittest.TestCase):
2
+
    def test_feature(self):
3
+
        self.assertTrue(value in values)
Suggested changes
-
        self.assertTrue(value in values)
+
        self.assertIn(value, values)
Commit suggestion

assertIn and assertNotIn provide more helpful failure messages than assertTrue or assertFalse.

Read more
Update tests.py
Over 3000 teams use Code Review Doctor to write better code, release faster, and save time.
  • Department for International Trade
  • Giant
  • Motley fool
  • Lift Interactive
  • Lightmatter
  • Media Interactive
  • We Make Services
  • Sumo

Cleaner and safer code

Code Review Doctor reviews your GitHub pull requests to prevent adding vulnerabilities, performance, or maintainability issues to your code. The code review runs in the cloud so there is nothing to install locally. Cutting edge technology achieves near-zero noise for developers so you can follow best practices without changing how you work.

More than a linter

Code Review Doctor gives clear and actionable advice, which you can commit to your branch directly from your pull request. Code Review Doctor understands the technologies you develop in, including Python, Django, HTML and CSS (closed beta).
344
+
from dataclasses import dataclass
345
+
	
346
+
@dataclass
Suggested changes
-
@dataclass
+
@dataclass(frozen=True)
Expand 2 lines ...
Commit suggestion

Use frozen=True to make the dataclasses immutable and hashable.

Read more
347
+
class FooBarClass:
348
+
    pass
Enforce Python best practice. Skip the docs and stay confident you're following best practice. With Code Review Doctor you stay focused right in your pull request. Read more about our Python capabilities.
344
+
class TestFeature(unittest.TestCase):
345
+
    def test_feature(self):
346
+
        self.assertTrue(value is not None)
Suggested changes
-
        self.assertTrue(value is not None)
+
        self.assertIsNotNone(value)
Commit suggestion

assertIsNone and assertIsNotNone provide more helpful failure messages than assertTrue or assertFalse.

Read more
344
+
class Migration(migrations.Migration):
345
+
    dependencies = [("core", "0001_initial.py")]
346
+
    operations = [RunPython(forwards)]
Suggested changes
-
    operations = [RunPython(forwards)]
+
    operations = [RunPython(forwards, RunPython.noop)]
Commit suggestion

It's good to, as a minimum, specify noop in RunPython so the migration can be skipped when going backwards, and even better to specify a function that undoes the migration.

Read more
Reclaim time reviewing Django code. Code Review Doctor works great for quickly detecting mistakes humans might miss, and even links you to the deep archive of best practice articles to upskill devs. Read more about our Django capabilities.
Prevent bugs. Code Review Doctor knows when code looks fishy and will raise the alarm. With Code Review Doctor you can deploy to prod knowing you've got a code reviewer on your side with the consistency and concentration of a robot.
344
+
values = (
345
+
    'yes',
346
+
    'correct'
Suggested changes
-
    'correct'
+
    'correct',
Expand 2 lines ...
Commit suggestion

Missing commas in tuples results in implicit string concatenation. Probably not what you intended to do.

Read more
347
+
    'agreed',
348
+
)

"Extremely positive. Suggested useful changes, giving our senior developers time back."

Jon Atkinson, Technical Director at Giant

Our price

One subscription unlocks all of our code review capabilities: Python, Django, and more to come in future.

Individual

Free

forever

Protects every PR: Yes

Suggests the fix: Yes

Codebase audit: Yes

Public repositories: Unlimited

Private repositories: No

Support: No

Add to GitHub
Popular

Organization

$49

per month

Protects every PR: Yes

Suggests the fix: Yes

Codebase audit: Yes

Public repositories: Unlimited

Private repositories: 10

Support: 24/7 email and chat

Unlimited

$99

per month

Protects every PR: Yes

Suggests the fix: Yes

Codebase audit: Yes

Public repositories: Unlimited

Private repositories: Unlimited

Support: 24/7 email and chat

Or read about our Python and Django code review capabilities.