HBNetwork / python-decouple

Strict separation of config from code.
MIT License
2.79k stars 192 forks source link

Infer cast if default is given #74

Closed Lonami closed 5 years ago

Lonami commented 5 years ago

I simply want to put the idea on the table. If default is set and cast is not, maybe we could default to use cast = type(default)?

Before:

DEBUG = config('DEBUG', default=False, cast=bool)
EMAIL_PORT = config('EMAIL_PORT', default=25, cast=int)

After:

DEBUG = config('DEBUG', default=False)
EMAIL_PORT = config('EMAIL_PORT', default=25)

Toggling off the feature would be done by setting default=str. But I guess this would be a breaking change. Another disadvantage is that explicit is better than implicit like the Python's Zen says. Maybe it's not clear that it will use int if we remove cast, for example.

I'm not happy with the idea so I'm going to close it to remove noise.