{"action":"created","issue":{"url":"https://api.github.com/repos/grauwoelfchen/flask-dotenv/issues/5","repository_url":"https://api.github.com/repos/grauwoelfchen/flask-dotenv","labels_url":"https://api.github.com/repos/grauwoelfchen/flask-dotenv/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/grauwoelfchen/flask-dotenv/issues/5/comments","events_url":"https://api.github.com/repos/grauwoelfchen/flask-dotenv/issues/5/events","html_url":"https://github.com/grauwoelfchen/flask-dotenv/issues/5","id":127130106,"number":5,"title":"Support appropriate type conversions","user":{"login":"nihonjinrxs","id":479496,"avatar_url":"https://avatars.githubusercontent.com/u/479496?v=3","gravatar_id":"","url":"https://api.github.com/users/nihonjinrxs","html_url":"https://github.com/nihonjinrxs","followers_url":"https://api.github.com/users/nihonjinrxs/followers","following_url":"https://api.github.com/users/nihonjinrxs/following{/other_user}","gists_url":"https://api.github.com/users/nihonjinrxs/gists{/gist_id}","starred_url":"https://api.github.com/users/nihonjinrxs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nihonjinrxs/subscriptions","organizations_url":"https://api.github.com/users/nihonjinrxs/orgs","repos_url":"https://api.github.com/users/nihonjinrxs/repos","events_url":"https://api.github.com/users/nihonjinrxs/events{/privacy}","received_events_url":"https://api.github.com/users/nihonjinrxs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-01-17T22:49:39Z","updated_at":"2016-02-22T17:14:31Z","closed_at":null,"body":"It would be really nice to be able to support appropriate type conversions to standard Python types.\r\n\r\nFor example, [this BitBucket project](https://bitbucket.org/romabysen/flask-envconfig/src/322b4817d2fb1a3b71b8ffe818ab8d45968a5830/flask_envconfig.py?at=default&fileviewer=file-view-default) doesn't support `DotEnv`, only OS Environment variables, but does appropriate type conversions via the `ast` module.  The relevant code looks something like this:\r\n\r\n```python\r\nfrom __future__ import absolute_import\r\nimport ast\r\nfrom os import environ\r\n\r\nclass EnvConfig(object):\r\n    def __init__(self, app): ...\r\n    def init_app(self, app):\r\n        for key, value in environ.iteritems():\r\n            try:\r\n                value = ast.literal_eval(value)\r\n            except (ValueError, SyntaxError):\r\n                pass\r\n            app.config[key] = value\r\n```\r\n\r\nIs this something you're willing to add to this project?  I'm happy to implement and submit a PR."},"comment":{"url":"https://api.github.com/repos/grauwoelfchen/flask-dotenv/issues/comments/187274112","html_url":"https://github.com/grauwoelfchen/flask-dotenv/issues/5#issuecomment-187274112","issue_url":"https://api.github.com/repos/grauwoelfchen/flask-dotenv/issues/5","id":187274112,"user":{"login":"grauwoelfchen","id":163063,"avatar_url":"https://avatars.githubusercontent.com/u/163063?v=3","gravatar_id":"","url":"https://api.github.com/users/grauwoelfchen","html_url":"https://github.com/grauwoelfchen","followers_url":"https://api.github.com/users/grauwoelfchen/followers","following_url":"https://api.github.com/users/grauwoelfchen/following{/other_user}","gists_url":"https://api.github.com/users/grauwoelfchen/gists{/gist_id}","starred_url":"https://api.github.com/users/grauwoelfchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grauwoelfchen/subscriptions","organizations_url":"https://api.github.com/users/grauwoelfchen/orgs","repos_url":"https://api.github.com/users/grauwoelfchen/repos","events_url":"https://api.github.com/users/grauwoelfchen/events{/privacy}","received_events_url":"https://api.github.com/users/grauwoelfchen/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T17:14:31Z","updated_at":"2016-02-22T17:14:31Z","body":"Thank you for thoroughly pull request. (ChangeLog too!)\r\nIt's very nice :+1: \r\n\r\nBut I found some small concerns:\r\n\r\n### verbose_mode\r\n\r\nIt seems that `verbose_mode` does not work for [this change](https://github.com/nihonjinrxs/flask-dotenv/commit/1b2da733d6810e72ce2dd7b15f5f70d96be7d986#diff-3b303c734a8f7d849fd01f38f4bd720aL25). It needs to be assigned to enable verbose mode by optional argument at here.\r\n\r\n```py\r\ndef init_app(self, app, env_file=None, verbose_mode=False):                 \r\n    if self.app is None:                                                    \r\n        self.app = app \r\n    self.verbose_mode = verbose_mode # => this line\r\n```\r\n\r\n### log messages\r\n\r\nAnd [this line](https://github.com/nihonjinrxs/flask-dotenv/commit/1b2da733d6810e72ce2dd7b15f5f70d96be7d986#diff-3b303c734a8f7d849fd01f38f4bd720aR44) will output many messages like this:\r\n\r\n```sh\r\n# I've got these outputs with `verbose_mode` on sample project.\r\n% python manage.py runserver\r\n * SECRET_KEY: value \":)\" of type <class 'str'> cast to <class 'str'>\r\n * Overwriting an existing config var: SECRET_KEY\r\n * MAIL_SERVER: value \"smtp.example.org\" of type <class 'str'> cast to <class 'str'>\r\n * Overwriting an existing config var: MAIL_SERVER\r\n * MAIL_PORT: value 587 of type <class 'str'> cast to <class 'int'>\r\n * Overwriting an existing config var: MAIL_PORT\r\n * MAIL_USERNAME: value \"foo.bar@example.org\" of type <class 'str'> cast to <class 'str'>\r\n * Overwriting an existing config var: MAIL_USERNAME\r\n * MAIL_PASSWORD: value \"foo.bar.baz\" of type <class 'str'> cast to <class 'str'>\r\n * Overwriting an existing config var: MAIL_PASSWORD\r\n * MAIL_SENDER: value \"Foo <foo.bar@example.org>\" of type <class 'str'> cast to <class 'str'>\r\n * Overwriting an existing config var: MAIL_SENDER\r\n * DATABASE_URL: value \"\" of type <class 'str'> cast to <class 'str'>\r\n * Setting an entirely new config var: DATABASE_URL\r\n * DEVELOPMENT_DATABASE_URL: value \"postgresql://qux:quux@localhost/baz_development\" of type <class 'str'> cast to <class 'str'>\r\n * Setting an entirely new config var: DEVELOPMENT_DATABASE_URL\r\n * TEST_DATABASE_URL: value \"postgresql://qux:quux@localhost/baz_test\" of type <class 'str'> cast to <class 'str'>\r\n * Setting an entirely new config var: TEST_DATABASE_URL\r\n * Mapping a specified var as a alias: SQLALCHEMY_DATABASE_URI => DEVELOPMENT_DATABASE_URL\r\n```\r\n\r\nIt really makes sense and messages are very friendly. But I think that these outputs may be a little noisy.\r\n\r\nSo, after merge your PR, I will add small changes to fix these issues for above reasons :wink: \r\n\\# ...and at next time, you could submit a PR from [topic branch](https://help.github.com/articles/using-pull-requests/#initiating-the-pull-request) (not master), then I will be more happy ;)\r\n\r\nAnyway, Thank you so much!\r\n"}}