We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Make poetry version plugin to update the pyproject.toml as well not just the build
/kind bug

**What steps did you take and what happened:**
[A clear and concise description of what the bug is.]
Currently the poetry plugin updates the version during the build, install phases but does not update the pyproject.toml
This makes it harder to easily decipher the version of the package.

**What did you expect to happen:**
Running poetry build or install should set the version of the package in pyproject.toml



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py`
Content:
```
1 import ast
2 import subprocess
3 from pathlib import Path
4 from typing import Any, Dict, Optional
5 
6 from cleo.io.io import IO
7 from poetry.plugins.plugin import Plugin
8 from poetry.poetry import Poetry
9 from poetry.core.utils.helpers import module_name
10 
11 
12 class VersionPlugin(Plugin):  # type: ignore
13     def activate(self, poetry: Poetry, io: IO) -> None:
14         poetry_version_config: Optional[Dict[str, Any]] = poetry.pyproject.data.get(
15             "tool", {}
16         ).get("poetry-version-plugin")
17         if poetry_version_config is None:
18             return
19         version_source = poetry_version_config.get("source")
20         version_file_path = poetry_version_config.get("file_path")
21         if not version_source:
22             message = (
23                 "<b>poetry-version-plugin</b>: No <b>source</b> configuration found in "
24                 "[tool.poetry-version-plugin] in pyproject.toml, not extracting "
25                 "dynamic version"
26             )
27             io.write_error_line(message)
28             raise RuntimeError(message)
29 
30         # Update version using file
31         if version_source == "file" and version_file_path:
32             with open(version_file_path, "r") as version_file:
33                 version = version_file.read().strip()
34                 poetry.package._set_version(version)
35                 io.write_line(
36                     "<b>poetry-version-plugin</b>: New package "
37                     "version is updated from given file "
38                     f"version is: <b>{version}</b>"
39                 )
40 
41         if version_source == "init":
42             packages = poetry.local_config.get("packages")
43             if packages:
44                 if len(packages) == 1:
45                     package_name = packages[0]["include"]
46                 else:
47                     message = (
48                         "<b>poetry-version-plugin</b>: More than one package set, "
49                         "cannot extract dynamic version"
50                     )
51                     io.write_error_line(message)
52                     raise RuntimeError(message)
53             else:
54                 package_name = module_name(poetry.package.name)
55             init_path = Path(package_name) / "__init__.py"
56             if not init_path.is_file():
57                 message = (
58                     "<b>poetry-version-plugin</b>: __init__.py file not found at "
59                     f"{init_path} cannot extract dynamic version"
60                 )
61                 io.write_error_line(message)
62                 raise RuntimeError(message)
63             else:
64                 io.write_line(
65                     "<b>poetry-version-plugin</b>: Using __init__.py file at "
66                     f"{init_path} for dynamic version"
67                 )
68             tree = ast.parse(init_path.read_text())
69             for el in tree.body:
70                 if isinstance(el, ast.Assign):
71                     if len(el.targets) == 1:
72                         target = el.targets[0]
73                         if isinstance(target, ast.Name):
74                             if target.id == "__version__":
75                                 value_node = el.value
76                                 if isinstance(value_node, ast.Constant):
77                                     version = value_node.value
78                                 elif isinstance(value_node, ast.Str):
79                                     version = value_node.s
80                                 else:  # pragma: nocover
81                                     # This is actually covered by tests, but can't be
82                                     # reported by Coverage
83                                     # Ref: https://github.com/nedbat/coveragepy/issues/198
84                                     continue
85                                 io.write_line(
86                                     "<b>poetry-version-plugin</b>: Setting package "
87                                     "dynamic version to __version__ "
88                                     f"variable from __init__.py: <b>{version}</b>"
89                                 )
90                                 poetry.package._set_version(version)
91                                 return
92             message = (
93                 "<b>poetry-version-plugin</b>: No valid __version__ variable found "
94                 "in __init__.py, cannot extract dynamic version"
95             )
96             io.write_error_line(message)
97             raise RuntimeError(message)
98         elif version_source == "git-tag":
99             result = subprocess.run(
100                 ["git", "describe", "--exact-match", "--tags", "HEAD"],
101                 stdin=subprocess.PIPE,
102                 stdout=subprocess.PIPE,
103                 universal_newlines=True,
104             )
105             if result.returncode == 0:
106                 tag = result.stdout.strip()
107                 io.write_line(
108                     "<b>poetry-version-plugin</b>: Git tag found, setting "
109                     f"dynamic version to: {tag}"
110                 )
111                 poetry.package._set_version(tag)
112                 return
113             else:
114                 message = (
115                     "<b>poetry-version-plugin</b>: No Git tag found, not "
116                     "extracting dynamic version"
117                 )
118                 io.write_error_line(message)
119                 raise RuntimeError(message)
120
```
--- 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()

```

diff --git a/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py b/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py
--- a/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py
+++ b/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py
@@ -37,6 +37,13 @@
                     "version is updated from given file "
                     f"version is: <b>{version}</b>"
                 )
+                content: dict[str, Any] = poetry.file.read()
+                poetry_content = content["tool"]["poetry"]
+                poetry_content["version"] = version
+                poetry.file.write(content)
+                io.write_line(
+                    "<b>poetry-version-plugin</b>: New version updated in toml file"
+                )
 
         if version_source == "init":
             packages = poetry.local_config.get("packages")

{"golden_diff": "diff --git a/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py b/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py\n--- a/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py\n+++ b/python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py\n@@ -37,6 +37,13 @@\n                     \"version is updated from given file \"\n                     f\"version is: <b>{version}</b>\"\n                 )\n+                content: dict[str, Any] = poetry.file.read()\n+                poetry_content = content[\"tool\"][\"poetry\"]\n+                poetry_content[\"version\"] = version\n+                poetry.file.write(content)\n+                io.write_line(\n+                    \"<b>poetry-version-plugin</b>: New version updated in toml file\"\n+                )\n \n         if version_source == \"init\":\n             packages = poetry.local_config.get(\"packages\")\n", "issue": "Make poetry version plugin to update the pyproject.toml as well not just the build\n/kind bug\r\n\r\n**What steps did you take and what happened:**\r\n[A clear and concise description of what the bug is.]\r\nCurrently the poetry plugin updates the version during the build, install phases but does not update the pyproject.toml\r\nThis makes it harder to easily decipher the version of the package.\r\n\r\n**What did you expect to happen:**\r\nRunning poetry build or install should set the version of the package in pyproject.toml\r\n\r\n\n", "before_files": [{"content": "import ast\nimport subprocess\nfrom pathlib import Path\nfrom typing import Any, Dict, Optional\n\nfrom cleo.io.io import IO\nfrom poetry.plugins.plugin import Plugin\nfrom poetry.poetry import Poetry\nfrom poetry.core.utils.helpers import module_name\n\n\nclass VersionPlugin(Plugin):  # type: ignore\n    def activate(self, poetry: Poetry, io: IO) -> None:\n        poetry_version_config: Optional[Dict[str, Any]] = poetry.pyproject.data.get(\n            \"tool\", {}\n        ).get(\"poetry-version-plugin\")\n        if poetry_version_config is None:\n            return\n        version_source = poetry_version_config.get(\"source\")\n        version_file_path = poetry_version_config.get(\"file_path\")\n        if not version_source:\n            message = (\n                \"<b>poetry-version-plugin</b>: No <b>source</b> configuration found in \"\n                \"[tool.poetry-version-plugin] in pyproject.toml, not extracting \"\n                \"dynamic version\"\n            )\n            io.write_error_line(message)\n            raise RuntimeError(message)\n\n        # Update version using file\n        if version_source == \"file\" and version_file_path:\n            with open(version_file_path, \"r\") as version_file:\n                version = version_file.read().strip()\n                poetry.package._set_version(version)\n                io.write_line(\n                    \"<b>poetry-version-plugin</b>: New package \"\n                    \"version is updated from given file \"\n                    f\"version is: <b>{version}</b>\"\n                )\n\n        if version_source == \"init\":\n            packages = poetry.local_config.get(\"packages\")\n            if packages:\n                if len(packages) == 1:\n                    package_name = packages[0][\"include\"]\n                else:\n                    message = (\n                        \"<b>poetry-version-plugin</b>: More than one package set, \"\n                        \"cannot extract dynamic version\"\n                    )\n                    io.write_error_line(message)\n                    raise RuntimeError(message)\n            else:\n                package_name = module_name(poetry.package.name)\n            init_path = Path(package_name) / \"__init__.py\"\n            if not init_path.is_file():\n                message = (\n                    \"<b>poetry-version-plugin</b>: __init__.py file not found at \"\n                    f\"{init_path} cannot extract dynamic version\"\n                )\n                io.write_error_line(message)\n                raise RuntimeError(message)\n            else:\n                io.write_line(\n                    \"<b>poetry-version-plugin</b>: Using __init__.py file at \"\n                    f\"{init_path} for dynamic version\"\n                )\n            tree = ast.parse(init_path.read_text())\n            for el in tree.body:\n                if isinstance(el, ast.Assign):\n                    if len(el.targets) == 1:\n                        target = el.targets[0]\n                        if isinstance(target, ast.Name):\n                            if target.id == \"__version__\":\n                                value_node = el.value\n                                if isinstance(value_node, ast.Constant):\n                                    version = value_node.value\n                                elif isinstance(value_node, ast.Str):\n                                    version = value_node.s\n                                else:  # pragma: nocover\n                                    # This is actually covered by tests, but can't be\n                                    # reported by Coverage\n                                    # Ref: https://github.com/nedbat/coveragepy/issues/198\n                                    continue\n                                io.write_line(\n                                    \"<b>poetry-version-plugin</b>: Setting package \"\n                                    \"dynamic version to __version__ \"\n                                    f\"variable from __init__.py: <b>{version}</b>\"\n                                )\n                                poetry.package._set_version(version)\n                                return\n            message = (\n                \"<b>poetry-version-plugin</b>: No valid __version__ variable found \"\n                \"in __init__.py, cannot extract dynamic version\"\n            )\n            io.write_error_line(message)\n            raise RuntimeError(message)\n        elif version_source == \"git-tag\":\n            result = subprocess.run(\n                [\"git\", \"describe\", \"--exact-match\", \"--tags\", \"HEAD\"],\n                stdin=subprocess.PIPE,\n                stdout=subprocess.PIPE,\n                universal_newlines=True,\n            )\n            if result.returncode == 0:\n                tag = result.stdout.strip()\n                io.write_line(\n                    \"<b>poetry-version-plugin</b>: Git tag found, setting \"\n                    f\"dynamic version to: {tag}\"\n                )\n                poetry.package._set_version(tag)\n                return\n            else:\n                message = (\n                    \"<b>poetry-version-plugin</b>: No Git tag found, not \"\n                    \"extracting dynamic version\"\n                )\n                io.write_error_line(message)\n                raise RuntimeError(message)\n", "path": "python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py"}], "after_files": [{"content": "import ast\nimport subprocess\nfrom pathlib import Path\nfrom typing import Any, Dict, Optional\n\nfrom cleo.io.io import IO\nfrom poetry.plugins.plugin import Plugin\nfrom poetry.poetry import Poetry\nfrom poetry.core.utils.helpers import module_name\n\n\nclass VersionPlugin(Plugin):  # type: ignore\n    def activate(self, poetry: Poetry, io: IO) -> None:\n        poetry_version_config: Optional[Dict[str, Any]] = poetry.pyproject.data.get(\n            \"tool\", {}\n        ).get(\"poetry-version-plugin\")\n        if poetry_version_config is None:\n            return\n        version_source = poetry_version_config.get(\"source\")\n        version_file_path = poetry_version_config.get(\"file_path\")\n        if not version_source:\n            message = (\n                \"<b>poetry-version-plugin</b>: No <b>source</b> configuration found in \"\n                \"[tool.poetry-version-plugin] in pyproject.toml, not extracting \"\n                \"dynamic version\"\n            )\n            io.write_error_line(message)\n            raise RuntimeError(message)\n\n        # Update version using file\n        if version_source == \"file\" and version_file_path:\n            with open(version_file_path, \"r\") as version_file:\n                version = version_file.read().strip()\n                poetry.package._set_version(version)\n                io.write_line(\n                    \"<b>poetry-version-plugin</b>: New package \"\n                    \"version is updated from given file \"\n                    f\"version is: <b>{version}</b>\"\n                )\n                content: dict[str, Any] = poetry.file.read()\n                poetry_content = content[\"tool\"][\"poetry\"]\n                poetry_content[\"version\"] = version\n                poetry.file.write(content)\n                io.write_line(\n                    \"<b>poetry-version-plugin</b>: New version updated in toml file\"\n                )\n\n        if version_source == \"init\":\n            packages = poetry.local_config.get(\"packages\")\n            if packages:\n                if len(packages) == 1:\n                    package_name = packages[0][\"include\"]\n                else:\n                    message = (\n                        \"<b>poetry-version-plugin</b>: More than one package set, \"\n                        \"cannot extract dynamic version\"\n                    )\n                    io.write_error_line(message)\n                    raise RuntimeError(message)\n            else:\n                package_name = module_name(poetry.package.name)\n            init_path = Path(package_name) / \"__init__.py\"\n            if not init_path.is_file():\n                message = (\n                    \"<b>poetry-version-plugin</b>: __init__.py file not found at \"\n                    f\"{init_path} cannot extract dynamic version\"\n                )\n                io.write_error_line(message)\n                raise RuntimeError(message)\n            else:\n                io.write_line(\n                    \"<b>poetry-version-plugin</b>: Using __init__.py file at \"\n                    f\"{init_path} for dynamic version\"\n                )\n            tree = ast.parse(init_path.read_text())\n            for el in tree.body:\n                if isinstance(el, ast.Assign):\n                    if len(el.targets) == 1:\n                        target = el.targets[0]\n                        if isinstance(target, ast.Name):\n                            if target.id == \"__version__\":\n                                value_node = el.value\n                                if isinstance(value_node, ast.Constant):\n                                    version = value_node.value\n                                elif isinstance(value_node, ast.Str):\n                                    version = value_node.s\n                                else:  # pragma: nocover\n                                    # This is actually covered by tests, but can't be\n                                    # reported by Coverage\n                                    # Ref: https://github.com/nedbat/coveragepy/issues/198\n                                    continue\n                                io.write_line(\n                                    \"<b>poetry-version-plugin</b>: Setting package \"\n                                    \"dynamic version to __version__ \"\n                                    f\"variable from __init__.py: <b>{version}</b>\"\n                                )\n                                poetry.package._set_version(version)\n                                return\n            message = (\n                \"<b>poetry-version-plugin</b>: No valid __version__ variable found \"\n                \"in __init__.py, cannot extract dynamic version\"\n            )\n            io.write_error_line(message)\n            raise RuntimeError(message)\n        elif version_source == \"git-tag\":\n            result = subprocess.run(\n                [\"git\", \"describe\", \"--exact-match\", \"--tags\", \"HEAD\"],\n                stdin=subprocess.PIPE,\n                stdout=subprocess.PIPE,\n                universal_newlines=True,\n            )\n            if result.returncode == 0:\n                tag = result.stdout.strip()\n                io.write_line(\n                    \"<b>poetry-version-plugin</b>: Git tag found, setting \"\n                    f\"dynamic version to: {tag}\"\n                )\n                poetry.package._set_version(tag)\n                return\n            else:\n                message = (\n                    \"<b>poetry-version-plugin</b>: No Git tag found, not \"\n                    \"extracting dynamic version\"\n                )\n                io.write_error_line(message)\n                raise RuntimeError(message)\n", "path": "python/plugin/poetry-version-plugin/poetry_version_plugin/plugin.py"}]}