This PR splits some datastructures that we use into a TOML specific representation and a data model representation. This is to allow expressing syntactically correct behavior in TOML and explicitly converting that into a semantically correct data model.
This makes it easier to generate proper error messages but removing a lot of the typing cruft to facilitate those for the rest of the application. An example is that previous the project name was optional because it is not required when using pyproject.toml files. However, the rest of the code had to unwrap that name because a project does require a name. After merging this PR these things become easier because the TomlWorkspace might contain an optional value but the Workspace that is used after the conversion does not have an optional value.
We can also move a large part of the validation logic to this conversion phase. But thats left up to the reader. 👍
The main driver for this was to be able to start implementing the [package] section. We want to only allow certain top-level keys if other top-level keys are present. This requires validation after parsing to be able to provider proper user feedback.
Implementation
The ParsedManifest was renamed to WorkspaceManifest. The serialization logic that was in place for ParsedManifest has been moved into an exposed struct called TomlManifest. The TomlManifest can be parsed from a toml string and converted to a WorkspaceManifest. The PyProjectManifest contains a TomlManifest and handles the conversion that way.
I also moved most of the already existing Toml* structs into the toml module.
Description
This PR splits some datastructures that we use into a TOML specific representation and a data model representation. This is to allow expressing syntactically correct behavior in TOML and explicitly converting that into a semantically correct data model.
This makes it easier to generate proper error messages but removing a lot of the typing cruft to facilitate those for the rest of the application. An example is that previous the project name was optional because it is not required when using pyproject.toml files. However, the rest of the code had to unwrap that name because a project does require a name. After merging this PR these things become easier because the
TomlWorkspace
might contain an optional value but theWorkspace
that is used after the conversion does not have an optional value.We can also move a large part of the validation logic to this conversion phase. But thats left up to the reader. 👍
The main driver for this was to be able to start implementing the
[package]
section. We want to only allow certain top-level keys if other top-level keys are present. This requires validation after parsing to be able to provider proper user feedback.Implementation
The
ParsedManifest
was renamed toWorkspaceManifest
. The serialization logic that was in place forParsedManifest
has been moved into an exposed struct calledTomlManifest
. TheTomlManifest
can be parsed from a toml string and converted to aWorkspaceManifest
. ThePyProjectManifest
contains aTomlManifest
and handles the conversion that way.I also moved most of the already existing
Toml*
structs into thetoml
module.