-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add collection-meta.yaml linter #617
Conversation
src/antsibull/collection_meta.py
Outdated
for collection_name, collection_data in data["collections"].items(): | ||
self.data[collection_name] = CollectionMetadata(collection_data) | ||
@staticmethod | ||
def load_from(deps_dir: str | None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def load_from(deps_dir: str | None): | |
def load_from(deps_dir: str | os.PathLike[str] | None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also use StrPath
here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for collection in sorted(remaining_collections): | ||
print(f"collections: No metadata present for {collection}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, yes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the feedback. I'll try to take a look later today or tomorrow now that I'm back from Labor Day travel. |
else: | ||
if self.reason_text is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this be a single elif
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it can be. But I find it easier to understand to first distinguish between the two cases other
and not other
, and inside these cases checking for specific conditions.
alias="collection-directory", default=None | ||
) | ||
repository: t.Optional[str] = None | ||
tag_version_regex: t.Optional[str] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: pydantic can validate regexes if this is set to t.Optional[re.Pattern]
, but I think the other code still expects a string.
src/antsibull/collection_meta.py
Outdated
for collection_name, collection_data in data["collections"].items(): | ||
self.data[collection_name] = CollectionMetadata(collection_data) | ||
@staticmethod | ||
def load_from(deps_dir: StrPath | None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing return type annotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in dd683e4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more minor things, but this otherwise looks good
src/antsibull/collection_meta.py
Outdated
announce_version: t.Optional[PydanticPypiVersion] = None | ||
new_name: t.Optional[str] = None | ||
discussion: t.Optional[p.HttpUrl] = None | ||
redirect_replacement_version: t.Optional[int] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the key should also have a _major_
in there. It's a different type than the other _version
keys.
redirect_replacement_version: t.Optional[int] = None | |
redirect_replacement_major_version: t.Optional[int] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh, it's only announce_version
that's a full version number. I guess version
could also be changed to major_version
? What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 changed in 6b7271f.
Co-authored-by: Maxwell G <maxwell@gtmx.me>
Co-authored-by: Maxwell G <maxwell@gtmx.me>
Co-authored-by: Maxwell G <maxwell@gtmx.me>
Failing CI is caused by CiscoDevNet/intersight-ansible#137. |
Thanks for working on this and for applying all my feedback |
@gotmax23 thanks for reviewing this! |
Ensures that collection-meta.yaml has the right order, the right structure, and that all kind of conditions are right.
Assumes the format from ansible-community/ansible-build-data#450. That PR also fixes the order.
Note that this makes pydantic 2+ a required dependency, and thus also antsibull-core 3+.