Skip to content

Conversation

nikordaris
Copy link
Contributor

No description provided.

Copy link
Member

@jkimbo jkimbo left a comment

Choose a reason for hiding this comment

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

Hi @nikordaris , thanks for the pull request!

I've added a suggestion to make it better. Also if you could add some tests to assert the new behaviour that would be great. You should add them here: https://github.com/graphql-python/graphene/blob/12d4dab7742c9408777380c390152d7cef0f838d/graphene/types/tests/test_dynamic.py

@@ -11,7 +12,7 @@ class Dynamic(MountedType):

def __init__(self, type, with_schema=False, _creation_counter=None):
super(Dynamic, self).__init__(_creation_counter=_creation_counter)
assert inspect.isfunction(type)
assert inspect.isfunction(type) or isinstance(type, partial)
Copy link
Member

Choose a reason for hiding this comment

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

I think a better check would be to use callable then it would catch both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can't use callable because class types are callable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could do not inspect.isclass(type) and callable(type)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really though I was basing it off of

if inspect.isfunction(_type) or isinstance(_type, partial):

I wasn't sure if there were callable types we didn't want to support

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah you're right. What you've done then looks good. Just needs some tests.

@nikordaris
Copy link
Contributor Author

ok @jkimbo I've added a test for partial. let me know if there is anything else i should change

@syrusakbary
Copy link
Member

It goods look to merge for me @jkimbo, feel free to merge once you review it :)

@jkimbo
Copy link
Member

jkimbo commented May 15, 2018

@syrusakbary I can't merge, I need write access to do that.

@jkimbo jkimbo merged commit 034765a into graphql-python:master May 25, 2018
@jkimbo
Copy link
Member

jkimbo commented May 26, 2018

This has been released in v2.1.1

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