question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keep original docstring from @task decorated function

See original GitHub issue

Current behavior

When decorating a function with @task, the original docstring of the function is lost.

Proposed behavior

Original docstring is kept. Looking at the wrapper prefect.utilities.tasks.task, I thinks this should be do-able with functools.wraps, although I am not exactly sure what change needs to be made.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ConstantinoSchillebeeckxcommented, Dec 3, 2021

I ended up implementing a sphinx extension for this.

1reaction
dkapitancommented, May 13, 2020

@cicdw just tried exactly that, no joy …

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python decorator handling docstrings - Stack Overflow
I've recently been failing to get the help description correct for decorated functions - it seems a pretty poor state of affairs, but...
Read more >
Preserving docstrings when decorating functions | Python
Here is an example of Preserving docstrings when decorating functions: Your friend has come to you with a problem.
Read more >
How to Keep Your Original Method Attributes When Using ...
With “functools.wrap,” the decorated function that returns the “wrapper()” function takes care of copying the docstring, name function, and other information ...
Read more >
How to preserve Function Metadata while using Decorators?
This can be done using the wraps() method of the functools. It updates the wrapper function to look like wrapped function by copying...
Read more >
Python Decorators [Part 1]. Primer | by Sumeet Sarkar | Medium
Decorator needs the understanding of the fact that functions in python are ... Do we always have to implement a wraps to preserve...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found