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

Add docparams lint check #145

Closed
wants to merge 10 commits into from
Closed

Conversation

c24t
Copy link
Member

@c24t c24t commented Sep 17, 2019

This PR adds a lint check for missing or mismatching names in docstrings. I added this after I noticed that opentelemetry.trace was missing some docstring annotations. This PR doesn't quite fix the problem since we still disable the missing-docstring check, but it should help to keep our docstrings consistent with the code.

Note that with this change we check for types (either in annotations or docstrings) in the SDK and ext packages. We may not actually want to enforce this, in which case we'll need different pylint configs for the API and SDK/etc. packages.

@@ -438,6 +438,9 @@ def use_span(self, span: "Span") -> typing.Iterator[None]:

Args:
span: The span to start and make current.

Yields:
`None`
Copy link
Member Author

Choose a reason for hiding this comment

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

Backticks here because this is interpreted as a text description of the thing that we yield. None: some description would force "None" to render as a type.

Ideally we'd pick up the yielded type from the return type annotation, but sphinx_autodoc_typehints isn't smart enough to unpack -> typing.Iterator[None] above.

"""

# pylint: disable=missing-type-doc
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what we get for using the same lint check in the API and SDK/etc.

Copy link
Member

Choose a reason for hiding this comment

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

What type doc is it complaining about? Under-documented parameters. Since the Middleware is public API, we should probably really add that documentation.

Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

LGTM. tox.ini file is getting longer though.

Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

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

In general, I like this but I want to know about the reason for e49a645.

.pylintrc Show resolved Hide resolved
tox.ini Outdated
@@ -73,18 +73,50 @@ commands_pre =
commands =
; Prefer putting everything in one pylint command to profit from duplication
; warnings.
black --check --diff .
pylint opentelemetry-api/src/opentelemetry \
black --check --diff \
Copy link
Member

Choose a reason for hiding this comment

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

I see that was done to restrict to code and test files in e49a645 but why? Are setup.py files not code, for example?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it'd be fine to include setup.py here, this was just copied from the pylint args below.

e49a645 was because tox was failing on my machine, linting a bunch of files in virtualenvs and etc. This seemed like a straightforward improvement to me, even if it means a bit more work keeping the toxfile up to date with the package structure.

Copy link
Member

Choose a reason for hiding this comment

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

I had that problem with virtualenvs too but decided that keeping virtualenvs out of the project dir is easier than maintaining theses ugly lists (separation of source and build tree is a nice thing in general).

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I also vote for not adding it this way. This repo may not add many more directories, but it's quite tricky to add the correct ones and increases the size and error-prone boilerplate considerably.

Maybe we should discuss how we expect to do venvs though? I like using vscode and it's autocompletion doesn't find modules at all with the current structure.

@c24t
Copy link
Member Author

c24t commented Sep 18, 2019

tox.ini file is getting longer though.

There are probably better ways to do this, e.g. using setuptools to get a list of files for each installed package.

@c24t
Copy link
Member Author

c24t commented Sep 19, 2019

The build is failing because the new lint check fails on changes on master. Something has gone seriously off the rails here.

https://travis-ci.org/open-telemetry/opentelemetry-python/jobs/586656470

opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py:208:0: W9015: "kind" missing in parameter documentation (missing-param-doc)

Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

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

Commenting to point out that I'm not approving because I dont't want these long folder lists. People should just keep their virtualenvs out of the source tree (also has the advantage that you can just run black . from a terminal without running the slower tox).

If you can get the list shorter that would also be OK.

This was referenced Sep 24, 2019
@a-feld a-feld removed their request for review December 10, 2019 00:57
@c24t c24t requested a review from a team May 21, 2020 16:49
@toumorokoshi
Copy link
Member

@c24t closing this out like we discussed in the maintainers meeting. Tracking ticket to pick this up again: #759

srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
* fix(basic-tracer): use recording/real span

* fix: avoid mutate the parent span, use Object.assign()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants