idea-php-dotenv-plugin icon indicating copy to clipboard operation
idea-php-dotenv-plugin copied to clipboard

os.environ['value'] support

Open mihaaairu opened this issue 1 year ago • 0 comments

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.

mihaaairu avatar Sep 19 '24 15:09 mihaaairu