HBNetwork / python-decouple

Strict separation of config from code.
MIT License
2.83k stars 196 forks source link

Issue with typings using Pylance type checking #163

Closed renaudjester closed 10 months ago

renaudjester commented 1 year ago

Hi,

I am using Pylance as type checker in my python code (it is using pyright in the background) and I am having typing errors due to python-decouple. Do you think there would be a way to solve this?

What's happening

ENV_VAR = config("ENV_VAR") is interpreted as type Unknown | bool

Expected

ENV_VAR = config("ENV_VAR") is interpreted as type Any or string (indeed it is explicitly written that by default decouple will treat environment variables as strings so I don't wanna use cast)

shmulvad commented 11 months ago

The missing type hints also started to annoy me. If you're interested, I created a fork of this repo that has added type hints: https://github.com/shmulvad/python-decouple-typed

It can be installed with pip install python-decouple-typed

henriquebastos commented 10 months ago

That is a good solution. I have no plans to add typing to python-decouple.