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

Refactor meta.yaml lint logic #1906

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

ytausch
Copy link
Contributor

@ytausch ytausch commented Apr 5, 2024

Checklist

  • Added a news entry

This builds upon #1900 by refactoring the meta.yaml lints out of the ~700 lines lintify_meta_yaml function, modularizing the lint logic. While doing that, I added early returns, simplified code and fixed smaller issues.

I think a modularized logic like this is a lot more maintainable, but the path forward should definitely be using more Pydantic models for interacting with complex JSON / YAML files.

#1900 needs to be merged first.

- test must be package for imports to work
- import AbstractSet
@ytausch ytausch marked this pull request as ready for review April 5, 2024 17:18
@ytausch ytausch requested a review from a team as a code owner April 5, 2024 17:18
@ytausch
Copy link
Contributor Author

ytausch commented Apr 5, 2024

Cc @0xbe7a

Copy link
Member

@0xbe7a 0xbe7a left a comment

Choose a reason for hiding this comment

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

Is there a list somewhere of all the uses of the conda-smithys public API to determine if we need deprecation warnings for all these methods?

return cls(hints=[hint])


Linter = Callable[[dict, T], LintsHints]
Copy link
Member

Choose a reason for hiding this comment

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

Since every lint is expected to return a LintsHints anyway, why not provide one as an argument and omit the return type. Requiring lint to create an empty LintHints container even if none are returned seems a bit verbose at times

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So you're proposing an intentional side effect? I tried to avoid that with my current solution, although it's more verbose, yes.

Copy link
Member

Choose a reason for hiding this comment

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

Yes

"Use linters_meta_yaml.is_jinja_line instead.",
DeprecationWarning,
)
return linters_meta_yaml.is_jinja_line(line)


def selector_lines(lines):
Copy link
Member

Choose a reason for hiding this comment

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

Are any of these util functions actually used outside of conda-smithy @beckermr? I couldn't find any uses in the conda-forge org outside of this repo. In general, I think we should design a clearly specified public API in the long-term instead of assuming that every public function in this module is a potentially public API. As far as I can tell, other components only use conda_smithy.lint_recipe.main.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1

There are good Python libraries I've seen that prefix private modules and functions with _ to create a clear distinction between public and private API.

@beckermr
Copy link
Member

beckermr commented Apr 7, 2024

Any public method should be assumed to be used. As I said before on another pr, unless we plan to release v4, there can be no api changes.

@beckermr
Copy link
Member

beckermr commented Apr 7, 2024

Also, we should not be introducing any deprecation processes unless core is in agreement on how they work.

@xhochy
Copy link
Member

xhochy commented Apr 7, 2024

Also, we should not be introducing any deprecation processes unless core is in agreement on how they work.

Where should we discuss this? Probably a new issue in this repo?

Still, I'm wondering who the users could be that depend on these functions? I would expect that they are only used inside of conda-forge and thus I would expect that the only thing to do would be to ensure that these functions are no longer used anywhere in our codebase.

@beckermr
Copy link
Member

beckermr commented Apr 7, 2024

Yes a new issue is fine and then on a core call.

We're going to bust something for somebody even if we don't know about it. We use semver and that has meaning.

@beckermr
Copy link
Member

beckermr commented Apr 7, 2024

Also while I'm not opposed to making the functions shorter here, the style in which these PRs are being made is making them difficult/impossible for me to review.

  • This pr has a net change of ~3000 lines of code. That's way too much for me personally to review. I think a series of smaller prs around at most a net change of 500 lines of code would be much better.
  • It apparently mixes api deprecations and refactoring. Each PR needs to be about one thing (eg new api or early returns, or something else, etc). It takes practice to learn how to make PRs like that, but they help them get proper review and discussion.
  • The logic for breaking up a big function is clear. I am sure this can be done by only adding APIs.
  • If one is proposing an API change, then the reason for it should be clearly stated. Simply changing them to ones that a given developer thinks are better is not IMHO sufficient justification. We should, IMO, have a technical reason why a given API has to be removed as opposed to us simply making a new one for use in some new feature.

@wolfv
Copy link
Member

wolfv commented Jul 23, 2024

hey @ytausch - I think we merged some similar refactors in #1981 - I hope you didn't mind. Do you want to check if we should still cherry-pick some changes from your branch?

@ytausch
Copy link
Contributor Author

ytausch commented Jul 25, 2024

Thanks for pointing out @wolfv!

I will have a look at this again once #1919 is merged, which was the reason this is blocked altogether

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.

5 participants