Python

Python

Made by DeepSource

Appending to dictionary immediately following its definition PY-W0072

Anti-pattern
Major
Autofix

Instead of adding items to a dictionary just after creation, it should be refactored to add those items into the dict definition itself.

Bad practice

env = {}
env['HOST'] = 'example.com'
env['PORT'] = 8080

Recommended

env = {'HOST': 'example.com', 'PORT': 8080}