-
Notifications
You must be signed in to change notification settings - Fork 278
New implementation tests: address pylint warnings #1664
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
Conversation
Pull Request Test Coverage Report for Build 1426425036Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
tests/repository_simulator.py
Outdated
@@ -136,6 +139,7 @@ def targets(self) -> Targets: | |||
return self.md_targets.signed | |||
|
|||
def all_targets(self) -> Iterator[Tuple[str, Targets]]: | |||
"""Yield role name and signed portion of targets one by one""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if relevant comment.
To be consistent with another docstring you had added, finish with a period.
If it makes sense, it would be interesting to apply the other changes that are part of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add .
at the end of the docstrings.
Do you have a better suggestion for this docstring?
The function is simple and I am not sure what else can I write here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a better suggestion for this docstring. LGTM
[General comment, not sure if the right place]
I think what we are doing in the ngclient
for docstring is the best option. In a sense, it can become good documentation in the end (as part of readthedocs/sphinx).
I understand that this is a test part, but it can help a lot of new contributors. Any thoughts @jku ?
tests/test_api.py
Outdated
root_path = os.path.join(self.repo_dir, "metadata", "root.json") | ||
root = Metadata[Root].from_file(root_path).signed | ||
path = os.path.join(self.repo_dir, "metadata", "root.json") | ||
root = Metadata[Root].from_file(path).signed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above you changed from dir
to dest_dir
, I see it as more explicit.
At these lines, I see the root_path
as path
, any specific reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dir was likely changed because it's a builtin, this change is likely to keep lines below 80 chars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root_path
was changed to path
, because there was a pylint warning we were using too many variables in a single function and with this change, we can reuse path
.
About dir
Jussi is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-using variables is usually a code smell but this looks OK to me. The best solution might be a refactor of the function (to maybe multiple tests) but I appreciate not doing large changes under "address pylint warnings": anyway LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer of a concern after the merge of #1671 and I removed this change.
87c6c31
to
ce10b69
Compare
I addressed comments made by @kairoaraujo:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Martin, Kairo. LGTM.
tests/test_api.py
Outdated
root_path = os.path.join(self.repo_dir, "metadata", "root.json") | ||
root = Metadata[Root].from_file(root_path).signed | ||
path = os.path.join(self.repo_dir, "metadata", "root.json") | ||
root = Metadata[Root].from_file(path).signed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-using variables is usually a code smell but this looks OK to me. The best solution might be a refactor of the function (to maybe multiple tests) but I appreciate not doing large changes under "address pylint warnings": anyway LGTM
I was a bout to merge ... but first merged another change that created a conflict. Sorry about that, could you resolve please? |
ce10b69
to
2f96935
Compare
Rebased on top of develop as there were conflicts after the merge of #1636. |
Pylint reported a couple of warnings flagged as "duplicate-code". We were truly duplicating code - one of the examples was when we imported the same objects from tuf/api/metadata.py: MetaFile, Role, Root, Snapshot, TargetFile, Targets, and Timestamp in two separate modules. So, I thought we do want to be repetitive here and include that code at both modules. The problem is that besides importing the above classes the modules imported other classes from tuf.api.metadata.py and there was no way to disable this check. I searched and found out that this is a known problem: pylint-dev/pylint#214. That's why the only solution I see is to disable this warning temporarily and hoping that one day when this issue is fixed we will remember to turn it on again. Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
_ is often used when a function returns multiple values and you need a sub-portion of them. Then, those values that are unnecessary can be named _. Currently, pylint warns us that this is not a good variable name, so fix that. Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
Address or disable pylint warnings raised on all test files inside the "tests/" directory testing the code of the new implementation. Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2f96935
to
d4187f3
Compare
#1671 is merged and I have rebased and removed the change which handled too many local variables (renaming |
Related to #1657:
Description of the changes being introduced by the pull request:
I believe we should enable linting (tox -e lint) for new test files testing the new implementation.
The first step to do that would be to apply the automatic fixes proposed
by
black
andisort
on the new test files testing the new code.This happened in #1658.
The next step would be to propose fixes for
pylint
andmypy
and the lastthe part will be to enable the linters themselves.
In this pr, I include fixes for the warnings by
pylint
only as those changes are NOTautomatically by the tool and are more than enough for a pr.