prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  User home directory is not expanded for TextLocalDataSet
  ## Description
  User home directory `~` is not automatically expanded for `TextLocalDataSet`, but it is automatically expanded for `ParquetLocalDataSet` and `CSVLocalDataSet `.
  
  ## Context
  Trying to specify file paths relative to user home directory to simplify interoperability and handoff of Kedro pipelines between teammates - instead of manually replacing hardcoded absolute paths on each machine or user, each user will automatically recreate same directory structure relative to his/her home directory.   
  
  ## Steps to Reproduce
  ```
  from kedro.io import TextLocalDataSet
  import os
  
  
  string_to_write = "This will go in a file."
  
  data_set = TextLocalDataSet(filepath="~/code/tmp/new_documentation.md")
  data_set.save(string_to_write)
  
  os.path.abspath(data_set._filepath)
  ```
  
  ## Expected Result
  `~` should be replaced by user home directory and file should be saved relative to it in subdirectory `code/tmp/`.
  
  ## Actual Result
  Directory `~/code/tmp/` is created in current working directory.
  
  
  ## Your Environment
  Include as many relevant details about the environment in which you experienced the bug:
  
  * Kedro version used (`pip show kedro` or `kedro -V`): v0.14.2
  * Python version used (`python -V`): Python 3.6.8 :: Anaconda, Inc.
  * Operating system and version: MacOS Mojave 10.14.3
  
  ## Checklist
  Include labels so that we can categorise your issue:
  
  - [ ] Add a "Component" label to the issue
  - [ ] Add a "Priority" label to the issue
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `kedro/io/text_local.py`
  Content:
  ```
  1 # Copyright 2018-2019 QuantumBlack Visual Analytics Limited
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 # http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  10 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  11 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
  12 # NONINFRINGEMENT. IN NO EVENT WILL THE LICENSOR OR OTHER CONTRIBUTORS
  13 # BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN
  14 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN
  15 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16 #
  17 # The QuantumBlack Visual Analytics Limited (“QuantumBlack”) name and logo
  18 # (either separately or in combination, “QuantumBlack Trademarks”) are
  19 # trademarks of QuantumBlack. The License does not grant you any right or
  20 # license to the QuantumBlack Trademarks. You may not use the QuantumBlack
  21 # Trademarks or any confusingly similar mark as a trademark for your product,
  22 #     or use the QuantumBlack Trademarks in any other manner that might cause
  23 # confusion in the marketplace, including but not limited to in advertising,
  24 # on websites, or on software.
  25 #
  26 # See the License for the specific language governing permissions and
  27 # limitations under the License.
  28 """``TextLocalDataSet`` loads and saves data to a local text file. The data is
  29 accessed text data using the python open function.
  30 """
  31 from pathlib import Path
  32 from typing import Any, Dict
  33 
  34 from kedro.io import AbstractDataSet
  35 from kedro.io.core import DataSetError, FilepathVersionMixIn, Version
  36 
  37 
  38 class TextLocalDataSet(AbstractDataSet, FilepathVersionMixIn):
  39     """``TextLocalDataSet`` loads and saves unstructured text files.
  40 
  41     Example:
  42     ::
  43 
  44         >>> from kedro.io import TextLocalDataSet
  45         >>>
  46         >>> string_to_write = "This will go in a file."
  47         >>>
  48         >>> data_set = TextLocalDataSet(filepath="docs/new_documentation.md")
  49         >>> data_set.save(string_to_write)
  50         >>> reloaded = data_set.load()
  51     """
  52 
  53     def _describe(self) -> Dict[str, Any]:
  54         return dict(
  55             filepath=self._filepath,
  56             load_args=self._load_args,
  57             save_args=self._save_args,
  58             version=self._version,
  59         )
  60 
  61     def __init__(
  62         self,
  63         filepath: str,
  64         load_args: Dict[str, Any] = None,
  65         save_args: Dict[str, Any] = None,
  66         version: Version = None,
  67     ) -> None:
  68         """Creates a new instance of ``TextFile``.
  69 
  70         Args:
  71             filepath: path to a text file.
  72             load_args: Load arguments should be specified in accordance with
  73                 the built in open function. This can be found at
  74                 https://docs.python.org/3/library/functions.html#open
  75             save_args: Save arguments should be specified in accordance with
  76                 the built in open function. This can be found at
  77                 https://docs.python.org/3/library/functions.html#open
  78             version: If specified, should be an instance of
  79                 ``kedro.io.core.Version``. If its ``load`` attribute is
  80                 None, the latest version will be loaded. If its ``save``
  81                 attribute is None, save version will be autogenerated.
  82         """
  83         default_save_args = {"mode": "w"}
  84         default_load_args = {"mode": "r"}
  85 
  86         self._filepath = filepath
  87         self._load_args = (
  88             {**default_load_args, **load_args}
  89             if load_args is not None
  90             else default_load_args
  91         )
  92         self._save_args = (
  93             {**default_save_args, **save_args}
  94             if save_args is not None
  95             else default_save_args
  96         )
  97         self._version = version
  98 
  99     def _load(self) -> str:
  100         load_path = self._get_load_path(self._filepath, self._version)
  101         with open(load_path, **self._load_args) as _file:
  102             return _file.read()
  103 
  104     def _save(self, data: str) -> None:
  105         save_path = Path(self._get_save_path(self._filepath, self._version))
  106         save_path.parent.mkdir(parents=True, exist_ok=True)
  107         with open(str(save_path), **self._save_args) as _file:
  108             _file.write(data)
  109 
  110         load_path = Path(self._get_load_path(self._filepath, self._version))
  111         self._check_paths_consistency(
  112             str(load_path.absolute()), str(save_path.absolute())
  113         )
  114 
  115     def _exists(self) -> bool:
  116         try:
  117             path = self._get_load_path(self._filepath, self._version)
  118         except DataSetError:
  119             return False
  120         return Path(path).is_file()
  121
  ```
  --- 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/kedro/io/text_local.py b/kedro/io/text_local.py
  --- a/kedro/io/text_local.py
  +++ b/kedro/io/text_local.py
  @@ -28,6 +28,7 @@
   """``TextLocalDataSet`` loads and saves data to a local text file. The data is
   accessed text data using the python open function.
   """
  +import os
   from pathlib import Path
   from typing import Any, Dict
   
  @@ -83,7 +84,7 @@
           default_save_args = {"mode": "w"}
           default_load_args = {"mode": "r"}
   
  -        self._filepath = filepath
  +        self._filepath = os.path.expanduser(filepath)
           self._load_args = (
               {**default_load_args, **load_args}
               if load_args is not None
  
verification_info: {"golden_diff": "diff --git a/kedro/io/text_local.py b/kedro/io/text_local.py\n--- a/kedro/io/text_local.py\n+++ b/kedro/io/text_local.py\n@@ -28,6 +28,7 @@\n \"\"\"``TextLocalDataSet`` loads and saves data to a local text file. The data is\n accessed text data using the python open function.\n \"\"\"\n+import os\n from pathlib import Path\n from typing import Any, Dict\n \n@@ -83,7 +84,7 @@\n         default_save_args = {\"mode\": \"w\"}\n         default_load_args = {\"mode\": \"r\"}\n \n-        self._filepath = filepath\n+        self._filepath = os.path.expanduser(filepath)\n         self._load_args = (\n             {**default_load_args, **load_args}\n             if load_args is not None\n", "issue": "User home directory is not expanded for TextLocalDataSet\n## Description\r\nUser home directory `~` is not automatically expanded for `TextLocalDataSet`, but it is automatically expanded for `ParquetLocalDataSet` and `CSVLocalDataSet `.\r\n\r\n## Context\r\nTrying to specify file paths relative to user home directory to simplify interoperability and handoff of Kedro pipelines between teammates - instead of manually replacing hardcoded absolute paths on each machine or user, each user will automatically recreate same directory structure relative to his/her home directory.   \r\n\r\n## Steps to Reproduce\r\n```\r\nfrom kedro.io import TextLocalDataSet\r\nimport os\r\n\r\n\r\nstring_to_write = \"This will go in a file.\"\r\n\r\ndata_set = TextLocalDataSet(filepath=\"~/code/tmp/new_documentation.md\")\r\ndata_set.save(string_to_write)\r\n\r\nos.path.abspath(data_set._filepath)\r\n```\r\n\r\n## Expected Result\r\n`~` should be replaced by user home directory and file should be saved relative to it in subdirectory `code/tmp/`.\r\n\r\n## Actual Result\r\nDirectory `~/code/tmp/` is created in current working directory.\r\n\r\n\r\n## Your Environment\r\nInclude as many relevant details about the environment in which you experienced the bug:\r\n\r\n* Kedro version used (`pip show kedro` or `kedro -V`): v0.14.2\r\n* Python version used (`python -V`): Python 3.6.8 :: Anaconda, Inc.\r\n* Operating system and version: MacOS Mojave 10.14.3\r\n\r\n## Checklist\r\nInclude labels so that we can categorise your issue:\r\n\r\n- [ ] Add a \"Component\" label to the issue\r\n- [ ] Add a \"Priority\" label to the issue\r\n\n", "before_files": [{"content": "# Copyright 2018-2019 QuantumBlack Visual Analytics Limited\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND\n# NONINFRINGEMENT. IN NO EVENT WILL THE LICENSOR OR OTHER CONTRIBUTORS\n# BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN\n# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN\n# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n#\n# The QuantumBlack Visual Analytics Limited (\u201cQuantumBlack\u201d) name and logo\n# (either separately or in combination, \u201cQuantumBlack Trademarks\u201d) are\n# trademarks of QuantumBlack. The License does not grant you any right or\n# license to the QuantumBlack Trademarks. You may not use the QuantumBlack\n# Trademarks or any confusingly similar mark as a trademark for your product,\n#     or use the QuantumBlack Trademarks in any other manner that might cause\n# confusion in the marketplace, including but not limited to in advertising,\n# on websites, or on software.\n#\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"``TextLocalDataSet`` loads and saves data to a local text file. The data is\naccessed text data using the python open function.\n\"\"\"\nfrom pathlib import Path\nfrom typing import Any, Dict\n\nfrom kedro.io import AbstractDataSet\nfrom kedro.io.core import DataSetError, FilepathVersionMixIn, Version\n\n\nclass TextLocalDataSet(AbstractDataSet, FilepathVersionMixIn):\n    \"\"\"``TextLocalDataSet`` loads and saves unstructured text files.\n\n    Example:\n    ::\n\n        >>> from kedro.io import TextLocalDataSet\n        >>>\n        >>> string_to_write = \"This will go in a file.\"\n        >>>\n        >>> data_set = TextLocalDataSet(filepath=\"docs/new_documentation.md\")\n        >>> data_set.save(string_to_write)\n        >>> reloaded = data_set.load()\n    \"\"\"\n\n    def _describe(self) -> Dict[str, Any]:\n        return dict(\n            filepath=self._filepath,\n            load_args=self._load_args,\n            save_args=self._save_args,\n            version=self._version,\n        )\n\n    def __init__(\n        self,\n        filepath: str,\n        load_args: Dict[str, Any] = None,\n        save_args: Dict[str, Any] = None,\n        version: Version = None,\n    ) -> None:\n        \"\"\"Creates a new instance of ``TextFile``.\n\n        Args:\n            filepath: path to a text file.\n            load_args: Load arguments should be specified in accordance with\n                the built in open function. This can be found at\n                https://docs.python.org/3/library/functions.html#open\n            save_args: Save arguments should be specified in accordance with\n                the built in open function. This can be found at\n                https://docs.python.org/3/library/functions.html#open\n            version: If specified, should be an instance of\n                ``kedro.io.core.Version``. If its ``load`` attribute is\n                None, the latest version will be loaded. If its ``save``\n                attribute is None, save version will be autogenerated.\n        \"\"\"\n        default_save_args = {\"mode\": \"w\"}\n        default_load_args = {\"mode\": \"r\"}\n\n        self._filepath = filepath\n        self._load_args = (\n            {**default_load_args, **load_args}\n            if load_args is not None\n            else default_load_args\n        )\n        self._save_args = (\n            {**default_save_args, **save_args}\n            if save_args is not None\n            else default_save_args\n        )\n        self._version = version\n\n    def _load(self) -> str:\n        load_path = self._get_load_path(self._filepath, self._version)\n        with open(load_path, **self._load_args) as _file:\n            return _file.read()\n\n    def _save(self, data: str) -> None:\n        save_path = Path(self._get_save_path(self._filepath, self._version))\n        save_path.parent.mkdir(parents=True, exist_ok=True)\n        with open(str(save_path), **self._save_args) as _file:\n            _file.write(data)\n\n        load_path = Path(self._get_load_path(self._filepath, self._version))\n        self._check_paths_consistency(\n            str(load_path.absolute()), str(save_path.absolute())\n        )\n\n    def _exists(self) -> bool:\n        try:\n            path = self._get_load_path(self._filepath, self._version)\n        except DataSetError:\n            return False\n        return Path(path).is_file()\n", "path": "kedro/io/text_local.py"}], "after_files": [{"content": "# Copyright 2018-2019 QuantumBlack Visual Analytics Limited\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND\n# NONINFRINGEMENT. IN NO EVENT WILL THE LICENSOR OR OTHER CONTRIBUTORS\n# BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN\n# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN\n# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n#\n# The QuantumBlack Visual Analytics Limited (\u201cQuantumBlack\u201d) name and logo\n# (either separately or in combination, \u201cQuantumBlack Trademarks\u201d) are\n# trademarks of QuantumBlack. The License does not grant you any right or\n# license to the QuantumBlack Trademarks. You may not use the QuantumBlack\n# Trademarks or any confusingly similar mark as a trademark for your product,\n#     or use the QuantumBlack Trademarks in any other manner that might cause\n# confusion in the marketplace, including but not limited to in advertising,\n# on websites, or on software.\n#\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"``TextLocalDataSet`` loads and saves data to a local text file. The data is\naccessed text data using the python open function.\n\"\"\"\nimport os\nfrom pathlib import Path\nfrom typing import Any, Dict\n\nfrom kedro.io import AbstractDataSet\nfrom kedro.io.core import DataSetError, FilepathVersionMixIn, Version\n\n\nclass TextLocalDataSet(AbstractDataSet, FilepathVersionMixIn):\n    \"\"\"``TextLocalDataSet`` loads and saves unstructured text files.\n\n    Example:\n    ::\n\n        >>> from kedro.io import TextLocalDataSet\n        >>>\n        >>> string_to_write = \"This will go in a file.\"\n        >>>\n        >>> data_set = TextLocalDataSet(filepath=\"docs/new_documentation.md\")\n        >>> data_set.save(string_to_write)\n        >>> reloaded = data_set.load()\n    \"\"\"\n\n    def _describe(self) -> Dict[str, Any]:\n        return dict(\n            filepath=self._filepath,\n            load_args=self._load_args,\n            save_args=self._save_args,\n            version=self._version,\n        )\n\n    def __init__(\n        self,\n        filepath: str,\n        load_args: Dict[str, Any] = None,\n        save_args: Dict[str, Any] = None,\n        version: Version = None,\n    ) -> None:\n        \"\"\"Creates a new instance of ``TextFile``.\n\n        Args:\n            filepath: path to a text file.\n            load_args: Load arguments should be specified in accordance with\n                the built in open function. This can be found at\n                https://docs.python.org/3/library/functions.html#open\n            save_args: Save arguments should be specified in accordance with\n                the built in open function. This can be found at\n                https://docs.python.org/3/library/functions.html#open\n            version: If specified, should be an instance of\n                ``kedro.io.core.Version``. If its ``load`` attribute is\n                None, the latest version will be loaded. If its ``save``\n                attribute is None, save version will be autogenerated.\n        \"\"\"\n        default_save_args = {\"mode\": \"w\"}\n        default_load_args = {\"mode\": \"r\"}\n\n        self._filepath = os.path.expanduser(filepath)\n        self._load_args = (\n            {**default_load_args, **load_args}\n            if load_args is not None\n            else default_load_args\n        )\n        self._save_args = (\n            {**default_save_args, **save_args}\n            if save_args is not None\n            else default_save_args\n        )\n        self._version = version\n\n    def _load(self) -> str:\n        load_path = self._get_load_path(self._filepath, self._version)\n        with open(load_path, **self._load_args) as _file:\n            return _file.read()\n\n    def _save(self, data: str) -> None:\n        save_path = Path(self._get_save_path(self._filepath, self._version))\n        save_path.parent.mkdir(parents=True, exist_ok=True)\n        with open(str(save_path), **self._save_args) as _file:\n            _file.write(data)\n\n        load_path = Path(self._get_load_path(self._filepath, self._version))\n        self._check_paths_consistency(\n            str(load_path.absolute()), str(save_path.absolute())\n        )\n\n    def _exists(self) -> bool:\n        try:\n            path = self._get_load_path(self._filepath, self._version)\n        except DataSetError:\n            return False\n        return Path(path).is_file()\n", "path": "kedro/io/text_local.py"}]}