-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Added StrictBytes type
#2136
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
Added StrictBytes type
#2136
Conversation
…tion for StrictBytes and ConstrainedBytes
|
cc @hhsecond |
Codecov Report
@@ Coverage Diff @@
## master #2136 +/- ##
===========================================
- Coverage 100.00% 99.63% -0.37%
===========================================
Files 21 21
Lines 4093 4121 +28
Branches 823 829 +6
===========================================
+ Hits 4093 4106 +13
- Misses 0 12 +12
- Partials 0 3 +3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @PrettyWood are you happy with this? If so feel free to merge.
|
Thanks for the review @samuelcolvin and @PrettyWood! |
Change Summary
Added
StrictBytestype which rejects objects which are castable to bytes (ie.int,float,str), but which are not nativelybytestype. All changes are modeled afterStrictStr,StrictInt,StrictFloat, andStrictBooltypes.Added
strictoption toConstrainedBytesclass. Default value of the option (False) respects downstream code continuity. Any initialization or subclass ofConstrianedBytesbehaves identically to prior implementations unless the"strict"option is explicitly set toTrue).Added
strict_bytes_validatorwhich rejects any object which is notUnion[bytes, bytearray]type. Becausebytearrayinstances are just mutable versions ofbytes, we accept both as equivalent nativebytetypes. This is noted explicitly since the builtin bytearray construtor creates objects with the following behavior:Related issue number
n/a
Checklist
changes/<pull request or issue id>-<github username>.mdfile added describing change(see changes/README.md for details)