Skip to content
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

Ensure valid RST in docstrings #1141

Merged
merged 11 commits into from
Dec 28, 2019
Merged

Ensure valid RST in docstrings #1141

merged 11 commits into from
Dec 28, 2019

Conversation

peterjc
Copy link
Contributor

@peterjc peterjc commented Dec 27, 2019

Description

Work in progress for #1140, fixing RST violations reported by docutils via flake8-rst-docstrings

Checklist

  • The above description motivates these changes.
  • There is a unit test that covers these changes.
  • All new and existing tests pass locally and on Semaphore.
  • Parameters have type hints with PEP 484 syntax.
  • Functions and classes have useful sphinx-style docstrings.
  • (New Feature) The docs have been updated accordingly.
  • (Bugfix) The associated issue is referenced above using
    auto-close keywords.
  • The changelog is updated,
    including author and PR number (@username, gh-xxx).

@peterjc peterjc requested a review from a team as a code owner December 27, 2019 10:19
Copy link
Contributor

@appleby appleby left a comment

Choose a reason for hiding this comment

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

This is great, thanks for doing this. I'm not sure what's going on with the semaphore tests, test pass for me locally.

As mentioned in #1140, let's wait on @karalekas to see what he thinks about rending bra/ket notation. Otherwise, this looks great so far.

pyquil/api/_devices.py Show resolved Hide resolved
pyquil/noise.py Show resolved Hide resolved
@peterjc
Copy link
Contributor Author

peterjc commented Dec 27, 2019

Apparently semaphoreci is unhappy, but I don't see any error message - this is my first time interacting with that platform so I may be missing where to click (or perhaps I need to register an account with them)?

@appleby
Copy link
Contributor

appleby commented Dec 27, 2019

I think you need to be a project admin to see the semaphore logs? It looks like the semaphore tests are failing because the quilc server was unresponsive... lot's of timeout errors trying to connect to quilc.

@karalekas
Copy link
Contributor

Reran it, looks like the build is passing now! Thanks for doing this -- I'd agree with @appleby that I think all docstrings should be valid RST. Our API documentation is currently incomplete, which is why some of the docstrings aren't included, but in general I think we should aim for them all to be valid and consistent. As for braket notation, I think that the double backticks or inline math suggestions are the way to go. I'd lean toward double backticks in most situations because we don't need to be rendering math when it is gratuitous, but I'm sure there will be situations where we are writing out equations where using :math: is more appropriate.

@karalekas karalekas added quality 🎨 Improve code quality. work in progress 🚧 This PR is not ready to be merged. labels Dec 27, 2019
@peterjc
Copy link
Contributor Author

peterjc commented Dec 27, 2019

I think this is all the low hanging fruit, the remaining possible issues:

$ flake8 --select RST --rst-roles ref,py:class,py:func --rst-directives versionadded,deprecated pyquil/
pyquil/gates.py:0:1: RST902 Failed to parse __all__ entry.
pyquil/gate_matrices.py:0:1: RST902 Failed to parse __all__ entry.
pyquil/unitary_tools.py:178:1: RST301 Unexpected indentation.
pyquil/unitary_tools.py:179:1: RST201 Block quote ends without a blank line; unexpected unindent.
pyquil/tests/test_numpy_simulator.py:276:1: RST213 Inline emphasis start-string without end-string.
pyquil/tests/test_numpy_simulator.py:280:1: RST213 Inline emphasis start-string without end-string.
pyquil/experiment/_program.py:52:1: RST214 Inline literal start-string without end-string.
pyquil/experiment/_program.py:52:1: RST214 Inline literal start-string without end-string.

Both RST902 Failed to parse __all__ entry are down to dynamically defined __all__ (might go away if I had pyquil installed), although I believe using tuples (immutable) over lists (mutable) is recommended elsewhere for the __all__ values.

The pyquil/unitary_tools.py indentation had me scratching my head, but I don't have enough experience of this part of RST as used in parameter lists to fix the warning.

Finally the RST213 Inline emphasis start-string without end-string messages from pyquil/tests/test_numpy_simulator.py are a special case, see peterjc/flake8-rst-docstrings#18

@appleby
Copy link
Contributor

appleby commented Dec 27, 2019

Personally, I think it's fine to punt on the above issues that don't have an obvious solution.

If you don't mind, please just add a line to the changelog and I think this is good to go.

@peterjc
Copy link
Contributor Author

peterjc commented Dec 27, 2019

Change log entry added (rebased first to pre-empt the likely merge conflict in the change log).

Copy link
Contributor

@appleby appleby left a comment

Choose a reason for hiding this comment

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

This is great thanks for contributing.

@karalekas karalekas changed the title Tweaking RST in docstrings Ensure valid RST in docstrings Dec 28, 2019
@karalekas karalekas added this to the v2.16 milestone Dec 28, 2019
@karalekas karalekas removed the work in progress 🚧 This PR is not ready to be merged. label Dec 28, 2019
Copy link
Contributor

@karalekas karalekas left a comment

Choose a reason for hiding this comment

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

Thanks (again) for contributing!! 🙌

@karalekas karalekas merged commit 729c66f into rigetti:master Dec 28, 2019
@peterjc peterjc deleted the rst branch December 28, 2019 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quality 🎨 Improve code quality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants