|
12 | 12 | from packaging.utils import canonicalize_name |
13 | 13 | from poetry.core.packages.dependency import Dependency |
14 | 14 | from poetry.core.packages.dependency_group import MAIN_GROUP |
15 | | -from tomlkit.toml_document import TOMLDocument |
16 | 15 |
|
17 | 16 | from poetry.console.commands.init import InitCommand |
18 | 17 | from poetry.console.commands.installer_command import InstallerCommand |
@@ -148,9 +147,7 @@ def handle(self) -> int: |
148 | 147 | if optional and group != MAIN_GROUP: |
149 | 148 | raise ValueError("You can only add optional dependencies to the main group") |
150 | 149 |
|
151 | | - # tomlkit types are awkward to work with, treat content as a mostly untyped |
152 | | - # dictionary. |
153 | | - content: dict[str, Any] = self.poetry.file.read() |
| 150 | + content = self.poetry.file.read() |
154 | 151 | project_content = content.get("project", table()) |
155 | 152 | poetry_content = content.get("tool", {}).get("poetry", table()) |
156 | 153 | groups_content = content.get("dependency-groups", {}) |
@@ -244,7 +241,7 @@ def handle(self) -> int: |
244 | 241 | assert isinstance(version, str) |
245 | 242 | parse_constraint(version) |
246 | 243 |
|
247 | | - constraint: dict[str, Any] = inline_table() |
| 244 | + constraint = inline_table() |
248 | 245 | for key, value in _constraint.items(): |
249 | 246 | if key == "name": |
250 | 247 | continue |
@@ -331,7 +328,7 @@ def handle(self) -> int: |
331 | 328 |
|
332 | 329 | # create a second constraint for tool.poetry.dependencies with keys |
333 | 330 | # that cannot be stored in the project section |
334 | | - poetry_constraint: dict[str, Any] = inline_table() |
| 331 | + poetry_constraint = inline_table() |
335 | 332 | if not isinstance(constraint, str): |
336 | 333 | for key in ["allow-prereleases", "develop", "source"]: |
337 | 334 | if value := constraint.get(key): |
@@ -413,7 +410,6 @@ def handle(self) -> int: |
413 | 410 | status = self.installer.run() |
414 | 411 |
|
415 | 412 | if status == 0 and not self.option("dry-run"): |
416 | | - assert isinstance(content, TOMLDocument) |
417 | 413 | self.poetry.file.write(content) |
418 | 414 |
|
419 | 415 | return status |
|
0 commit comments