Repository: repobee/repobee
Pull request #515 (2020-07-23 10:38:23)

[fact] Rename command_callback to command
Applies to #501

codecov[bot]: # [Codecov](https://codecov.io/gh/repobee/repobee/pull/515?src=pr&el=h1) Report
> Merging [#515](https://codecov.io/gh/repobee/repobee/pull/515?src=pr&el=desc) into [master](https://codecov.io/gh/repobee/repobee/commit/7409c888741945b36574343744599555b661813f&el=desc) will **decrease** coverage by `0.06%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/repobee/repobee/pull/515/graphs/tree.svg?width=650&height=150&src=pr&token=5vOKgkphZe)](https://codecov.io/gh/repobee/repobee/pull/515?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #515      +/-   ##
==========================================
- Coverage   88.27%   88.21%   -0.07%     
==========================================
  Files          43       43              
  Lines        2507     2494      -13     
  Branches      409      409              
==========================================
- Hits         2213     2200      -13     
  Misses        249      249              
  Partials       45       45              
```


| [Impacted Files](https://codecov.io/gh/repobee/repobee/pull/515?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/repobee\_plug/\_pluginmeta.py](https://codecov.io/gh/repobee/repobee/pull/515/diff?src=pr&el=tree#diff-c3JjL3JlcG9iZWVfcGx1Zy9fcGx1Z2lubWV0YS5weQ==) | `93.18% <ø> (-0.16%)` | :arrow_down: |
| [src/repobee\_plug/cli.py](https://codecov.io/gh/repobee/repobee/pull/515/diff?src=pr&el=tree#diff-c3JjL3JlcG9iZWVfcGx1Zy9jbGkucHk=) | `94.61% <ø> (-0.05%)` | :arrow_down: |
| [src/\_repobee/ext/defaults/configwizard.py](https://codecov.io/gh/repobee/repobee/pull/515/diff?src=pr&el=tree#diff-c3JjL19yZXBvYmVlL2V4dC9kZWZhdWx0cy9jb25maWd3aXphcmQucHk=) | `97.29% <100.00%> (ø)` | |
| [src/\_repobee/ext/query.py](https://codecov.io/gh/repobee/repobee/pull/515/diff?src=pr&el=tree#diff-c3JjL19yZXBvYmVlL2V4dC9xdWVyeS5weQ==) | `48.48% <0.00%> (-1.52%)` | :arrow_down: |
| [src/\_repobee/ext/gitlab.py](https://codecov.io/gh/repobee/repobee/pull/515/diff?src=pr&el=tree#diff-c3JjL19yZXBvYmVlL2V4dC9naXRsYWIucHk=) | `63.86% <0.00%> (-0.40%)` | :arrow_down: |
| [src/\_repobee/ext/defaults/github.py](https://codecov.io/gh/repobee/repobee/pull/515/diff?src=pr&el=tree#diff-c3JjL19yZXBvYmVlL2V4dC9kZWZhdWx0cy9naXRodWIucHk=) | `90.29% <0.00%> (-0.11%)` | :arrow_down: |
| [src/\_repobee/plugin.py](https://codecov.io/gh/repobee/repobee/pull/515/diff?src=pr&el=tree#diff-c3JjL19yZXBvYmVlL3BsdWdpbi5weQ==) | `95.03% <0.00%> (-0.04%)` | :arrow_down: |
| [src/repobee\_plug/\_corehooks.py](https://codecov.io/gh/repobee/repobee/pull/515/diff?src=pr&el=tree#diff-c3JjL3JlcG9iZWVfcGx1Zy9fY29yZWhvb2tzLnB5) | `100.00% <0.00%> (ø)` | |
| ... and [1 more](https://codecov.io/gh/repobee/repobee/pull/515/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/repobee/repobee/pull/515?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/repobee/repobee/pull/515?src=pr&el=footer). Last update [7409c88...e320995](https://codecov.io/gh/repobee/repobee/pull/515?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/_repobee/ext/defaults/configwizard.py b/src/_repobee/ext/defaults/configwizard.py
index 16707cc..21a86c8 100644
--- a/src/_repobee/ext/defaults/configwizard.py
+++ b/src/_repobee/ext/defaults/configwizard.py
@@ -30,9 +30,7 @@ class Wizard(plug.Plugin, plug.cli.Command):
         ),
     )
 
-    def command_callback(
-        self, args: argparse.Namespace, api: plug.API
-    ) -> None:
+    def command(self, args: argparse.Namespace, api: plug.API) -> None:
         return callback(args, api)
 
 
diff --git a/src/repobee_plug/_pluginmeta.py b/src/repobee_plug/_pluginmeta.py
index ce6bd42..a74cf78 100644
--- a/src/repobee_plug/_pluginmeta.py
+++ b/src/repobee_plug/_pluginmeta.py
@@ -87,9 +87,7 @@ class _PluginMeta(type):
         return {
             key: value
             for key, value in attrdict.items()
-            if callable(value)
-            and not key.startswith("_")
-            and key != "command_callback"
+            if callable(value) and not key.startswith("_") and key != "command"
         }
 
 
@@ -166,7 +164,7 @@ def _generate_command_func(attrdict: Mapping[str, Any]) -> Callable:
             or self.__class__.__name__.lower().replace("_", "-"),
             help=settings.help,
             description=settings.description,
-            callback=self.command_callback,
+            callback=self.command,
             category=settings.category,
             requires_api=settings.requires_api,
             requires_base_parsers=settings.base_parsers,
diff --git a/src/repobee_plug/cli.py b/src/repobee_plug/cli.py
index 99aa139..eb3e7d2 100644
--- a/src/repobee_plug/cli.py
+++ b/src/repobee_plug/cli.py
@@ -89,7 +89,7 @@ def command_settings(
                 category=plug.cli.CoreCommand.config,
             )
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 print("Hello, world!")
 
     This can then be called with:
@@ -175,7 +175,7 @@ def option(
             name = plug.cli.option(help="Your name.")
             age = plug.cli.option(converter=int, help="Your age.")
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 print(
                     f"Hello, my name is {args.name} "
                     f"and I am {args.age} years old"
@@ -241,7 +241,7 @@ def positional(
             name = plug.cli.Positional(help="Your name.")
             age = plug.cli.Positional(converter=int, help="Your age.")
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 print(
                     f"Hello, my name is {args.name} "
                     f"and I am {args.age} years old"
@@ -316,7 +316,7 @@ class Command:
 
     .. code-block:: python
 
-        def command_callback(
+        def command(
             self, args: argparse.Namespace, api: plug.API
         ) -> Optional[plug.Result]:
             pass
@@ -326,7 +326,7 @@ class Command:
 
     .. code-block:: python
 
-        def command_callback(self, args, api):
+        def command(self, args, api):
             pass
 
     Declaring static members of type :py:class:`Option` will add command line
@@ -349,7 +349,7 @@ class Command:
                 converter=int, help="your age", default=30
             )
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 print(f"Hello, my name is {args.name} and I am {args.age}")
 
     Note that the file is called ``command.py``. We can run this command with


Test patch:
diff --git a/tests/unit_tests/repobee_plug/test_pluginmeta.py b/tests/unit_tests/repobee_plug/test_pluginmeta.py
index 75f599d..b997f00 100644
--- a/tests/unit_tests/repobee_plug/test_pluginmeta.py
+++ b/tests/unit_tests/repobee_plug/test_pluginmeta.py
@@ -123,7 +123,7 @@ class TestDeclarativeExtensionCommand:
             name = plug.cli.option(help="your name", required=True)
             age = plug.cli.option(converter=int, help="your age", default=30)
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 print(f"My name is {args.name} and I am {args.age} years old")
 
         return Greeting
@@ -139,7 +139,7 @@ class TestDeclarativeExtensionCommand:
         assert ext_cmd.name == basic_greeting_command.__name__.lower()
         assert ext_cmd.help == ""
         assert ext_cmd.description == ""
-        assert ext_cmd.callback == plugin_instance.command_callback
+        assert ext_cmd.callback == plugin_instance.command
         assert ext_cmd.requires_api is False
         assert ext_cmd.requires_base_parsers is None
         assert ext_cmd.category is None
@@ -166,7 +166,7 @@ class TestDeclarativeExtensionCommand:
                 requires_api=expected_requires_api,
             )
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 pass
 
         plugin_instance = ExtCommand("greeting")
@@ -176,7 +176,7 @@ class TestDeclarativeExtensionCommand:
         assert ext_cmd.name == expected_name
         assert ext_cmd.help == expected_help
         assert ext_cmd.description == expected_description
-        assert ext_cmd.callback == plugin_instance.command_callback
+        assert ext_cmd.callback == plugin_instance.command
         assert ext_cmd.requires_api == expected_requires_api
         assert ext_cmd.requires_base_parsers == expected_base_parsers
 
@@ -198,7 +198,7 @@ class TestDeclarativeExtensionCommand:
                 help="Your name.", required=True, configurable=True
             )
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 pass
 
         plugin_name = "greeting"
@@ -220,7 +220,7 @@ class TestDeclarativeExtensionCommand:
         class Greeting(plug.Plugin, plug.cli.Command):
             name = plug.cli.option(help="Your name.", required=True)
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 pass
 
         plugin_name = "greeting"
@@ -253,7 +253,7 @@ class TestDeclarativeExtensionCommand:
                 required=True,
             )
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 pass
 
         ext_cmd = Greeting("g").create_extension_command()
@@ -272,7 +272,7 @@ class TestDeclarativeExtensionCommand:
             name = plug.cli.positional()
             age = plug.cli.positional(converter=int)
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 pass
 
         ext_cmd = Greeting("g").create_extension_command()
@@ -300,7 +300,7 @@ class TestDeclarativeExtensionCommand:
                 __required__=True,
             )
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 pass
 
         ext_cmd = Greeting("g").create_extension_command()
@@ -342,7 +342,7 @@ class TestDeclarativeExtensionCommand:
                 __required__=True,
             )
 
-            def command_callback(self, args, api):
+            def command(self, args, api):
                 pass
 
         ext_cmd = Greeting("g").create_extension_command()