6363
6464# this package
6565from pyproject_parser .classes import License , Readme , _NormalisedName
66- from pyproject_parser .parsers import BuildSystemParser , PEP621Parser
66+ from pyproject_parser .parsers import BuildSystemParser , DependencyGroupsParser , PEP621Parser
6767from pyproject_parser .type_hints import ( # noqa: F401
6868Author ,
6969BuildSystemDict ,
7070ContentTypes ,
71+ DependencyGroupsDict ,
7172ProjectDict ,
7273_PyProjectAsTomlDict
7374)
@@ -239,23 +240,29 @@ class PyProject:
239240
240241:param build_system:
241242
242- .. autosummary-widths:: 23/64
243+ .. versionchanged:: 0.13.0 Added ``dependency_groups`` and ``dependency_groups_table_parser`` properties.
244+
245+ .. autosummary-widths:: 4/10
243246
244247.. autoclasssumm:: PyProject
245248:autosummary-sections: Methods
246- :autosummary-exclude-members: __ge__,__gt__,__le__,__lt__,__ne__,__init__
249+ :autosummary-exclude-members: __ge__,__gt__,__le__,__lt__,__ne__,__init__,__repr__,__eq__
247250
248251.. latex:clearpage::
249252
253+ .. autosummary-widths:: 1/2
254+
250255.. autoclasssumm:: PyProject
251256:autosummary-sections: Attributes
252257
253- .. latex:vspace:: 10px
254258"""
255259
256260#: Represents the :pep:`build-system table <518#build-system-table>` defined in :pep:`517` and :pep:`518`.
257261build_system : Optional [BuildSystemDict ] = attr .ib (default = None )
258262
263+ #: Represents the :pep:`dependency groups table <735#specification>` defined in :pep:`735`.
264+ dependency_groups : Optional [DependencyGroupsDict ] = attr .ib (default = None )
265+
259266#: Represents the :pep621:`project table <table-name>` defined in :pep:`621`.
260267project : Optional [ProjectDict ] = attr .ib (default = None )
261268
@@ -268,6 +275,14 @@ class PyProject:
268275to parse the :pep:`build-system table <518#build-system-table>` with.
269276"""
270277
278+ dependency_groups_table_parser : ClassVar [DependencyGroupsParser ] = DependencyGroupsParser ()
279+ """
280+ The :class:`~dom_toml.parser.AbstractConfigParser`
281+ to parse the :pep:`dependency groups table <735#specification>` with.
282+
283+ .. versionadded:: 0.13.0
284+ """
285+
271286project_table_parser : ClassVar [PEP621Parser ] = PEP621Parser ()
272287"""
273288The :class:`~dom_toml.parser.AbstractConfigParser`
@@ -313,6 +328,7 @@ def load(
313328keys = set (config .keys ())
314329
315330build_system_table : Optional [BuildSystemDict ] = None
331+ dependency_groups_table : Optional [DependencyGroupsDict ] = None
316332project_table : Optional [ProjectDict ] = None
317333tool_table : Dict [str , Dict [str , Any ]] = {}
318334
@@ -323,6 +339,12 @@ def load(
323339)
324340keys .remove ("build-system" )
325341
342+ if "dependency-groups" in config :
343+ dependency_groups_table = cls .dependency_groups_table_parser .parse (
344+ config ["dependency-groups" ], set_defaults = set_defaults
345+ )
346+ keys .remove ("dependency-groups" )
347+
326348if "project" in config :
327349project_table = cls .project_table_parser .parse (config ["project" ], set_defaults = set_defaults )
328350keys .remove ("project" )
@@ -336,7 +358,7 @@ def load(
336358tool_table [tool_name ] = cls .tool_parsers [tool_name ].parse (tool_subtable )
337359
338360if keys :
339- allowed_top_level = ("build-system" , "project" , "tool" )
361+ allowed_top_level = ("build-system" , "dependency-groups" , " project" , "tool" )
340362
341363for top_level_key in sorted (keys ):
342364if top_level_key in allowed_top_level :
@@ -355,6 +377,7 @@ def load(
355377
356378return cls (
357379build_system = build_system_table ,
380+ dependency_groups = dependency_groups_table ,
358381project = project_table ,
359382tool = tool_table ,
360383)
@@ -375,6 +398,7 @@ def dumps(
375398"build-system" : self .build_system ,
376399"project" : self .project ,
377400"tool" : self .tool ,
401+ "dependency-groups" : self .dependency_groups ,
378402}
379403
380404if toml_dict ["project" ] is not None :
@@ -478,6 +502,8 @@ def from_dict(cls: Type[_PP], d: Mapping[str, Any]) -> _PP:
478502for key , value in d .items ():
479503if key == "build-system" :
480504key = "build_system"
505+ elif key == "dependency-groups" :
506+ key = "dependency_groups"
481507
482508kwargs [key ] = value
483509
@@ -494,4 +520,5 @@ def to_dict(self) -> MutableMapping[str, Any]:
494520"build_system" : self .build_system ,
495521"project" : self .project ,
496522"tool" : self .tool ,
523+ "dependency_groups" : self .dependency_groups ,
497524}
0 commit comments