Enable missing argument in docstring lint#15721
Conversation
In the recently merged Qiskit#15603 we migrated from pylint to use ruff. During the development of that PR the rule group "D" for rules derived from pydocstyle was investigated but the full rule group was overly pedantic and even with disabling the most egregious rules also changed the docs for the worse (at least by autofixing many rules) so that sphinx would not succesfully build after applying the fixes. So during Qiskit#15603 the changes for this rule group were reverted. However, one of the useful rules from that group D417 which checks that all arguments are documented. This rule found real issues in the documentation and it is worthwhile to enable it. This commit enables the rule in our ruff checks and fixes the issues associated with. During this process ruff flagged one place in the `__call__` method docstring for the `TwoQubitControlledUDecomposer` class has not documented several arguments on the method. However, these arguments are unused currently. It is apparently trying to match the `__call__` signature of the other two qubit decomposers but is not using most of the arguments. Most could be conceivably supported by `TwoQubitControlledUDecomposer` and it's not clear why they were added. But, for this PR I didn't want to look into adding the support as it was out of scope. For the time being this PR suppresses the ruff rule and adds a TODO comment to start using the unused arguments.
|
One or more of the following people are relevant to this code:
|
jakelishman
left a comment
There was a problem hiding this comment.
There's only one potentially actionable comment - feel free to either respond to it or just queue for merge.
| def _run_workflow( | ||
| program: Any, | ||
| pass_manager: BasePassManager, | ||
| *, | ||
| initial_property_set: dict[str, object] | None = None, | ||
| **kwargs, | ||
| ) -> Any: | ||
| """Run single program optimization with a pass manager. | ||
|
|
||
| Args: | ||
| program: Arbitrary program to optimize. | ||
| pass_manager: Pass manager with scheduled passes. | ||
| initial_property_set: An optional dictionary to preseed the | ||
| property set in the pass manager with. | ||
| **kwargs: Keyword arguments for IR conversion. |
There was a problem hiding this comment.
This is a private function - does the Ruff rule enforce that all private functions have complete "Args" definitions, or just ones that specify an "Args" section? (I guess/hope the latter.)
There was a problem hiding this comment.
It's the latter, it only looks at docstrings with an Args section: https://docs.astral.sh/ruff/rules/undocumented-param/#pydocstyle-d
| Parameters: | ||
| Args: | ||
| circuit: Input quantum circuit. |
There was a problem hiding this comment.
I don't mind standardising these, but Napoleon documents "Args" as an alias to "Parameters", so they should be all internally normalised into the same section heading anyway.
There was a problem hiding this comment.
Yeah, it was a bit annoying, but the rule checker only looks for Args it doesn't know about Parameters. I assume it's because the rule documents itself as only working with Google style docs.
| default `left` will be used. | ||
| idle_wires (bool): Include idle wires. Default is True. | ||
| wire_order (list): A list of ints that modifies the order of the bits. | ||
| wire_map (dict): The wire map |
There was a problem hiding this comment.
lol
(I don't care about improving this necessarily - it's just an internal helper and clear from the context it's called in.)
There was a problem hiding this comment.
Yeah I had the same attitude, I didn't feel the need to figure out the dictionary format and write a detailed description of it just for a private docstring
Cryoris
left a comment
There was a problem hiding this comment.
This also need rebasing on main but otherwise LGTM 🙂
* Enable missing argument in docstring lint In the recently merged Qiskit#15603 we migrated from pylint to use ruff. During the development of that PR the rule group "D" for rules derived from pydocstyle was investigated but the full rule group was overly pedantic and even with disabling the most egregious rules also changed the docs for the worse (at least by autofixing many rules) so that sphinx would not succesfully build after applying the fixes. So during Qiskit#15603 the changes for this rule group were reverted. However, one of the useful rules from that group D417 which checks that all arguments are documented. This rule found real issues in the documentation and it is worthwhile to enable it. This commit enables the rule in our ruff checks and fixes the issues associated with. During this process ruff flagged one place in the `__call__` method docstring for the `TwoQubitControlledUDecomposer` class has not documented several arguments on the method. However, these arguments are unused currently. It is apparently trying to match the `__call__` signature of the other two qubit decomposers but is not using most of the arguments. Most could be conceivably supported by `TwoQubitControlledUDecomposer` and it's not clear why they were added. But, for this PR I didn't want to look into adding the support as it was out of scope. For the time being this PR suppresses the ruff rule and adds a TODO comment to start using the unused arguments. * Update filename docstring * Revise wording on state visualization filename arg
Summary
In the recently merged #15603 we migrated from pylint to use ruff. During the development of that PR the rule group "D" for rules derived from pydocstyle was investigated but the full rule group was overly pedantic and even with disabling the most egregious rules also changed the docs for the worse (at least by autofixing many rules) so that sphinx would not succesfully build after applying the fixes. So during #15603 the changes for this rule group were reverted. However, one of the useful rules from that group D417 which checks that all arguments are documented. This rule found real issues in the documentation and it is worthwhile to enable it. This commit enables the rule in our ruff checks and fixes the issues associated with.
During this process ruff flagged one place in the
__call__method docstring for theTwoQubitControlledUDecomposerclass has not documented several arguments on the method. However, these arguments are unused currently. It is apparently trying to match the__call__signature of the other two qubit decomposers but is not using most of the arguments. Most could be conceivably supported byTwoQubitControlledUDecomposerand it's not clear why they were added. But, for this PR I didn't want to look into adding the support as it was out of scope. For the time being this PR suppresses the ruff rule and adds a TODO comment to start using the unused arguments.Details and comments