-
-
Notifications
You must be signed in to change notification settings - Fork 374
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 attr.validators.in_() #181
Conversation
Codecov Report
@@ Coverage Diff @@
## master #181 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 9 9
Lines 579 589 +10
Branches 126 128 +2
=====================================
+ Hits 579 589 +10
Continue to review full report at Codecov.
|
This seems like a good idea however the naming (and docstring) seems too restrictive given the implementation. Something like |
|
@glyph try to talk me out of calling it |
|
Since we’re going for |
(I cannot promise this will make it into 17.1 b/c I need to get it out ASAP but it’s possible. If you want to raise your chances, please double check CONTRIBUTING.rst; especially re: test docstrings.) |
Just updated it to |
Thanks, I’ve made some small adjustments. |
Thanks! |
I just noticed I forgot to add |
Hello there!
I wrote this for one of my projects and I thought it could be useful to others too. This is a validator called
in_(options)
that allows you to check if the value is within the allowed values. In my particular case it was useful to test things likein_(POSSIBLE_CHOICES)
,in_(Animals)
, etc.Example:
I was wondering if you had any thoughts and whether it would make sense to add it to attrs. If that's the case, I'd be more than happy to adjust the code with your suggestions.
Thanks!
Pull Request Check List
This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!
.rst
files is written using semantic newlines.versionadded
,versionchanged
, ordeprecated
directives.CHANGELOG.rst
.If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!