From efa649e85b2c4a6201c5b57a72067390bf187ed8 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Aug 19 2020 22:33:43 +0000 Subject: frontend: silence pylint issues - Fix C&P problem - Work-around for our "commands" module, this naming was historically used in standard library and pylint thinks it actually is standard library (even though in Python 3 it isn't) --- diff --git a/frontend/coprs_frontend/commands/branch_fedora.py b/frontend/coprs_frontend/commands/branch_fedora.py index 97932f4..db77cc5 100644 --- a/frontend/coprs_frontend/commands/branch_fedora.py +++ b/frontend/coprs_frontend/commands/branch_fedora.py @@ -1,8 +1,12 @@ import click from coprs.logic import coprs_logic +# pylint: disable=wrong-import-order from commands.create_chroot import create_chroot_function -from commands.rawhide_to_release import rawhide_to_release_function +from commands.rawhide_to_release import ( + option_retry_forked, + rawhide_to_release_function, +) @click.command() @@ -10,14 +14,7 @@ from commands.rawhide_to_release import rawhide_to_release_function "fedora_version", type=int ) -@click.option( - "--retry-forked/--no-retry-forked", - default=False, - help=( - "Generate actions for backend also for already forked builds, useful " - "e.g. when previous run of this command failed." - ) -) +@option_retry_forked @click.option( "--dist-git-branch", "-b", "branch", help="Branch name for this set of new chroots" diff --git a/frontend/coprs_frontend/commands/rawhide_to_release.py b/frontend/coprs_frontend/commands/rawhide_to_release.py index 6bfb593..0882dc9 100644 --- a/frontend/coprs_frontend/commands/rawhide_to_release.py +++ b/frontend/coprs_frontend/commands/rawhide_to_release.py @@ -8,6 +8,19 @@ from coprs import models from coprs.logic import coprs_logic, actions_logic, builds_logic, packages_logic +def option_retry_forked(f): + """ Shortcut to --retry-forked option definition, to avoid C&P """ + method = click.option( + "--retry-forked/--no-retry-forked", + default=False, + help=( + "Generate actions for backend also for already forked builds, useful " + "e.g. when previous run of this command failed." + ) + ) + return method(f) + + @click.command() @click.argument( "rawhide_chroot", @@ -17,14 +30,7 @@ from coprs.logic import coprs_logic, actions_logic, builds_logic, packages_logic "dest_chroot", required=True ) -@click.option( - "--retry-forked/--no-retry-forked", - default=False, - help=( - "Generate actions for backend also for already forked builds, useful " - "e.g. when previous run of this command failed." - ) -) +@option_retry_forked def rawhide_to_release(rawhide_chroot, dest_chroot, retry_forked): """ Branching diff --git a/frontend/coprs_frontend/tests/test_commands/test_rawhide_to_release.py b/frontend/coprs_frontend/tests/test_commands/test_rawhide_to_release.py index 6fa0403..c7567fe 100644 --- a/frontend/coprs_frontend/tests/test_commands/test_rawhide_to_release.py +++ b/frontend/coprs_frontend/tests/test_commands/test_rawhide_to_release.py @@ -7,8 +7,9 @@ import pytest from coprs import db, models from coprs.logic import coprs_logic from tests.coprs_test_case import CoprsTestCase, new_app_context -from commands.branch_fedora import branch_fedora_function from copr_common.enums import StatusEnum +# pylint: disable=wrong-import-order +from commands.branch_fedora import branch_fedora_function @pytest.mark.usefixtures("f_copr_chroots_assigned_finished")