Skip to content

added special handling for partials in get_name_from_func #294

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

Closed
wants to merge 1 commit into from

Conversation

beniwohli
Copy link
Contributor

@beniwohli beniwohli commented Sep 23, 2018

@graphaelli @roncohen any opinion on wrapping the resulting name with "partial()" to denote that the wrapped function was a partial?

fixes #293
closes #294

@beniwohli beniwohli changed the title added special handling for partials in get_name_from_func (#294) added special handling for partials in get_name_from_func Sep 23, 2018
beniwohli added a commit to beniwohli/apm-agent-python that referenced this pull request Sep 23, 2018
Copy link
Member

@graphaelli graphaelli left a comment

Choose a reason for hiding this comment

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

partial() looks nice to me

if isinstance(func, partial_types):
return "partial({})".format(get_name_from_func(func.func))
elif hasattr(func, "_partialmethod"):
return "partial({})".format(get_name_from_func(func._partialmethod.func))
Copy link
Member

Choose a reason for hiding this comment

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

any reason to worry about func not existing? eg user defined _partialmethod on their class?

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.

AttributeError: 'functools.partial' object has no attribute '__module__'
2 participants