Skip to content

Commit

Permalink
package category is not useful (#7637)
Browse files Browse the repository at this point in the history
package.category doesn't make a lot of sense in the richer world of dependency groups.

The only use that is made of the category in poetry and poetry-core is that it is written to and read back from the lockfile. But no use is made of that information.
  • Loading branch information
dimbleby authored Apr 18, 2023
1 parent ec35b83 commit a770b3a
Show file tree
Hide file tree
Showing 47 changed files with 5 additions and 454 deletions.
2 changes: 0 additions & 2 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def locked_repository(self) -> LockfileRepository:
source_subdirectory=source.get("subdirectory"),
)
package.description = info.get("description", "")
package.category = info.get("category", "main")
package.optional = info["optional"]
metadata = cast("dict[str, Any]", lock_data["metadata"])

Expand Down Expand Up @@ -425,7 +424,6 @@ def _dump_package(self, package: Package) -> dict[str, Any]:
"name": package.pretty_name,
"version": package.pretty_version,
"description": package.description or "",
"category": package.category,
"optional": package.optional,
"python-versions": package.python_versions,
"files": sorted(
Expand Down
7 changes: 0 additions & 7 deletions src/poetry/puzzle/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from typing import Tuple
from typing import TypeVar

from poetry.core.packages.dependency_group import MAIN_GROUP

from poetry.mixology import resolve_version
from poetry.mixology.failure import SolveFailure
from poetry.puzzle.exceptions import OverrideNeeded
Expand Down Expand Up @@ -273,11 +271,9 @@ def __init__(
self.depth = -1

if not previous:
self.category = "dev"
self.groups: frozenset[str] = frozenset()
self.optional = True
elif dep:
self.category = "main" if MAIN_GROUP in dep.groups else "dev"
self.groups = dep.groups
self.optional = dep.is_optional()
else:
Expand Down Expand Up @@ -327,14 +323,11 @@ def aggregate_package_nodes(nodes: list[PackageNode]) -> tuple[Package, int]:
for node in nodes:
groups.extend(node.groups)

category = "main" if any(MAIN_GROUP in node.groups for node in nodes) else "dev"
optional = all(node.optional for node in nodes)
for node in nodes:
node.depth = depth
node.category = category
node.optional = optional

package.category = category
package.optional = optional

return package, depth
1 change: 0 additions & 1 deletion tests/console/commands/self/test_remove_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def install_plugin(installed: Repository) -> None:
{
"name": "poetry-plugin",
"version": "1.2.3",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
Expand Down
Loading

0 comments on commit a770b3a

Please sign in to comment.