Page MenuHomePhabricator

deprecation decorators should add deprecation information to docstrings
Closed, ResolvedPublic

Description

T121365 shows many instances where the docstring has 'DEPRECATED' explicitly added to the docstring.

There will be other cases where a method is decorated with @deprecated but the docstring was not updated to mention it is deprecated, or there is no docstring at all.

All the existing literal DEPRECATED in docstrings should be removed, and the deprecated decorator should add/alter the function's docstring to describe the deprecation for documentation.

This task doesnt need to solve T121365; it could simply replicate the existing problem by prefixing the docstrings with 'DEPRECATED:' .
There are alternatives which would pass the new pep257 rule, such as appending (DEPRECATED). to the end of the first line of the docstring.

Event Timeline

jayvdb raised the priority of this task from to Needs Triage.
jayvdb updated the task description. (Show Details)

As decorators are fairly 'advanced Python', and are complex to build/modify/test, this would be a good Google-Code-In-2015 project for someone wanting to increase their Python skills.

I imagine a regex could be used to make @deprecate_arg do something similar.

Change 265899 had a related patch set uploaded (by Sn1per):
Add deprecation notice to docstring in @deprecated decorator

https://gerrit.wikimedia.org/r/265899

Change 265902 had a related patch set uploaded (by Sn1per):
[WIP]Remove unnecessary DEPRECATED notices from docstrings

https://gerrit.wikimedia.org/r/265902

What is wrong keeping "Deprecated" in doc string? Please keep in mind doc strings are comments for human readability to explain a method inside the code. But it would be wrong to have access to those comments via post-processors on an external sheet only.

The @deprecated is also human readable. The 'problem' with adding 'Deprecated' to the docstring is they are not kept in sync with @deprecated. We have so many instances where this hasnt been done; it slips through code review, as we dont have a code style checker for it (and it would be difficult to create one).

But if you want to create a code style checker, that would also be great.

This decorator could check if 'Deprecated.' is in the docstring already, and not add it.

@jayvdb any idea how to implement a hook for additional test stuff?

Change 265902 abandoned by Sn1per:
[WIP] Remove unnecessary DEPRECATED notices from docstrings

Reason:
Per T121366#1958826

https://gerrit.wikimedia.org/r/265902

Change 265899 merged by jenkins-bot:
Add deprecation notice (if necessary) to docstring of @deprecated functions

https://gerrit.wikimedia.org/r/265899