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

Fix incorrect fields in docstrings #1453

Merged
merged 24 commits into from
Oct 21, 2020
Merged

Conversation

mthuurne
Copy link
Contributor

@mthuurne mthuurne commented Oct 16, 2020

Contributor Checklist:

The link in the return type was invalid, since `IO[bytes]` is not
a single entity. As these tags will be redundant with the next major
pydoctor release, I removed them rather than fixing the `@rtype`.
ILegacyLogObserver is the local name under which this interface is
imported, but is not the actual class name.
The asterixes are not part of the parameter name itself, so they
shouldn't be used in the docstring, unlike the `def` line.
Future versions of pydoctor will warn about these asterixes.
Also correct the actual documented return type where a Python 2 `str`
was still used instead of `bytes`.
In some cases a superfluous colon was preventing the name from being
recognised as such, but in other cases the name was actually missing.
The docstring claimed that the method would both return -1 and raise
an unspecified exception if the descriptor no longer has a valid file
descriptor number associated with it.

Some implementations within Twisted can return -1, while none of them
raise an exception.
The code can no longer raise that exception, ever since commit e14cc81
("Remove deprecated code that allowed passing non-bytes values.").
The mentioned functions from the `os` module don't document any
particular exception types they might raise, but anything other
than `OSError` seems unlikely.
The syntax of the `@raise` field requires an exception type and if we
don't know the exception type because we're not the original raiser,
`Exception` is the most specific we can be.
While the epytext parser can handle these cases gracefully, they are
still syntactically incorrect.
These do not end up in the output.

Future pydoctor versions will warn about them.
@mthuurne mthuurne force-pushed the 10021-mthuurne-fix-docstrings branch from 3c7d92e to 9ca5eab Compare October 21, 2020 03:21
Epytext has a dedicated `@keyword` field for these. In the past,
using `@param` worked just as well, but in the near future pydoctor
will start warning about `@param` for parameters that aren't included
in the function signature.
The signature of this method was changed in commit d55d2a0 ("Support
encoding to new OpenSSH private key format"), but the docstring wasn't
updated to match.
The parameters were made more explicit in commit 8f9ba2c ("Add type
hints for twisted.internet.interfaces and twisted.internet.base"),
but the docstring wasn't updated to match.
This method takes multiple domains, but was documented as taking only
a single domain.
The documented `reactor` parameter does not exist, while the unrelated
`threadFactory` parameter was undocumented.
@mthuurne mthuurne force-pushed the 10021-mthuurne-fix-docstrings branch from 9ca5eab to e975cf3 Compare October 21, 2020 03:41
@mthuurne mthuurne marked this pull request as ready for review October 21, 2020 04:02
@mthuurne mthuurne requested a review from twm October 21, 2020 04:03
Copy link
Contributor

@twm twm left a comment

Choose a reason for hiding this comment

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

This looks good. I didn't run pydoctor, but all these changes are clearly improvements. I did note one typo.

The only other thought I had is that there are several places documented as Exception that might technically produce BaseException. However that's always true so 🤷‍♂️ .

Thank you!

src/twisted/conch/ssh/keys.py Outdated Show resolved Hide resolved
@@ -1588,9 +1588,6 @@ class IFileDescriptor(ILoggingContext):

def fileno() -> object:
"""
@raise: If the descriptor no longer has a valid file descriptor
number associated with it.
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like a deficiency in the interface that there is no exception type defined for this. Oh well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of the implementations within Twisted raise an exception though. Some return -1 if the descriptor is no longer valid.

@mthuurne
Copy link
Contributor Author

The only other thought I had is that there are several places documented as Exception that might technically produce BaseException. However that's always true so man_shrugging .

I think the purpose of @raise is to document exceptions the caller might want to catch and the exceptions that inherit directly from BaseException are not ones you should be catching.

@mthuurne mthuurne merged commit 720f59d into trunk Oct 21, 2020
@mthuurne mthuurne deleted the 10021-mthuurne-fix-docstrings branch October 21, 2020 08:37
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.

None yet

2 participants