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

fix: Support parsing inline-table format of Poetry dependency spec #71

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

rlad78
Copy link
Contributor

@rlad78 rlad78 commented May 2, 2024

Suggested fix for #70. This allows for the Nautobot module dependency defined in pyproject.toml to be parsed successfully both in its string form and its inline-table form.

If a user wants extras included with the Nautobot dependency, such as "napalm" or "remote_storage", they will appear in pyproject.toml like so:

nautobot = {version = "2.1.1", extras = ["napalm"]}

toml.load will represent this as a dict-like object. We can try to parse it as a dict first, then fall back to parsing it as a string. As far as I know, these should be the only two forms the version value will come in for most use cases. Multiple constraints bring a list-of-dicts form as well, but I'd imagine that's more of a fringe case.


I would also advise considering the possibility of users supplying one of the different possible version strings. For example, if a user wants to add the 'napalm' extra to their Nautobot dependency, they would most likely do so with the poetry add command:

poetry add nautobot[napalm]

Since no version is specified, Poetry defaults to setting the version string to ^(current version), i.e. ^2.2.2. That caret is going to throw a wrench in Docker's rendering of the Nautobot image URL:

ARG NAUTOBOT_VERSION
ARG PYTHON_VER
FROM ghcr.io/nautobot/nautobot:${NAUTOBOT_VERSION}-py${PYTHON_VER} as nautobot-base

The resolution for this comes down to the project's preference. If you want to constrain the dependency versioning to only using a static version, I think raising a warning to the user would suffice. Otherwise, you'd have to tackle the less trivial task of parsing poetry.lock for the resolved Nautobot module version.

@rlad78 rlad78 requested a review from jvanderaa as a code owner May 2, 2024 11:59
Copy link
Contributor

@jdrew82 jdrew82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jdrew82 jdrew82 merged commit 14b88df into nautobot:main Oct 3, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants