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

feat: allow eval on non existing namespace #29

Merged
merged 7 commits into from
Jul 22, 2024

Conversation

nichmor
Copy link
Collaborator

@nichmor nichmor commented Jul 22, 2024

This PR aims to add allow_missing_selector argument for RecipeLoader which will be used by conda-smithy linter to suggest some lints for osx platform. To do this, we need to ignore other selectors ( treat them as true ) so the osx one will be evaluated.
Also, I'm adding flatten_lists that will make just a list of values for this case:

python:
if: osx
  - 3.8
 
python:
if: unix
 - 3.9

So instead of having python: [[3.8], [3.9]] we will have python: [3.8, 3.9]

@@ -94,12 +114,27 @@ def remove_empty_keys(variant_dict: dict[str, Any]) -> dict[str, Any]:
return filtered_dict


def flatten_lists(variant_dict: dict[str, Any]) -> dict[str, Any]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these methods considered to be used outside of this class? E.g. are they public? If not maybe we should prepend them with a _. Otherwise, disregard this comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've moved flatten_lists and remove_empty_keys in utils.py so it could be reused in future.
wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

utils.py is still a "public" module though. Personally I would either make utils "non-public" by prepending a _ or prepending the functions.

The thing is that if we don't mark them as non-public they are public and people might start depending on these symbols.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sorry but why it's a bad idea to expose this utills functions for the public?
flattening a lists and remove empty keys seems like a generic problem that isn't a rattler/conda specific

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's a preference but to me, the scope of this library is not providing utility functions to work with lists and dictionaries but rather to work with recipe.yamls. In my eyes, we should be really careful to increase the API of the library. People will start depending on anything we expose publicly which makes it harder for us to refactor things in the library later on. For instance, just moving a function from one module to another will then already be a breaking change.

WDYT @Hofer-Julian @tdejager

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

got it, let me make them private

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with @baszalmstra.

Regarding making all functions private vs making the module private, I think making the functions private is the way to go. It is more common in my experience.

@nichmor nichmor requested a review from baszalmstra July 22, 2024 12:16
@nichmor nichmor merged commit d6aff49 into main Jul 22, 2024
7 checks passed
@Hofer-Julian Hofer-Julian deleted the feat/allow-eval-on-non-existing-namespace branch July 22, 2024 13:21
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.

3 participants