Description
This project uses asserts in a lot of places (I found about 100 cases) where they should not be used. They're being used to validate arguments to functions, where the normal Python way would be to use a TypeError
or a ValueError
. Assertions are essentially debug code, not code for validating arguments.
Any usage of optimize mode or Python (-O
or -OO
, or PYTHONOPTIMIZE
) strips out assertions, making this code useless. That's very problematic if you're generating schema dynamically, as you won't get errors and this library will generate an invalid GraphQL schema.
At this point it's probably too late to change the uses of assert to a proper TypeError
or ValueError
, without a major version bump as dependent code in other projects may be catching AssertionError
.
I'm proposing all instances of assert foo, "Error"
be replaced with:
if not foo:
raise AssertionError("Error") # Should be a TypeError
This will at least make the code work in optimize modes where assertions are stripped.
I'll gladly make a PR doing so, but it's hard to tell if this project is still actively developed.