adelf / idea-php-dotenv-plugin

environment parameters completion, based on .env file keys
MIT License
166 stars 13 forks source link

os.environ['value'] support #137

Open mihaaairu opened 1 month ago

mihaaairu commented 1 month ago

That would be great to extend current syntaxis with standart python dictionary's.

For now we can work with .env vars like this: os.getenv('value') or os.environ.get('value'). But .get() methods handles KeyError exceptions, so, we can't autocheck .env file correctness.

All we can do is to write smth like that:

foo = os.getenv('bar', None)
if foo is None:
    raise KeyError('bar')

But, this of cource this ruins the code clearness/elegancy.

So, the main idea is to extend support for python dictionary syntaxis, which will looks like that: os.environ['value']. This syntax will throw the exception in case of incorrect .env key.