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

Add collection-meta.yaml linter #617

Merged
merged 14 commits into from
Sep 10, 2024
Merged

Conversation

felixfontein
Copy link
Collaborator

@felixfontein felixfontein commented Aug 26, 2024

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+.

src/antsibull/collection_meta_lint.py Show resolved Hide resolved
for collection_name, collection_data in data["collections"].items():
self.data[collection_name] = CollectionMetadata(collection_data)
@staticmethod
def load_from(deps_dir: str | None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def load_from(deps_dir: str | None):
def load_from(deps_dir: str | os.PathLike[str] | None):

Copy link
Collaborator Author

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 :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines 164 to 165
for collection in sorted(remaining_collections):
print(f"collections: No metadata present for {collection}")
Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ooops, yes...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gotmax23
Copy link
Contributor

gotmax23 commented Sep 3, 2024

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.

Comment on lines +63 to +68
else:
if self.reason_text is not None:
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
alias="collection-directory", default=None
)
repository: t.Optional[str] = None
tag_version_regex: t.Optional[str] = None
Copy link
Contributor

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.

for collection_name, collection_data in data["collections"].items():
self.data[collection_name] = CollectionMetadata(collection_data)
@staticmethod
def load_from(deps_dir: StrPath | None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing return type annotation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in dd683e4.

src/antsibull/collection_meta_lint.py Show resolved Hide resolved
src/antsibull/collection_meta_lint.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta_lint.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta_lint.py Outdated Show resolved Hide resolved
Copy link
Contributor

@gotmax23 gotmax23 left a 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_lint.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
src/antsibull/collection_meta.py Outdated Show resolved Hide resolved
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
Copy link
Contributor

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.

Suggested change
redirect_replacement_version: t.Optional[int] = None
redirect_replacement_major_version: t.Optional[int] = None

Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 changed in 6b7271f.

@felixfontein
Copy link
Collaborator Author

Failing CI is caused by CiscoDevNet/intersight-ansible#137.

@gotmax23
Copy link
Contributor

gotmax23 commented Sep 9, 2024

Thanks for working on this and for applying all my feedback

@felixfontein felixfontein merged commit 821fb6d into ansible-community:main Sep 10, 2024
9 checks passed
@felixfontein
Copy link
Collaborator Author

@gotmax23 thanks for reviewing this!

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