prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add encoding to `read_env_file()`
  # Feature Request
  
  Output of `import pydantic.utils; print(pydantic.utils.version_info())`:
  
  ```
               pydantic version: 1.5.1
              pydantic compiled: True
                 python version: 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]
                       platform: Windows-7-6.1.7601-SP1
       optional deps. installed: ['email-validator']
  ```
  
  ## Description
  
  Hi, there's known problem on Windows with parsing dotenv files - https://github.com/pypa/pipenv/issues/1963. `python-dotenv` would parse files with default encoding (cp1251 for Cyrillic Windows). As a result we get `Р›РёСЃС‚ 1` instead of `Лист 1`.
  
  It looks like [this](https://github.com/samuelcolvin/pydantic/blob/960b24a5aab7ae0631bfbfbe0047b4d8600c6012/pydantic/env_settings.py#L111) function need to fetch encoding from `Config` class somehow.
  
  <!-- Where possible please include a self-contained code snippet describing your feature request: -->
  
  ## Example
  
  `.env` file (UTF-8):
  
  ```
  foo=Лист 1
  ```
  
  Code snippet:
  
  ```py
  import pydantic
  
  class Settings(pydantic.BaseSettings):
      foo: str
  
      class Config:
          env_file_encoding = 'utf-8'
  
  settings = Settings(_env_file='.env')
  print(settings)
  # foo='Лист 1'
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pydantic/env_settings.py`
  Content:
  ```
  1 import os
  2 import warnings
  3 from pathlib import Path
  4 from typing import AbstractSet, Any, Dict, List, Mapping, Optional, Union
  5 
  6 from .fields import ModelField
  7 from .main import BaseModel, Extra
  8 from .typing import display_as_type
  9 from .utils import deep_update, sequence_like
  10 
  11 env_file_sentinel = str(object())
  12 
  13 
  14 class SettingsError(ValueError):
  15     pass
  16 
  17 
  18 class BaseSettings(BaseModel):
  19     """
  20     Base class for settings, allowing values to be overridden by environment variables.
  21 
  22     This is useful in production for secrets you do not wish to save in code, it plays nicely with docker(-compose),
  23     Heroku and any 12 factor app design.
  24     """
  25 
  26     def __init__(__pydantic_self__, _env_file: Union[Path, str, None] = env_file_sentinel, **values: Any) -> None:
  27         # Uses something other than `self` the first arg to allow "self" as a settable attribute
  28         super().__init__(**__pydantic_self__._build_values(values, _env_file=_env_file))
  29 
  30     def _build_values(self, init_kwargs: Dict[str, Any], _env_file: Union[Path, str, None] = None) -> Dict[str, Any]:
  31         return deep_update(self._build_environ(_env_file), init_kwargs)
  32 
  33     def _build_environ(self, _env_file: Union[Path, str, None] = None) -> Dict[str, Optional[str]]:
  34         """
  35         Build environment variables suitable for passing to the Model.
  36         """
  37         d: Dict[str, Optional[str]] = {}
  38 
  39         if self.__config__.case_sensitive:
  40             env_vars: Mapping[str, Optional[str]] = os.environ
  41         else:
  42             env_vars = {k.lower(): v for k, v in os.environ.items()}
  43 
  44         env_file = _env_file if _env_file != env_file_sentinel else self.__config__.env_file
  45         if env_file is not None:
  46             env_path = Path(env_file)
  47             if env_path.is_file():
  48                 env_vars = {**read_env_file(env_path, case_sensitive=self.__config__.case_sensitive), **env_vars}
  49 
  50         for field in self.__fields__.values():
  51             env_val: Optional[str] = None
  52             for env_name in field.field_info.extra['env_names']:
  53                 env_val = env_vars.get(env_name)
  54                 if env_val is not None:
  55                     break
  56 
  57             if env_val is None:
  58                 continue
  59 
  60             if field.is_complex():
  61                 try:
  62                     env_val = self.__config__.json_loads(env_val)  # type: ignore
  63                 except ValueError as e:
  64                     raise SettingsError(f'error parsing JSON for "{env_name}"') from e
  65             d[field.alias] = env_val
  66         return d
  67 
  68     class Config:
  69         env_prefix = ''
  70         env_file = None
  71         validate_all = True
  72         extra = Extra.forbid
  73         arbitrary_types_allowed = True
  74         case_sensitive = False
  75 
  76         @classmethod
  77         def prepare_field(cls, field: ModelField) -> None:
  78             env_names: Union[List[str], AbstractSet[str]]
  79             env = field.field_info.extra.get('env')
  80             if env is None:
  81                 if field.has_alias:
  82                     warnings.warn(
  83                         'aliases are no longer used by BaseSettings to define which environment variables to read. '
  84                         'Instead use the "env" field setting. '
  85                         'See https://pydantic-docs.helpmanual.io/usage/settings/#environment-variable-names',
  86                         FutureWarning,
  87                     )
  88                 env_names = {cls.env_prefix + field.name}
  89             elif isinstance(env, str):
  90                 env_names = {env}
  91             elif isinstance(env, (set, frozenset)):
  92                 env_names = env
  93             elif sequence_like(env):
  94                 env_names = list(env)
  95             else:
  96                 raise TypeError(f'invalid field env: {env!r} ({display_as_type(env)}); should be string, list or set')
  97 
  98             if not cls.case_sensitive:
  99                 env_names = env_names.__class__(n.lower() for n in env_names)
  100             field.field_info.extra['env_names'] = env_names
  101 
  102     __config__: Config  # type: ignore
  103 
  104 
  105 def read_env_file(file_path: Path, *, case_sensitive: bool = False) -> Dict[str, Optional[str]]:
  106     try:
  107         from dotenv import dotenv_values
  108     except ImportError as e:
  109         raise ImportError('python-dotenv is not installed, run `pip install pydantic[dotenv]`') from e
  110 
  111     file_vars: Dict[str, Optional[str]] = dotenv_values(file_path)
  112     if not case_sensitive:
  113         return {k.lower(): v for k, v in file_vars.items()}
  114     else:
  115         return file_vars
  116
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pydantic/env_settings.py b/pydantic/env_settings.py
  --- a/pydantic/env_settings.py
  +++ b/pydantic/env_settings.py
  @@ -23,14 +23,28 @@
       Heroku and any 12 factor app design.
       """
   
  -    def __init__(__pydantic_self__, _env_file: Union[Path, str, None] = env_file_sentinel, **values: Any) -> None:
  +    def __init__(
  +        __pydantic_self__,
  +        _env_file: Union[Path, str, None] = env_file_sentinel,
  +        _env_file_encoding: Optional[str] = None,
  +        **values: Any,
  +    ) -> None:
           # Uses something other than `self` the first arg to allow "self" as a settable attribute
  -        super().__init__(**__pydantic_self__._build_values(values, _env_file=_env_file))
  -
  -    def _build_values(self, init_kwargs: Dict[str, Any], _env_file: Union[Path, str, None] = None) -> Dict[str, Any]:
  -        return deep_update(self._build_environ(_env_file), init_kwargs)
  -
  -    def _build_environ(self, _env_file: Union[Path, str, None] = None) -> Dict[str, Optional[str]]:
  +        super().__init__(
  +            **__pydantic_self__._build_values(values, _env_file=_env_file, _env_file_encoding=_env_file_encoding)
  +        )
  +
  +    def _build_values(
  +        self,
  +        init_kwargs: Dict[str, Any],
  +        _env_file: Union[Path, str, None] = None,
  +        _env_file_encoding: Optional[str] = None,
  +    ) -> Dict[str, Any]:
  +        return deep_update(self._build_environ(_env_file, _env_file_encoding), init_kwargs)
  +
  +    def _build_environ(
  +        self, _env_file: Union[Path, str, None] = None, _env_file_encoding: Optional[str] = None
  +    ) -> Dict[str, Optional[str]]:
           """
           Build environment variables suitable for passing to the Model.
           """
  @@ -42,10 +56,16 @@
               env_vars = {k.lower(): v for k, v in os.environ.items()}
   
           env_file = _env_file if _env_file != env_file_sentinel else self.__config__.env_file
  +        env_file_encoding = _env_file_encoding if _env_file_encoding is not None else self.__config__.env_file_encoding
           if env_file is not None:
               env_path = Path(env_file)
               if env_path.is_file():
  -                env_vars = {**read_env_file(env_path, case_sensitive=self.__config__.case_sensitive), **env_vars}
  +                env_vars = {
  +                    **read_env_file(
  +                        env_path, encoding=env_file_encoding, case_sensitive=self.__config__.case_sensitive
  +                    ),
  +                    **env_vars,
  +                }
   
           for field in self.__fields__.values():
               env_val: Optional[str] = None
  @@ -68,6 +88,7 @@
       class Config:
           env_prefix = ''
           env_file = None
  +        env_file_encoding = None
           validate_all = True
           extra = Extra.forbid
           arbitrary_types_allowed = True
  @@ -102,13 +123,13 @@
       __config__: Config  # type: ignore
   
   
  -def read_env_file(file_path: Path, *, case_sensitive: bool = False) -> Dict[str, Optional[str]]:
  +def read_env_file(file_path: Path, *, encoding: str = None, case_sensitive: bool = False) -> Dict[str, Optional[str]]:
       try:
           from dotenv import dotenv_values
       except ImportError as e:
           raise ImportError('python-dotenv is not installed, run `pip install pydantic[dotenv]`') from e
   
  -    file_vars: Dict[str, Optional[str]] = dotenv_values(file_path)
  +    file_vars: Dict[str, Optional[str]] = dotenv_values(file_path, encoding=encoding)
       if not case_sensitive:
           return {k.lower(): v for k, v in file_vars.items()}
       else:
  
verification_info: {"golden_diff": "diff --git a/pydantic/env_settings.py b/pydantic/env_settings.py\n--- a/pydantic/env_settings.py\n+++ b/pydantic/env_settings.py\n@@ -23,14 +23,28 @@\n     Heroku and any 12 factor app design.\n     \"\"\"\n \n-    def __init__(__pydantic_self__, _env_file: Union[Path, str, None] = env_file_sentinel, **values: Any) -> None:\n+    def __init__(\n+        __pydantic_self__,\n+        _env_file: Union[Path, str, None] = env_file_sentinel,\n+        _env_file_encoding: Optional[str] = None,\n+        **values: Any,\n+    ) -> None:\n         # Uses something other than `self` the first arg to allow \"self\" as a settable attribute\n-        super().__init__(**__pydantic_self__._build_values(values, _env_file=_env_file))\n-\n-    def _build_values(self, init_kwargs: Dict[str, Any], _env_file: Union[Path, str, None] = None) -> Dict[str, Any]:\n-        return deep_update(self._build_environ(_env_file), init_kwargs)\n-\n-    def _build_environ(self, _env_file: Union[Path, str, None] = None) -> Dict[str, Optional[str]]:\n+        super().__init__(\n+            **__pydantic_self__._build_values(values, _env_file=_env_file, _env_file_encoding=_env_file_encoding)\n+        )\n+\n+    def _build_values(\n+        self,\n+        init_kwargs: Dict[str, Any],\n+        _env_file: Union[Path, str, None] = None,\n+        _env_file_encoding: Optional[str] = None,\n+    ) -> Dict[str, Any]:\n+        return deep_update(self._build_environ(_env_file, _env_file_encoding), init_kwargs)\n+\n+    def _build_environ(\n+        self, _env_file: Union[Path, str, None] = None, _env_file_encoding: Optional[str] = None\n+    ) -> Dict[str, Optional[str]]:\n         \"\"\"\n         Build environment variables suitable for passing to the Model.\n         \"\"\"\n@@ -42,10 +56,16 @@\n             env_vars = {k.lower(): v for k, v in os.environ.items()}\n \n         env_file = _env_file if _env_file != env_file_sentinel else self.__config__.env_file\n+        env_file_encoding = _env_file_encoding if _env_file_encoding is not None else self.__config__.env_file_encoding\n         if env_file is not None:\n             env_path = Path(env_file)\n             if env_path.is_file():\n-                env_vars = {**read_env_file(env_path, case_sensitive=self.__config__.case_sensitive), **env_vars}\n+                env_vars = {\n+                    **read_env_file(\n+                        env_path, encoding=env_file_encoding, case_sensitive=self.__config__.case_sensitive\n+                    ),\n+                    **env_vars,\n+                }\n \n         for field in self.__fields__.values():\n             env_val: Optional[str] = None\n@@ -68,6 +88,7 @@\n     class Config:\n         env_prefix = ''\n         env_file = None\n+        env_file_encoding = None\n         validate_all = True\n         extra = Extra.forbid\n         arbitrary_types_allowed = True\n@@ -102,13 +123,13 @@\n     __config__: Config  # type: ignore\n \n \n-def read_env_file(file_path: Path, *, case_sensitive: bool = False) -> Dict[str, Optional[str]]:\n+def read_env_file(file_path: Path, *, encoding: str = None, case_sensitive: bool = False) -> Dict[str, Optional[str]]:\n     try:\n         from dotenv import dotenv_values\n     except ImportError as e:\n         raise ImportError('python-dotenv is not installed, run `pip install pydantic[dotenv]`') from e\n \n-    file_vars: Dict[str, Optional[str]] = dotenv_values(file_path)\n+    file_vars: Dict[str, Optional[str]] = dotenv_values(file_path, encoding=encoding)\n     if not case_sensitive:\n         return {k.lower(): v for k, v in file_vars.items()}\n     else:\n", "issue": "Add encoding to `read_env_file()`\n# Feature Request\r\n\r\nOutput of `import pydantic.utils; print(pydantic.utils.version_info())`:\r\n\r\n```\r\n             pydantic version: 1.5.1\r\n            pydantic compiled: True\r\n               python version: 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]\r\n                     platform: Windows-7-6.1.7601-SP1\r\n     optional deps. installed: ['email-validator']\r\n```\r\n\r\n## Description\r\n\r\nHi, there's known problem on Windows with parsing dotenv files - https://github.com/pypa/pipenv/issues/1963. `python-dotenv` would parse files with default encoding (cp1251 for Cyrillic Windows). As a result we get `\u0420\u203a\u0420\u0451\u0421\u0403\u0421\u201a 1` instead of `\u041b\u0438\u0441\u0442 1`.\r\n\r\nIt looks like [this](https://github.com/samuelcolvin/pydantic/blob/960b24a5aab7ae0631bfbfbe0047b4d8600c6012/pydantic/env_settings.py#L111) function need to fetch encoding from `Config` class somehow.\r\n\r\n<!-- Where possible please include a self-contained code snippet describing your feature request: -->\r\n\r\n## Example\r\n\r\n`.env` file (UTF-8):\r\n\r\n```\r\nfoo=\u041b\u0438\u0441\u0442 1\r\n```\r\n\r\nCode snippet:\r\n\r\n```py\r\nimport pydantic\r\n\r\nclass Settings(pydantic.BaseSettings):\r\n    foo: str\r\n\r\n    class Config:\r\n        env_file_encoding = 'utf-8'\r\n\r\nsettings = Settings(_env_file='.env')\r\nprint(settings)\r\n# foo='\u041b\u0438\u0441\u0442 1'\r\n```\r\n\n", "before_files": [{"content": "import os\nimport warnings\nfrom pathlib import Path\nfrom typing import AbstractSet, Any, Dict, List, Mapping, Optional, Union\n\nfrom .fields import ModelField\nfrom .main import BaseModel, Extra\nfrom .typing import display_as_type\nfrom .utils import deep_update, sequence_like\n\nenv_file_sentinel = str(object())\n\n\nclass SettingsError(ValueError):\n    pass\n\n\nclass BaseSettings(BaseModel):\n    \"\"\"\n    Base class for settings, allowing values to be overridden by environment variables.\n\n    This is useful in production for secrets you do not wish to save in code, it plays nicely with docker(-compose),\n    Heroku and any 12 factor app design.\n    \"\"\"\n\n    def __init__(__pydantic_self__, _env_file: Union[Path, str, None] = env_file_sentinel, **values: Any) -> None:\n        # Uses something other than `self` the first arg to allow \"self\" as a settable attribute\n        super().__init__(**__pydantic_self__._build_values(values, _env_file=_env_file))\n\n    def _build_values(self, init_kwargs: Dict[str, Any], _env_file: Union[Path, str, None] = None) -> Dict[str, Any]:\n        return deep_update(self._build_environ(_env_file), init_kwargs)\n\n    def _build_environ(self, _env_file: Union[Path, str, None] = None) -> Dict[str, Optional[str]]:\n        \"\"\"\n        Build environment variables suitable for passing to the Model.\n        \"\"\"\n        d: Dict[str, Optional[str]] = {}\n\n        if self.__config__.case_sensitive:\n            env_vars: Mapping[str, Optional[str]] = os.environ\n        else:\n            env_vars = {k.lower(): v for k, v in os.environ.items()}\n\n        env_file = _env_file if _env_file != env_file_sentinel else self.__config__.env_file\n        if env_file is not None:\n            env_path = Path(env_file)\n            if env_path.is_file():\n                env_vars = {**read_env_file(env_path, case_sensitive=self.__config__.case_sensitive), **env_vars}\n\n        for field in self.__fields__.values():\n            env_val: Optional[str] = None\n            for env_name in field.field_info.extra['env_names']:\n                env_val = env_vars.get(env_name)\n                if env_val is not None:\n                    break\n\n            if env_val is None:\n                continue\n\n            if field.is_complex():\n                try:\n                    env_val = self.__config__.json_loads(env_val)  # type: ignore\n                except ValueError as e:\n                    raise SettingsError(f'error parsing JSON for \"{env_name}\"') from e\n            d[field.alias] = env_val\n        return d\n\n    class Config:\n        env_prefix = ''\n        env_file = None\n        validate_all = True\n        extra = Extra.forbid\n        arbitrary_types_allowed = True\n        case_sensitive = False\n\n        @classmethod\n        def prepare_field(cls, field: ModelField) -> None:\n            env_names: Union[List[str], AbstractSet[str]]\n            env = field.field_info.extra.get('env')\n            if env is None:\n                if field.has_alias:\n                    warnings.warn(\n                        'aliases are no longer used by BaseSettings to define which environment variables to read. '\n                        'Instead use the \"env\" field setting. '\n                        'See https://pydantic-docs.helpmanual.io/usage/settings/#environment-variable-names',\n                        FutureWarning,\n                    )\n                env_names = {cls.env_prefix + field.name}\n            elif isinstance(env, str):\n                env_names = {env}\n            elif isinstance(env, (set, frozenset)):\n                env_names = env\n            elif sequence_like(env):\n                env_names = list(env)\n            else:\n                raise TypeError(f'invalid field env: {env!r} ({display_as_type(env)}); should be string, list or set')\n\n            if not cls.case_sensitive:\n                env_names = env_names.__class__(n.lower() for n in env_names)\n            field.field_info.extra['env_names'] = env_names\n\n    __config__: Config  # type: ignore\n\n\ndef read_env_file(file_path: Path, *, case_sensitive: bool = False) -> Dict[str, Optional[str]]:\n    try:\n        from dotenv import dotenv_values\n    except ImportError as e:\n        raise ImportError('python-dotenv is not installed, run `pip install pydantic[dotenv]`') from e\n\n    file_vars: Dict[str, Optional[str]] = dotenv_values(file_path)\n    if not case_sensitive:\n        return {k.lower(): v for k, v in file_vars.items()}\n    else:\n        return file_vars\n", "path": "pydantic/env_settings.py"}], "after_files": [{"content": "import os\nimport warnings\nfrom pathlib import Path\nfrom typing import AbstractSet, Any, Dict, List, Mapping, Optional, Union\n\nfrom .fields import ModelField\nfrom .main import BaseModel, Extra\nfrom .typing import display_as_type\nfrom .utils import deep_update, sequence_like\n\nenv_file_sentinel = str(object())\n\n\nclass SettingsError(ValueError):\n    pass\n\n\nclass BaseSettings(BaseModel):\n    \"\"\"\n    Base class for settings, allowing values to be overridden by environment variables.\n\n    This is useful in production for secrets you do not wish to save in code, it plays nicely with docker(-compose),\n    Heroku and any 12 factor app design.\n    \"\"\"\n\n    def __init__(\n        __pydantic_self__,\n        _env_file: Union[Path, str, None] = env_file_sentinel,\n        _env_file_encoding: Optional[str] = None,\n        **values: Any,\n    ) -> None:\n        # Uses something other than `self` the first arg to allow \"self\" as a settable attribute\n        super().__init__(\n            **__pydantic_self__._build_values(values, _env_file=_env_file, _env_file_encoding=_env_file_encoding)\n        )\n\n    def _build_values(\n        self,\n        init_kwargs: Dict[str, Any],\n        _env_file: Union[Path, str, None] = None,\n        _env_file_encoding: Optional[str] = None,\n    ) -> Dict[str, Any]:\n        return deep_update(self._build_environ(_env_file, _env_file_encoding), init_kwargs)\n\n    def _build_environ(\n        self, _env_file: Union[Path, str, None] = None, _env_file_encoding: Optional[str] = None\n    ) -> Dict[str, Optional[str]]:\n        \"\"\"\n        Build environment variables suitable for passing to the Model.\n        \"\"\"\n        d: Dict[str, Optional[str]] = {}\n\n        if self.__config__.case_sensitive:\n            env_vars: Mapping[str, Optional[str]] = os.environ\n        else:\n            env_vars = {k.lower(): v for k, v in os.environ.items()}\n\n        env_file = _env_file if _env_file != env_file_sentinel else self.__config__.env_file\n        env_file_encoding = _env_file_encoding if _env_file_encoding is not None else self.__config__.env_file_encoding\n        if env_file is not None:\n            env_path = Path(env_file)\n            if env_path.is_file():\n                env_vars = {\n                    **read_env_file(\n                        env_path, encoding=env_file_encoding, case_sensitive=self.__config__.case_sensitive\n                    ),\n                    **env_vars,\n                }\n\n        for field in self.__fields__.values():\n            env_val: Optional[str] = None\n            for env_name in field.field_info.extra['env_names']:\n                env_val = env_vars.get(env_name)\n                if env_val is not None:\n                    break\n\n            if env_val is None:\n                continue\n\n            if field.is_complex():\n                try:\n                    env_val = self.__config__.json_loads(env_val)  # type: ignore\n                except ValueError as e:\n                    raise SettingsError(f'error parsing JSON for \"{env_name}\"') from e\n            d[field.alias] = env_val\n        return d\n\n    class Config:\n        env_prefix = ''\n        env_file = None\n        env_file_encoding = None\n        validate_all = True\n        extra = Extra.forbid\n        arbitrary_types_allowed = True\n        case_sensitive = False\n\n        @classmethod\n        def prepare_field(cls, field: ModelField) -> None:\n            env_names: Union[List[str], AbstractSet[str]]\n            env = field.field_info.extra.get('env')\n            if env is None:\n                if field.has_alias:\n                    warnings.warn(\n                        'aliases are no longer used by BaseSettings to define which environment variables to read. '\n                        'Instead use the \"env\" field setting. '\n                        'See https://pydantic-docs.helpmanual.io/usage/settings/#environment-variable-names',\n                        FutureWarning,\n                    )\n                env_names = {cls.env_prefix + field.name}\n            elif isinstance(env, str):\n                env_names = {env}\n            elif isinstance(env, (set, frozenset)):\n                env_names = env\n            elif sequence_like(env):\n                env_names = list(env)\n            else:\n                raise TypeError(f'invalid field env: {env!r} ({display_as_type(env)}); should be string, list or set')\n\n            if not cls.case_sensitive:\n                env_names = env_names.__class__(n.lower() for n in env_names)\n            field.field_info.extra['env_names'] = env_names\n\n    __config__: Config  # type: ignore\n\n\ndef read_env_file(file_path: Path, *, encoding: str = None, case_sensitive: bool = False) -> Dict[str, Optional[str]]:\n    try:\n        from dotenv import dotenv_values\n    except ImportError as e:\n        raise ImportError('python-dotenv is not installed, run `pip install pydantic[dotenv]`') from e\n\n    file_vars: Dict[str, Optional[str]] = dotenv_values(file_path, encoding=encoding)\n    if not case_sensitive:\n        return {k.lower(): v for k, v in file_vars.items()}\n    else:\n        return file_vars\n", "path": "pydantic/env_settings.py"}]}