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

fix: declaration of required variable in filters v2 #1136

Merged

Conversation

tcleonard
Copy link
Collaborator

This is to fix the problem you reported @ulgens

@tcleonard tcleonard changed the title fix: declaration of required variable in filters fix: declaration of required variable in filters v2 Feb 24, 2021
@ulgens
Copy link
Collaborator

ulgens commented Feb 24, 2021

Is there any chance we can add test for this too? I didn't understand how tests didn't fail before.

@tcleonard
Copy link
Collaborator Author

yep I can add a test for it, good point. (it's when you don't use any automatic filters and only custom ones)

@tcleonard
Copy link
Collaborator Author

tcleonard commented Feb 25, 2021

There is a test failing which I have no idea what it is about... it doesn't seem linked to what I have changed and I can't reproduce this failure locally... any idea?

@zbyte64
Copy link
Collaborator

zbyte64 commented Feb 26, 2021

I'll play with it this weekend, looks like names is an empty string when it attempts to generate an enum for the file path field.

@zbyte64
Copy link
Collaborator

zbyte64 commented Mar 2, 2021

Can hack around it by modifying: graphene_django/converter.py: convert_choices_to_named_enum_with_descriptions

    if not len(named_choices):
        named_choices = set()
    return Enum(name, named_choices, type=EnumWithDescriptionsType)

Python 2.7 doesn't handle enums with lists or tuples with zero entries - but works okay if we pass a set or generator. The file path field in the test has no child folders, therefor we get an empty set of choices.

tcleonard pushed a commit to loft-orbital/graphene-django that referenced this pull request Mar 10, 2021
@ulgens ulgens requested review from ulgens and zbyte64 March 11, 2021 00:05
Copy link
Collaborator

@zbyte64 zbyte64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ulgens ulgens merged commit 6f1389c into graphql-python:v2 Mar 11, 2021
@tcleonard tcleonard deleted the fix/filtered_required_declaration branch January 30, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants