Verified Commit 2a1c9553 authored by Naveen's avatar Naveen 👽

Apply coala fixes

parent f701d533
......@@ -57,7 +57,7 @@ def get_plugins() -> [str]:
and is_plugin(path.abspath(path.join(plugin_dir, dir)))]
def run_in_container(image: str, *args: [str], stdin: str=None) -> str:
def run_in_container(image: str, *args: [str], stdin: str = None) -> str:
"""
Runs a docker container with the specified image and command and returns
the output.
......
......@@ -181,7 +181,7 @@ class Repository(models.Model):
for k, v in plugin.get_settings(self).items()}
@settings.setter
def settings(self, plugins: Optional[List]=None):
def settings(self, plugins: Optional[List] = None):
"""
Sets the plugin settings for all plugins for the specified repo.
"""
......@@ -227,7 +227,7 @@ class Repository(models.Model):
config.set_settings(self, plugin['settings'])
@classmethod
def from_igitt_repo(cls, instance: IGittRepository, active: bool=True):
def from_igitt_repo(cls, instance: IGittRepository, active: bool = True):
"""
Retrieves a repository model from an IGitt Repository instance.
......
......@@ -18,12 +18,12 @@ class TestResponderRegistrar(GitmateTestCase):
@ResponderRegistrar.responder(self.plugin,
MergeRequestActions.OPENED)
def test_responder(obj, example_bool_setting: bool = True):
def test_responder(_, example_bool_setting: bool = True):
return example_bool_setting
@ResponderRegistrar.scheduled_responder(
self.plugin, 100.00, is_active=True)
def scheduled_responder_function(obj, example_bool_setting: bool=True):
def scheduled_responder_function(_, example_bool_setting: bool = True):
return example_bool_setting
@patch.object(GitHubComment, 'body', new_callable=PropertyMock)
......@@ -31,7 +31,7 @@ class TestResponderRegistrar(GitmateTestCase):
@ResponderRegistrar.responder(self.plugin,
MergeRequestActions.COMMENTED)
def test_blocked_responder(mr, comment, *args, **kwargs):
def test_blocked_responder(_, comment, *args, **kwargs):
# this should never run
return comment.body # pragma: no cover
......
......@@ -22,7 +22,7 @@ from gitmate_hooks.decorators import block_comment
def run_plugin_for_all_repos(plugin_name: str,
event_name: (str, Enum),
is_active: bool=True):
is_active: bool = True):
"""
This will trigger the responders registered with `event_name`
for every repo based on active state of a plugin.
......@@ -166,7 +166,7 @@ class ResponderRegistrar:
@classmethod
def responder(cls, plugin_name: str, *actions: [Enum],
queue: Enum=TaskQueue.SHORT):
queue: Enum = TaskQueue.SHORT):
"""
Registers the decorated function as a responder to the actions
provided. Specifying description as defaults on option specific args
......@@ -201,8 +201,8 @@ class ResponderRegistrar:
@classmethod
def _get_responders(cls,
event: Enum,
repo: Repository=None,
plugin_name: str=None) -> [ExceptionLoggerTask]:
repo: Repository = None,
plugin_name: str = None) -> [ExceptionLoggerTask]:
"""
Retrieves the list of responders for the specified event. Filters only
the ones within a plugin, if ``plugin name`` is specified. Filters only
......@@ -227,8 +227,8 @@ class ResponderRegistrar:
def respond(cls,
event: Enum,
*args,
repo: Repository=None,
plugin_name: str=None):
repo: Repository = None,
plugin_name: str = None):
"""
Invoke all responders for the given event. If a plugin name is
specified, invokes responders only within that plugin.
......
......@@ -31,8 +31,8 @@ def store_head_commit_sha(pr: MergeRequest):
'approver', PipelineActions.UPDATED)
def add_approved_label(
commit: Commit,
approved_label: str='status/ci-approved',
status_labels: str='status/pending_review, status/WIP'
approved_label: str = 'status/ci-approved',
status_labels: str = 'status/pending_review, status/WIP'
):
"""
Labels the PR as approved when the head commit passes all tests.
......
......@@ -12,8 +12,8 @@ from gitmate_hooks.utils import ResponderRegistrar
)
def mark_pending_review_or_wip_accordingly(
pr: MergeRequest,
wip_label: str='Work in progress',
pending_review_label: str='Review pending'
wip_label: str = 'Work in progress',
pending_review_label: str = 'Review pending'
):
"""
Labels the pull request as pending review and removes work in
......@@ -40,12 +40,12 @@ def mark_pending_review_or_wip_accordingly(
)
def check_keywords_in_commit_messages(
pr: MergeRequest,
wip_label: str='Work in progress',
pending_review_label: str='Review pending',
enable_fixes_vs_closes: bool=False,
bug_label: str='type/bug',
no_bug_label_message: str='Fixes is used but issue has no bug label',
bug_label_message: str='Closes is used but issue has bug label'
wip_label: str = 'Work in progress',
pending_review_label: str = 'Review pending',
enable_fixes_vs_closes: bool = False,
bug_label: str = 'type/bug',
no_bug_label_message: str = 'Fixes is used but issue has no bug label',
bug_label_message: str = 'Closes is used but issue has bug label'
):
"""
Label the pull request as work in progress and remove pending review label
......
......@@ -111,7 +111,7 @@ def result_table_row(result):
)
def add_comment(commit: Commit, results: dict, mr_num: int=None):
def add_comment(commit: Commit, results: dict, mr_num: int = None):
for section_name, section_results in results.items():
if len(section_results) > 10:
commit.comment(
......@@ -161,8 +161,8 @@ def get_ref(pr): # pragma: no cover, testing this with mocks is meaningless
MergeRequestActions.SYNCHRONIZED,
MergeRequestActions.OPENED
)
def run_code_analysis(pr: MergeRequest, pr_based_analysis: bool=True,
coafile_location: str='.coafile'):
def run_code_analysis(pr: MergeRequest, pr_based_analysis: bool = True,
coafile_location: str = '.coafile'):
"""
Starts code analysis on the merge request.
"""
......
......@@ -26,8 +26,8 @@ def popen_coala():
def fake_fetch(url: str, req_type: str, token: str,
data: dict = None, query_params: dict=None,
headers: dict=frozenset()):
data: dict = None, query_params: dict = None,
headers: dict = frozenset()):
if '/repository/commits' in url:
return {
'sha': 'deadbeef',
......
......@@ -19,7 +19,7 @@ from .models import MergeRequestModel
MergeRequestActions.SYNCHRONIZED
)
def sync_updated_pr_with_issue(pr: MergeRequest,
sync_assignees: bool='Synchronize Assignees'):
sync_assignees: bool = 'Synchronize Assignees'):
issues = pr.closes_issues
repo = Repository.from_igitt_repo(pr.repository)
pr_obj = MergeRequestModel.objects.get_or_create(
......@@ -76,7 +76,7 @@ def sync_label_remove_from_issue_with_pr(issue: Issue, label: str):
IssueActions.ATTRIBUTES_CHANGED
)
def sync_pr_with_updated_issue(issue: Issue,
sync_assignees: bool='Synchronize Assignees'):
sync_assignees: bool = 'Synchronize Assignees'):
if not sync_assignees: # pragma: no cover
return
......
......@@ -12,8 +12,8 @@ from gitmate_hooks.utils import ResponderRegistrar
)
def notify_merge_conflicts(
pr: MergeRequest,
conflicts_label: str='rebase',
conflicts_message: str='Resolve conflicts message'
conflicts_label: str = 'rebase',
conflicts_message: str = 'Resolve conflicts message'
):
"""
Check the pull request for merge conflicts, if pull request has merge
......
......@@ -10,7 +10,8 @@ from gitmate_hooks.utils import ResponderRegistrar
MergeRequestActions.SYNCHRONIZED,
MergeRequestActions.OPENED,
)
def add_labels_based_on_size(pr: MergeRequest, size_scheme: str='size/{size}'):
def add_labels_based_on_size(pr: MergeRequest,
size_scheme: str = 'size/{size}'):
"""
Labels the pull request with size labels according to the amount of
code touched, commits and files involved. Helps plan the review in
......
......@@ -58,13 +58,13 @@ def get_matched_command(body: str, username: str):
@ResponderRegistrar.responder('rebaser', MergeRequestActions.COMMENTED)
def apply_command_on_merge_request(
pr: MergeRequest, comment: Comment,
enable_rebase: bool=False,
enable_merge: bool=False,
enable_squash: bool=False,
enable_fastforward: bool=False,
merge_admin_only: bool=True,
fastforward_admin_only: bool=True,
squash_admin_only: bool=True
enable_rebase: bool = False,
enable_merge: bool = False,
enable_squash: bool = False,
enable_fastforward: bool = False,
merge_admin_only: bool = True,
fastforward_admin_only: bool = True,
squash_admin_only: bool = True
):
"""
Performs a merge, fastforward, squash or rebase of a merge request when an
......
......@@ -14,8 +14,8 @@ from gitmate_hooks.utils import ResponderRegistrar
@ResponderRegistrar.responder('scrum', IssueActions.ASSIGNEES_CHANGED)
def mark_issue_ongoing(issue: Issue,
usernames: Set[str],
operating_namespace: str='dev',
ongoing_label: str='ongoing'):
operating_namespace: str = 'dev',
ongoing_label: str = 'ongoing'):
labels = issue.labels
ns_regex = re.compile('^{}/.*$'.format(operating_namespace))
if bool(usernames):
......@@ -30,9 +30,9 @@ def mark_issue_ongoing(issue: Issue,
MergeRequestActions.OPENED,
MergeRequestActions.REOPENED)
def mark_as_review_or_acceptance(pr: MergeRequest,
operating_namespace: str='dev',
review_label: str='code-review',
acceptance_label: str='acceptance-QA'):
operating_namespace: str = 'dev',
review_label: str = 'code-review',
acceptance_label: str = 'acceptance-QA'):
labels = pr.labels
ns_regex = re.compile('^{}/.*$'.format(operating_namespace))
qa_regex = re.compile(
......
......@@ -10,8 +10,8 @@ from gitmate_hooks.utils import ResponderRegistrar
IssueActions.REOPENED)
def check_presence_of_issue_weight(issue: Issue,
*args,
no_weight_label: str='weight/missing',
check_issue_weight_presence: bool=False):
no_weight_label: str = 'weight/missing',
check_issue_weight_presence: bool = False):
if check_issue_weight_presence:
try:
if issue.weight is not None:
......@@ -28,9 +28,9 @@ def check_presence_of_issue_weight(issue: Issue,
IssueActions.REOPENED)
def check_for_overweight_issues(issue: Issue,
*args,
check_overweight_issues: bool=False,
max_issue_weight: int=4,
max_weight_label: str='weight/overweight'):
check_overweight_issues: bool = False,
max_issue_weight: int = 4,
max_weight_label: str = 'weight/overweight'):
if check_overweight_issues:
try:
if issue.weight is not None and issue.weight > max_issue_weight:
......
......@@ -8,7 +8,7 @@ from gitmate_hooks.utils import ResponderRegistrar
@ResponderRegistrar.responder('welcome_commenter', MergeRequestActions.OPENED)
def add_welcome_comment(
pr: MergeRequest,
autorespond_text: str='Hi! This is GitMate v2.0!'
autorespond_text: str = 'Hi! This is GitMate v2.0!'
):
"""
Adds a welcome comment to pull requests.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment