Skip to content

Commit 6974e7a

Browse files
committed
fix: Fix handling of "format" in package includes initialization
Ensure that "format" is always processed as a list when initializing package includes. If not explicit set default to sdist and wheel.
1 parent 61081dd commit 6974e7a

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/poetry/core/factory.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ def _configure_package_poetry_specifics(
376376
package.exclude = exclude
377377

378378
if packages := tool_poetry.get("packages"):
379+
for p in packages:
380+
if "format" in p:
381+
if not isinstance(p["format"], list):
382+
p["format"] = [p["format"]]
383+
else:
384+
p["format"] = ["sdist", "wheel"]
385+
379386
package.packages = packages
380387

381388
@classmethod

tests/test_factory.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,27 @@ def test_create_poetry_with_packages_and_includes() -> None:
354354
package = poetry.package
355355

356356
assert package.packages == [
357-
{"include": "extra_dir/**/*.py"},
358-
{"include": "extra_dir/**/*.py"},
359-
{"include": "my_module.py"},
360-
{"include": "package_with_include"},
361-
{"include": "tests", "format": "sdist"},
357+
{"include": "extra_dir/**/*.py", "format": ["sdist", "wheel"]},
358+
{"include": "extra_dir/**/*.py", "format": ["sdist", "wheel"]},
359+
{"include": "my_module.py", "format": ["sdist", "wheel"]},
360+
{"include": "package_with_include", "format": ["sdist", "wheel"]},
361+
{
362+
"include": "tests",
363+
"format": ["sdist"],
364+
},
362365
{"include": "for_wheel_only", "format": ["wheel"]},
363-
{"include": "src_package", "from": "src"},
364-
{"include": "from_to", "from": "etc", "to": "target_from_to"},
365-
{"include": "my_module_to.py", "to": "target_module"},
366+
{"include": "src_package", "from": "src", "format": ["sdist", "wheel"]},
367+
{
368+
"include": "from_to",
369+
"from": "etc",
370+
"to": "target_from_to",
371+
"format": ["sdist", "wheel"],
372+
},
373+
{
374+
"include": "my_module_to.py",
375+
"to": "target_module",
376+
"format": ["sdist", "wheel"],
377+
},
366378
]
367379

368380
assert package.include == [

0 commit comments

Comments
 (0)