Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata validation API #332

Closed
wants to merge 1 commit into from
Closed

Conversation

VikramJayanthi17
Copy link

As mentioned in #147, there is currently no metadata validation module in pypa/packaging that allows packaging projects such as pip or twine to validate metadata in a standardized way. @di and I built this API to address this problem. The API is based off of @di's and @pfmoore's WIP branches.

Currently the API allows for creation of metadata objects from various formats such RFC822 strings and JSONs and allows for the conversion between these different formats. It doesn't implement the full validation process but creates the structure to add it.

Additionally this doesn't support Python2 because of the sunsetting of Python2 support as well as encoding issues while parsing RFC822 strings using Python2's email parsing modules.
Support for reading metadata from distributions is something we plan to support.

* Basic Metadata API done, need to write tests

* Basic testing completed

* More testing

* extract_pkginfo completed for all file types

* Unresolved description bug

* Parameterized with all metadataformats, added way to extend file type

* WIP: Working on Python2 email parser fix

* Before split. to_rfc822 not working

* Python2 and Python3, not fully working (payload unicode Python2 error)

* Python3 all tests passing

* Updated typing and fixed one test

* Prefix json_form with underscore

* _canonicalize doesn't need to be a classmethod

* Add back special handling of Description

* make self.meta_dict prefixed with _

* Raise NotImplemented for equality instead

* Use 'rfc822' instead of 'pkginfo' or 'pkg_info'

* Don't need to_dict if it supports __iter__

* Simplify missing multi fields

* Raise exception when duplicate descriptions are given

* some linting erros

* Implemented TypedDict, linting failing

* Deleting TypedDict

Co-authored-by: Vikram Jayanthi <vikramjayanthi@google.com>
Co-authored-by: Dustin Ingram <di@users.noreply.github.com>
@pradyunsg
Copy link
Member

FYI: this is failing tests on Windows.

@pradyunsg
Copy link
Member

What's the state of this PR? Is this going to be worked on by author at some point in the future?

@di
Copy link
Sponsor Member

di commented Oct 12, 2020

@pradyunsg Unlikely. Getting this merge-able is on my to-do list, but others can take over here as well if they're interested.

MANIFEST.in Show resolved Hide resolved
@brettcannon
Copy link
Member

One thing to consider is PEP 621, if it gets accepted, will lead to its own need to have a representation of metadata as fed from TOML data. Now I'm assuming that will be via a fromdict() class method for whatever class we have to represent metadata (as well as a asdict() method for writing it back out to TOML). PEP 621 would also lead to some needs to do stuff like updating the dynamic field if something is assigned to.

So I don't know what ramifications PEP 621 will have on the proposed API as that will shift slightly the data model of what metadata can be (e.g. the dynamic field).

@pradyunsg
Copy link
Member

I'd say we make that treating a separate object compared to what we're getting from the METADATA files.

@brettcannon
Copy link
Member

It gets a little tricky, though, if that data is then used to emit METADATA later. So I think there's at least a possibility of translation we should keep in mind in that case.

@pradyunsg
Copy link
Member

Yeaaaa... We'll cross that design bridge when we get to it tho!

@di di mentioned this pull request Dec 3, 2020
@di di mentioned this pull request Jan 5, 2021
Base automatically changed from master to main January 21, 2021 19:20
@brettcannon
Copy link
Member

I'm closing this as stale as c533201 has landed as the way to represent metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants