Skip to content

Commit

Permalink
Make DependencyGroups a newtype and bump version
Browse files Browse the repository at this point in the history
This allows implementing methods on it.
  • Loading branch information
konstin committed Oct 13, 2024
1 parent 83f2bf4 commit 3daa40a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyproject-toml"
version = "0.11.0"
version = "0.12.0"
description = "pyproject.toml parser in Rust"
edition = "2021"
license = "MIT"
Expand Down
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.12.0

* Support dependency groups (PEP 735)

## 0.11.0

* Update pep440_rs to 0.6.0
Expand Down
20 changes: 15 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use indexmap::IndexMap;
use pep440_rs::{Version, VersionSpecifiers};
use pep508_rs::Requirement;
use serde::{Deserialize, Serialize};
use std::ops::Deref;

/// The `[build-system]` section of a pyproject.toml as specified in PEP 517
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -43,7 +44,7 @@ pub struct Project {
pub requires_python: Option<VersionSpecifiers>,
/// License
pub license: Option<License>,
/// License Files (PEP 639) - https://peps.python.org/pep-0639/#add-license-files-key
/// License Files (PEP 639) - <https://peps.python.org/pep-0639/#add-license-files-key>
pub license_files: Option<LicenseFiles>,
/// The people or organizations considered to be the "authors" of the project
pub authors: Option<Vec<Contact>>,
Expand Down Expand Up @@ -164,16 +165,25 @@ pub struct Contact {
}

/// The `[dependency-groups]` section of pyproject.toml, as specified in PEP 735
type DependencyGroups = IndexMap<String, Vec<DependencyGroupSpecifier>>;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(transparent)]
pub struct DependencyGroups(pub IndexMap<String, Vec<DependencyGroupSpecifier>>);

impl Deref for DependencyGroups {
type Target = IndexMap<String, Vec<DependencyGroupSpecifier>>;

fn deref(&self) -> &Self::Target {
&self.0
}
}

/// A specifier item in a Dependency Group
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
#[serde(untagged)]
#[serde(rename_all = "kebab-case", untagged)]
pub enum DependencyGroupSpecifier {
/// PEP 508 requirement string
String(Requirement),
/// DependencyGroupInclude
/// Include another dependency group
#[serde(rename_all = "kebab-case")]
Table {
/// The name of the group to include
Expand Down

0 comments on commit 3daa40a

Please sign in to comment.