File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed
fixtures/project_with_invalid_dependency_groups Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -620,6 +620,14 @@ def validate(
620620 ]
621621 result ["errors" ] += tool_poetry_validation_errors
622622
623+ dependency_groups = toml_data .get ("dependency-groups" )
624+ if dependency_groups is not None :
625+ dependency_groups_validation_errors = [
626+ e .replace ("data" , "dependency-groups" )
627+ for e in validate_object (dependency_groups , "dependency-groups-schema" )
628+ ]
629+ result ["errors" ] += dependency_groups_validation_errors
630+
623631 # Check for required fields if package mode.
624632 # In non-package mode, there are no required fields.
625633 package_mode = tool_poetry .get ("package-mode" , True )
Original file line number Diff line number Diff line change 1+ {
2+ "$schema" : " http://json-schema.org/draft-07/schema#" ,
3+ "name" : " dependency-groups" ,
4+ "type" : " object" ,
5+ "additionalProperties" : {
6+ "title" : " Dependency group requirements" ,
7+ "type" : " array" ,
8+ "items" : {
9+ "type" : " string"
10+ },
11+ "examples" : [
12+ [
13+ " attrs" ,
14+ " requests ~= 2.28"
15+ ]
16+ ]
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ [dependency-groups ]
2+ testing = [
3+ " pytest" ,
4+ [" pytest-cov" , {version = " >=4.0" }],
5+ ]
6+
7+ [tool .poetry ]
8+ name = " my-package"
9+ version = " 1.2.3"
10+ description = " Some description."
11+ authors = [" Awesome Hacker <awesome@hacker.io>" ]
12+ license = " MIT"
13+
14+ [tool .poetry .dependencies ]
15+
16+ [tool .poetry .extras ]
Original file line number Diff line number Diff line change @@ -869,6 +869,21 @@ def test_create_poetry_with_invalid_dev_dependencies(caplog: LogCaptureFixture)
869869 assert any ("dev" in r .groups for r in poetry .package .all_requires )
870870
871871
872+ @pytest .mark .parametrize ("with_groups" , [True , False ])
873+ def test_create_poetry_with_invalid_dependency_groups (with_groups : bool ) -> None :
874+ with pytest .raises (RuntimeError ) as e :
875+ _ = Factory ().create_poetry (
876+ fixtures_dir / "project_with_invalid_dependency_groups" ,
877+ with_groups = with_groups ,
878+ )
879+
880+ expected = """\
881+ The Poetry configuration is invalid:
882+ - dependency-groups.testing[1] must be string
883+ """
884+ assert str (e .value ) == expected
885+
886+
872887def test_create_poetry_with_groups_and_legacy_dev (caplog : LogCaptureFixture ) -> None :
873888 assert not caplog .records
874889
You can’t perform that action at this time.
0 commit comments