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 the @has_preference and @delete_preferences convenience functions and macros #6

Merged
merged 1 commit into from
Jan 7, 2021
Merged

Add the @has_preference and @delete_preferences convenience functions and macros #6

merged 1 commit into from
Jan 7, 2021

Conversation

DilumAluthge
Copy link
Member

@DilumAluthge DilumAluthge commented Jan 4, 2021

Fixes #4

This pull request adds the following convenience functions, with associated convenience macros:

  1. @has_preference
  2. @delete_preferences

@has_preference is pretty straightforward - if the result of @load_preference is nothing, it returns false, otherwise it returns true.

For @delete_preferences, there is a keyword argument block_inheritance. If block_inheritance is false (which is the default), then we call @set_preferences with missing as the value for each given preference key. If block_inheritance is true, then we call @set_preferences with nothing as the value for each given preference key.

Copy link
Member

@staticfloat staticfloat left a comment

Choose a reason for hiding this comment

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

Overall, this looks perfect.

test/UsesPreferences/src/UsesPreferences.jl Outdated Show resolved Hide resolved
test/runtests.jl Outdated Show resolved Hide resolved
test/runtests.jl Outdated Show resolved Hide resolved
@DilumAluthge
Copy link
Member Author

DilumAluthge commented Jan 5, 2021

BTW, it would be best to first merge #7, and then I can rebase this PR. That way we can double check that CI passes on this PR.

EDIT: this is done now.

@codecov
Copy link

codecov bot commented Jan 6, 2021

Codecov Report

Merging #6 (bae9101) into master (e517d28) will decrease coverage by 5.11%.
The diff coverage is 46.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #6      +/-   ##
==========================================
- Coverage   81.81%   76.69%   -5.12%     
==========================================
  Files           2        2              
  Lines          88      103      +15     
==========================================
+ Hits           72       79       +7     
- Misses         16       24       +8     
Impacted Files Coverage Δ
src/Preferences.jl 76.40% <46.66%> (-6.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e517d28...bae9101. Read the comment docs.

@DilumAluthge
Copy link
Member Author

Alright, should be ready for another round of review.

@staticfloat staticfloat merged commit f52ba25 into JuliaPackaging:master Jan 7, 2021
@DilumAluthge DilumAluthge deleted the dpa/delete-preference branch January 7, 2021 07:26
Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

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

Curious about this.

@timholy
Copy link
Member

timholy commented Jan 31, 2022

Hmm, GitHub seems to be having some troubles. Issue is that has_preference takes a default argument but doesn't use it. Typo, or intended?

@DilumAluthge
Copy link
Member Author

Oh that's definitely a bug.

@DilumAluthge
Copy link
Member Author

It shouldn't take a default argument. The docs in https://github.com/JuliaPackaging/Preferences.jl/blob/master/README.md#api are correct, but the function itself is incorrect.

@timholy
Copy link
Member

timholy commented Jan 31, 2022

xref #29

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.

Feature request: ability to "delete" a preference
3 participants