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

Requesting metadata proposal #21

Open
henryiii opened this issue Apr 28, 2024 · 0 comments
Open

Requesting metadata proposal #21

henryiii opened this issue Apr 28, 2024 · 0 comments

Comments

@henryiii
Copy link
Contributor

henryiii commented Apr 28, 2024

Some hooks may want to access other's metadata. I think this could be supported in three stages:

First, the hooks could be redesigned to modify an existing dictionary of metadata in place. The new hook signature would be:

def dynamic_metadata(
    metadata: MutableMapping[str, str | dict[str, str | None] | list[str]],
    field: str,
    settings: Mapping[str, object] | None = None,
) -> None:
    "Modify the metadata inplace"

The contents of the metadata dict would include static metadata, and the hook is expected to replace or add field. At this stage, nothing is stated about the order of the hooks run.

Second stage could be to require version be computed before other hooks. I believe this is the current implantation in hatchling, and is the reason for adding this (hatch-fancy-pypi-readme requires the version pre-computed).

The third stage would be to add topological sorting. This would probably be easier to add after Python 3.9 becomes the minimum required version for most backends. A new hook would be added:

def metadata_reqiures(
    field: str,
    settings: Mapping[str, object] | None = None,
) -> list[str]:
    "Return fields needing to be computed first"

And backends should topologically sort before running.

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

No branches or pull requests

1 participant