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

Change asserts to manually raising AssertionError #947

Closed
wants to merge 1 commit into from

Conversation

dsanders11
Copy link
Contributor

See graphql-python/graphql-core#244 for discussion of why this change is needed. The issue exists in several graphql-python projects (graphql-core, graphene, graphene-django), but biting this one off first as it was smaller than the changes needed in graphql-core.

Ideally the usage of AssertionError would be dropped in favor of TypeError and ValueError, but that would have to wait for a new major version release as it's a backwards incompatible change.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@ekampf
Copy link
Contributor

ekampf commented Apr 23, 2019

As I mentioned in the issue Im not sure this is the correct approach avoiding assert statements all together,
What I am sure is that manually throwing AssertionError is wrong.
If we're converting assertion checks to runtime checks we should use the appropriate errors (like ValueError etc)

@ekampf
Copy link
Contributor

ekampf commented Apr 23, 2019

I also wrote this on the issue but I think the PR is too big - removing all uses of assert regardless of case.
I think the change is correct in the Date(Scalar) (but should throw the right error and not AssertionError) but I'm not sure about a lot of the other places...

(if you want to separate the changes to Date and similar changes to a separate PR I would gladly approve that one and we can discuss the rest case by case)

@dsanders11
Copy link
Contributor Author

If we're converting assertion checks to runtime checks we should use the appropriate errors (like ValueError etc)

That would require a new major version of graphql-core, graphene, django-graphene, etc. Changing the exception type from AssertionError changes the contract of the function, so you can't change that and not potentially break other people's code. For example, the code I mentioned in django-graphene at this line depends on catching an AssertionError.

@stale
Copy link

stale bot commented Jul 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 29, 2019
@stale stale bot closed this Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants