Don't allow non-string email in authors (#8520)

This commit is contained in:
konsti 2024-10-24 17:25:52 +02:00 committed by GitHub
parent a642676236
commit 6caeb6aba1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 30 deletions

View file

@ -605,14 +605,19 @@ enum License {
/// The entry is derived from the email format of `John Doe <john.doe@example.net>`. You need to /// The entry is derived from the email format of `John Doe <john.doe@example.net>`. You need to
/// provide at least name or email. /// provide at least name or email.
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
#[serde(untagged, expecting = "a table with 'name' and/or 'email' keys")] // deny_unknown_fields prevents using the name field when the email is not a string.
#[serde(
untagged,
deny_unknown_fields,
expecting = "a table with 'name' and/or 'email' keys"
)]
enum Contact { enum Contact {
/// TODO(konsti): RFC 822 validation.
NameEmail { name: String, email: String },
/// TODO(konsti): RFC 822 validation. /// TODO(konsti): RFC 822 validation.
Name { name: String }, Name { name: String },
/// TODO(konsti): RFC 822 validation. /// TODO(konsti): RFC 822 validation.
Email { email: String }, Email { email: String },
/// TODO(konsti): RFC 822 validation.
NameEmail { name: String, email: String },
} }
/// The `[build-system]` section of a pyproject.toml as specified in PEP 517. /// The `[build-system]` section of a pyproject.toml as specified in PEP 517.

View file

@ -104,35 +104,37 @@ fn valid() {
let metadata = pyproject_toml.to_metadata(temp_dir.path()).unwrap(); let metadata = pyproject_toml.to_metadata(temp_dir.path()).unwrap();
assert_snapshot!(metadata.core_metadata_format(), @r###" assert_snapshot!(metadata.core_metadata_format(), @r###"
Metadata-Version: 2.3 Metadata-Version: 2.3
Name: hello-world Name: hello-world
Version: 0.1.0 Version: 0.1.0
Summary: A Python package Summary: A Python package
Keywords: demo,example,package Keywords: demo,example,package
Author: Ferris the crab Author: Ferris the crab
License: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, Author-email: Ferris the crab <ferris@rustacean.net>
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A License: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
Classifier: Development Status :: 6 - Mature OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Classifier: License :: OSI Approved :: MIT License Classifier: Development Status :: 6 - Mature
Classifier: License :: OSI Approved :: Apache Software License Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python Classifier: License :: OSI Approved :: Apache Software License
Requires-Dist: flask>=3,<4 Classifier: Programming Language :: Python
Requires-Dist: sqlalchemy[asyncio]>=2.0.35,<3 Requires-Dist: flask>=3,<4
Maintainer: Konsti Requires-Dist: sqlalchemy[asyncio]>=2.0.35,<3
Project-URL: Homepage, https://github.com/astral-sh/uv Maintainer: Konsti
Project-URL: Repository, https://astral.sh Maintainer-email: Konsti <konstin@mailbox.org>
Provides-Extra: mysql Project-URL: Homepage, https://github.com/astral-sh/uv
Provides-Extra: postgres Project-URL: Repository, https://astral.sh
Description-Content-Type: text/markdown Provides-Extra: mysql
Provides-Extra: postgres
Description-Content-Type: text/markdown
# Foo # Foo
This is the foo library. This is the foo library.
"###); "###);
assert_snapshot!(pyproject_toml.to_entry_points().unwrap().unwrap(), @r###" assert_snapshot!(pyproject_toml.to_entry_points().unwrap().unwrap(), @r###"
[console_scripts] [console_scripts]