-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
validate_arguments decorator example implementation #1263
Conversation
f4db527
to
e61f8c0
Compare
35fde6f
to
abe566d
Compare
413dfd7
to
436fde6
Compare
Update: I have edited the tests to highlight the differences, please have a look. |
b6d402e
to
f8c6226
Compare
is there something else failing beside string annotations? (I have left this test case active to reflect that - that's what keep failing in CI) I liked in this approach to have python itself bind the arguments and that we don't have to rely on nor restrict arguments names, The logic part is pretty straightforward (getting arguments by kind -> check bindings -> validate arguments on matching model -> call function with validated arguments) - from entry to model creation is just transformation over a mapping, and the apply wrapper itself, which does signature check and validation is also very easy to understand and short. of course you may decide whatever works, so all is acceptable, but it is also worth to look at this (I suggest looking the file Thank you for your response and this amazing project. |
This looks like an interesting approach, but how does it effect performance? I guess we need some kind of benchmark to compare it with. If you don't have time, I'll try to get around to building a benchmark when I have more time. |
in the interests of getting the number of open PRs down to a manageable level, I'm closing this but could be reopened if performance benchmarks show it's a more performant approach. |
This is an alternative implementation for the validate_arguments decorator #1179
Which also happen to fix #1222
(It also does not relay on arguments naming conventions)
I would not recommend merging this as it does not wrap raised TypeError as ValidationError (making relevant tests fail).
But might be useful for extracting logic and finding out what causes the above issue.