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

pylint: fix issues #250

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ max-complexity = 10

[pylint.master]
ignore = server.py,task03.py,task04.py,task05.py
load-plugins = pylint.extensions.no_self_use

[pylint.messages control]
disable=
Expand Down
4 changes: 2 additions & 2 deletions testutils/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import subprocess


TAP_MASTER_C = re.compile(r"^\d+:\s+(?P<tap>[^:]+):.+" r"master\s+(?P<master>\S+)?")
TAP_MASTER_C = re.compile(r"^\d+:\s+(?P<tap>[^:]+):.+" + r"master\s+(?P<master>\S+)?")
TAP_LINK_LOCAL_C = re.compile(
r"inet6\s+(?P<link_local>fe80:[0-9a-f:]+)/\d+\s+" r"scope\s+link"
r"inet6\s+(?P<link_local>fe80:[0-9a-f:]+)/\d+\s+" + r"scope\s+link"
)


Expand Down
4 changes: 2 additions & 2 deletions testutils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def udp_server_check_output(self, count, delay_ms):
continue
try:
self.riotctrl.term.expect(
r"~~ SNIP 0 - size:\s+\d+ byte, type: NETTYPE_UNDEF " r"\(\d+\)"
r"~~ SNIP 0 - size:\s+\d+ byte, type: NETTYPE_UNDEF \(\d+\)"
)
self.riotctrl.term.expect(
r"~~ SNIP 1 - size:\s+\d+ byte, type: NETTYPE_UDP \(\d+\)"
Expand All @@ -147,7 +147,7 @@ def udp_server_check_output(self, count, delay_ms):
r"~~ SNIP 2 - size:\s+40 byte, type: NETTYPE_IPV6 \(\d+\)"
)
self.riotctrl.term.expect(
r"~~ SNIP 3 - size:\s+\d+ byte, type: NETTYPE_NETIF " r"\(-1\)"
r"~~ SNIP 3 - size:\s+\d+ byte, type: NETTYPE_NETIF \(-1\)"
)
self.riotctrl.term.expect(
r"~~ PKT\s+-\s+4 snips, total size:\s+\d+ byte"
Expand Down
68 changes: 34 additions & 34 deletions testutils/tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ def test_get_github(monkeypatch, access_token, expected):


def test_get_repo():
# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class MockGithub:
# pylint: disable=R0201,W0613
# pylint: disable=no-self-use,unused-argument
def get_repo(self, name):
return "I am repo"

assert testutils.github.get_repo(MockGithub()) == "I am repo"


def test_get_repo_error(caplog):
# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class MockGithub:
# pylint: disable=R0201,W0613
# pylint: disable=no-self-use,unused-argument
def get_repo(self, name):
raise testutils.github.GithubException(404, "I am not repo", None)

Expand Down Expand Up @@ -122,17 +122,17 @@ def get_repo(self, name):
],
)
def test_get_rc_tracking_issue(caplog, issue_titles, rc, expected_idx):
# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class MockIssue:
def __init__(self, title):
self.title = title

# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class MockRepo:
def __init__(self, issues):
self.issues = issues

# pylint: disable=W0613
# pylint: disable=unused-argument
def get_issues(self, *args, **kwargs):
for issue in self.issues:
yield issue
Expand All @@ -149,9 +149,9 @@ def get_issues(self, *args, **kwargs):


def test_get_rc_tracking_issue_error(caplog):
# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class MockRepo:
# pylint: disable=R0201,W0613
# pylint: disable=no-self-use,unused-argument
def get_issues(self, *args, **kwargs):
raise testutils.github.GithubException(403, "You don't get issues", None)

Expand Down Expand Up @@ -193,7 +193,7 @@ def __init__(self, body):
def body(self):
return self._body

# pylint: disable=W0613
# pylint: disable=unused-argument
def edit(self, body, *args, **kwargs):
self._body = body

Expand All @@ -213,14 +213,14 @@ class MockIssue:
def __init__(self, body):
self.body = body

# pylint: disable=W0613
# pylint: disable=unused-argument
def edit(self, body, *args, **kwargs):
self.body = body

def update(self):
pass

# pylint: disable=W0613
# pylint: disable=unused-argument
def _raise(*args, **kwargs):
raise testutils.github.GithubException(404, "This went wrong", None)

Expand All @@ -242,7 +242,7 @@ def __init__(self, body):
def body(self):
raise testutils.github.GithubException(404, "This went wrong", None)

# pylint: disable=W0613
# pylint: disable=unused-argument
def edit(self, body, *args, **kwargs):
self._body = body

Expand Down Expand Up @@ -352,15 +352,15 @@ def edit(self, body):


def _github(user_class=None):
# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class MockUser:
@property
def login(self):
return "user"

# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class MockGithub:
# pylint: disable=R0201
# pylint: disable=no-self-use
def get_user(self):
if user_class is None:
return MockUser()
Expand All @@ -381,15 +381,15 @@ def get_user(self):
],
)
def test_find_previous_comment(comments, exp):
class MockIssue: # pylint: disable=R0903
def get_comments(self): # pylint: disable=R0201
class MockIssue: # pylint: disable=too-few-public-methods
def get_comments(self): # pylint: disable=no-self-use
return comments

assert testutils.github.find_previous_comment(_github(), MockIssue()) == exp


def test_create_comment(monkeypatch, caplog):
class MockIssue: # pylint: disable=R0903
class MockIssue: # pylint: disable=too-few-public-methods
def __init__(self):
self.comment = None

Expand Down Expand Up @@ -420,8 +420,8 @@ def create_comment(self, comment):


def test_create_comment_error(caplog):
class MockIssue: # pylint: disable=R0903
def create_comment(self, comment): # pylint: disable=R0201
class MockIssue: # pylint: disable=too-few-public-methods
def create_comment(self, comment): # pylint: disable=no-self-use
raise testutils.github.GithubException(300, "Nope", None)

with caplog.at_level(logging.ERROR):
Expand Down Expand Up @@ -675,7 +675,7 @@ def when(self):
def test_update_comment(
monkeypatch, caplog, comment_body, env, gist_id, exp_body, exp_errs
):
# pylint: disable=R0913
# pylint: disable=too-many-arguments
# patch environment variables to not include run URL when run in Github
# Action
monkeypatch.setattr(testutils.github.os, "environ", env)
Expand Down Expand Up @@ -784,7 +784,7 @@ def mock_exists(self):

def test_update_comment_edit_error(monkeypatch, caplog):
class MockCommentEditError(MockComment):
def edit(self, body): # pylint: disable=R0201
def edit(self, body): # pylint: disable=no-self-use
raise testutils.github.GithubException(300, "Nope", None)

# isolate test environment
Expand Down Expand Up @@ -1114,7 +1114,7 @@ def test_upload_results(
),
],
)
# pylint: disable=R0913
# pylint: disable=too-many-arguments
def test_make_comment(monkeypatch, tmpdir, outcome, longrepr, sections, task, env):
class MockIssue:
def __init__(self):
Expand All @@ -1129,7 +1129,7 @@ def get_comments(self):
return [self.comment]
return []

# pylint: disable=R0903
# pylint: disable=too-few-public-methods
monkeypatch.setattr(testutils.github.os, "environ", env)
monkeypatch.setattr(testutils.github, "upload_results", lambda *args: None)
report = _get_mock_report(outcome, longrepr=longrepr, sections=sections)
Expand Down Expand Up @@ -1171,16 +1171,16 @@ def get_comments(self):
("failed", None, [], {"spec": {"spec": 5}, "name": "Lorem", "url": "t::test"}),
],
)
# pylint: disable=R0913
# pylint: disable=too-many-arguments
def test_make_comment_error(
monkeypatch, tmpdir, caplog, outcome, longrepr, sections, task
):
# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class MockIssue:
def __init__(self):
self.comment = None

# pylint: disable=R0201,W0613
# pylint: disable=no-self-use,unused-argument
def create_comment(self, comment):
raise testutils.github.GithubException(300, "Nope", None)

Expand All @@ -1198,7 +1198,7 @@ def create_comment(self, comment):


def _mock_update_issue():
# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class MockIssue:
@property
def body(self):
Expand Down Expand Up @@ -1430,7 +1430,7 @@ def __str__(self):
),
],
)
# pylint: disable=R0913,R0914
# pylint: disable=too-many-arguments,too-many-locals
def test_update_issue(
monkeypatch,
caplog,
Expand All @@ -1447,7 +1447,7 @@ def test_update_issue(
comment_error,
exp_marked,
):
# pylint: disable=R0903,W0621
# pylint: disable=too-few-public-methods,W0621
class MockComment:
@property
def html_url(self):
Expand All @@ -1465,7 +1465,7 @@ def html_url(self):
testutils.github, "get_rc_tracking_issue", lambda *args, **kwargs: issue
)
if task is None:
# pylint: disable=W0613
# pylint: disable=unused-argument
def _raise(*args, **kwargs):
raise testutils.github.GithubException(420, "Fail!", None)

Expand All @@ -1475,13 +1475,13 @@ def _raise(*args, **kwargs):
testutils.github, "find_task_text", lambda *args, **kwargs: task
)

# pylint: disable=W0613
# pylint: disable=unused-argument
def comment(*args, **kwargs):
if comment_error:
return None
return MockComment()

# pylint: disable=W0613
# pylint: disable=unused-argument
def mark(*args, **kwargs):
nonlocal task_marked_done
task_marked_done = True
Expand Down