We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add "radon" tool to the Backend and enable it in CI
## Expected Behavior

Python code in backend should be validated by "radon" tool in CI.

## Actual Behavior

MedTagger backend uses a few linters already but we should add more validators to increate automation and code quality.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `backend/scripts/migrate_hbase.py`
Content:
```
1 """Script that can migrate existing HBase schema or prepare empty database with given schema.
2 
3 How to use it?
4 --------------
5 Run this script just by executing following line in the root directory of this project:
6 
7     (venv) $ python3.6 scripts/migrate_hbase.py
8 
9 """
10 import argparse
11 import logging
12 import logging.config
13 
14 from medtagger.clients.hbase_client import HBaseClient
15 from utils import get_connection_to_hbase, user_agrees
16 
17 logging.config.fileConfig('logging.conf')
18 logger = logging.getLogger(__name__)
19 
20 parser = argparse.ArgumentParser(description='HBase migration.')
21 parser.add_argument('-y', '--yes', dest='yes', action='store_const', const=True)
22 args = parser.parse_args()
23 
24 
25 HBASE_SCHEMA = HBaseClient.HBASE_SCHEMA
26 connection = get_connection_to_hbase()
27 existing_tables = set(connection.tables())
28 schema_tables = set(HBASE_SCHEMA)
29 tables_to_drop = list(existing_tables - schema_tables)
30 for table_name in tables_to_drop:
31     if args.yes or user_agrees('Do you want to drop table "{}"?'.format(table_name)):
32         logger.info('Dropping table "%s".', table_name)
33         table = connection.table(table_name)
34         table.drop()
35 
36 for table_name in HBASE_SCHEMA:
37     table = connection.table(table_name)
38     if not table.exists():
39         if args.yes or user_agrees('Do you want to create table "{}"?'.format(table_name)):
40             list_of_columns = HBASE_SCHEMA[table_name]
41             logger.info('Creating table "%s" with columns %s.', table_name, list_of_columns)
42             table.create(*list_of_columns)
43             table.enable_if_exists_checks()
44     else:
45         existing_column_families = set(table.columns())
46         schema_column_families = set(HBASE_SCHEMA[table_name])
47         columns_to_add = list(schema_column_families - existing_column_families)
48         columns_to_drop = list(existing_column_families - schema_column_families)
49 
50         if columns_to_add:
51             if args.yes or user_agrees('Do you want to add columns {} to "{}"?'.format(columns_to_add, table_name)):
52                 table.add_columns(*columns_to_add)
53 
54         if columns_to_drop:
55             if args.yes or user_agrees('Do you want to drop columns {} from "{}"?'.format(columns_to_drop, table_name)):
56                 table.drop_columns(*columns_to_drop)
57
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/backend/scripts/migrate_hbase.py b/backend/scripts/migrate_hbase.py
--- a/backend/scripts/migrate_hbase.py
+++ b/backend/scripts/migrate_hbase.py
@@ -11,6 +11,8 @@
 import logging
 import logging.config
 
+from starbase import Table
+
 from medtagger.clients.hbase_client import HBaseClient
 from utils import get_connection_to_hbase, user_agrees
 
@@ -22,35 +24,59 @@
 args = parser.parse_args()
 
 
-HBASE_SCHEMA = HBaseClient.HBASE_SCHEMA
-connection = get_connection_to_hbase()
-existing_tables = set(connection.tables())
-schema_tables = set(HBASE_SCHEMA)
-tables_to_drop = list(existing_tables - schema_tables)
-for table_name in tables_to_drop:
+def create_new_table(table: Table) -> None:
+    """Create new table once user agrees on that."""
+    table_name = table.name
+    if args.yes or user_agrees('Do you want to create table "{}"?'.format(table_name)):
+        list_of_columns = HBaseClient.HBASE_SCHEMA[table_name]
+        logger.info('Creating table "%s" with columns %s.', table_name, list_of_columns)
+        table.create(*list_of_columns)
+        table.enable_if_exists_checks()
+
+
+def update_table_schema(table: Table) -> None:
+    """Update table schema once user agrees on that."""
+    table_name = table.name
+    existing_column_families = set(table.columns())
+    schema_column_families = set(HBaseClient.HBASE_SCHEMA[table_name])
+    columns_to_add = list(schema_column_families - existing_column_families)
+    columns_to_drop = list(existing_column_families - schema_column_families)
+
+    if columns_to_add:
+        if args.yes or user_agrees('Do you want to add columns {} to "{}"?'.format(columns_to_add, table_name)):
+            table.add_columns(*columns_to_add)
+
+    if columns_to_drop:
+        if args.yes or user_agrees('Do you want to drop columns {} from "{}"?'.format(columns_to_drop, table_name)):
+            table.drop_columns(*columns_to_drop)
+
+
+def drop_table(table: Table) -> None:
+    """Drop table once user agrees on that."""
+    table_name = table.name
     if args.yes or user_agrees('Do you want to drop table "{}"?'.format(table_name)):
         logger.info('Dropping table "%s".', table_name)
-        table = connection.table(table_name)
         table.drop()
 
-for table_name in HBASE_SCHEMA:
-    table = connection.table(table_name)
-    if not table.exists():
-        if args.yes or user_agrees('Do you want to create table "{}"?'.format(table_name)):
-            list_of_columns = HBASE_SCHEMA[table_name]
-            logger.info('Creating table "%s" with columns %s.', table_name, list_of_columns)
-            table.create(*list_of_columns)
-            table.enable_if_exists_checks()
-    else:
-        existing_column_families = set(table.columns())
-        schema_column_families = set(HBASE_SCHEMA[table_name])
-        columns_to_add = list(schema_column_families - existing_column_families)
-        columns_to_drop = list(existing_column_families - schema_column_families)
-
-        if columns_to_add:
-            if args.yes or user_agrees('Do you want to add columns {} to "{}"?'.format(columns_to_add, table_name)):
-                table.add_columns(*columns_to_add)
-
-        if columns_to_drop:
-            if args.yes or user_agrees('Do you want to drop columns {} from "{}"?'.format(columns_to_drop, table_name)):
-                table.drop_columns(*columns_to_drop)
+
+def main() -> None:
+    """Run main functionality of this script."""
+    connection = get_connection_to_hbase()
+    existing_tables = set(connection.tables())
+    schema_tables = set(HBaseClient.HBASE_SCHEMA)
+    tables_to_drop = list(existing_tables - schema_tables)
+
+    for table_name in tables_to_drop:
+        table = connection.table(table_name)
+        drop_table(table)
+
+    for table_name in HBaseClient.HBASE_SCHEMA:
+        table = connection.table(table_name)
+        if not table.exists():
+            create_new_table(table)
+        else:
+            update_table_schema(table)
+
+
+if __name__ == '__main__':
+    main()

{"golden_diff": "diff --git a/backend/scripts/migrate_hbase.py b/backend/scripts/migrate_hbase.py\n--- a/backend/scripts/migrate_hbase.py\n+++ b/backend/scripts/migrate_hbase.py\n@@ -11,6 +11,8 @@\n import logging\n import logging.config\n \n+from starbase import Table\n+\n from medtagger.clients.hbase_client import HBaseClient\n from utils import get_connection_to_hbase, user_agrees\n \n@@ -22,35 +24,59 @@\n args = parser.parse_args()\n \n \n-HBASE_SCHEMA = HBaseClient.HBASE_SCHEMA\n-connection = get_connection_to_hbase()\n-existing_tables = set(connection.tables())\n-schema_tables = set(HBASE_SCHEMA)\n-tables_to_drop = list(existing_tables - schema_tables)\n-for table_name in tables_to_drop:\n+def create_new_table(table: Table) -> None:\n+    \"\"\"Create new table once user agrees on that.\"\"\"\n+    table_name = table.name\n+    if args.yes or user_agrees('Do you want to create table \"{}\"?'.format(table_name)):\n+        list_of_columns = HBaseClient.HBASE_SCHEMA[table_name]\n+        logger.info('Creating table \"%s\" with columns %s.', table_name, list_of_columns)\n+        table.create(*list_of_columns)\n+        table.enable_if_exists_checks()\n+\n+\n+def update_table_schema(table: Table) -> None:\n+    \"\"\"Update table schema once user agrees on that.\"\"\"\n+    table_name = table.name\n+    existing_column_families = set(table.columns())\n+    schema_column_families = set(HBaseClient.HBASE_SCHEMA[table_name])\n+    columns_to_add = list(schema_column_families - existing_column_families)\n+    columns_to_drop = list(existing_column_families - schema_column_families)\n+\n+    if columns_to_add:\n+        if args.yes or user_agrees('Do you want to add columns {} to \"{}\"?'.format(columns_to_add, table_name)):\n+            table.add_columns(*columns_to_add)\n+\n+    if columns_to_drop:\n+        if args.yes or user_agrees('Do you want to drop columns {} from \"{}\"?'.format(columns_to_drop, table_name)):\n+            table.drop_columns(*columns_to_drop)\n+\n+\n+def drop_table(table: Table) -> None:\n+    \"\"\"Drop table once user agrees on that.\"\"\"\n+    table_name = table.name\n     if args.yes or user_agrees('Do you want to drop table \"{}\"?'.format(table_name)):\n         logger.info('Dropping table \"%s\".', table_name)\n-        table = connection.table(table_name)\n         table.drop()\n \n-for table_name in HBASE_SCHEMA:\n-    table = connection.table(table_name)\n-    if not table.exists():\n-        if args.yes or user_agrees('Do you want to create table \"{}\"?'.format(table_name)):\n-            list_of_columns = HBASE_SCHEMA[table_name]\n-            logger.info('Creating table \"%s\" with columns %s.', table_name, list_of_columns)\n-            table.create(*list_of_columns)\n-            table.enable_if_exists_checks()\n-    else:\n-        existing_column_families = set(table.columns())\n-        schema_column_families = set(HBASE_SCHEMA[table_name])\n-        columns_to_add = list(schema_column_families - existing_column_families)\n-        columns_to_drop = list(existing_column_families - schema_column_families)\n-\n-        if columns_to_add:\n-            if args.yes or user_agrees('Do you want to add columns {} to \"{}\"?'.format(columns_to_add, table_name)):\n-                table.add_columns(*columns_to_add)\n-\n-        if columns_to_drop:\n-            if args.yes or user_agrees('Do you want to drop columns {} from \"{}\"?'.format(columns_to_drop, table_name)):\n-                table.drop_columns(*columns_to_drop)\n+\n+def main() -> None:\n+    \"\"\"Run main functionality of this script.\"\"\"\n+    connection = get_connection_to_hbase()\n+    existing_tables = set(connection.tables())\n+    schema_tables = set(HBaseClient.HBASE_SCHEMA)\n+    tables_to_drop = list(existing_tables - schema_tables)\n+\n+    for table_name in tables_to_drop:\n+        table = connection.table(table_name)\n+        drop_table(table)\n+\n+    for table_name in HBaseClient.HBASE_SCHEMA:\n+        table = connection.table(table_name)\n+        if not table.exists():\n+            create_new_table(table)\n+        else:\n+            update_table_schema(table)\n+\n+\n+if __name__ == '__main__':\n+    main()\n", "issue": "Add \"radon\" tool to the Backend and enable it in CI\n## Expected Behavior\r\n\r\nPython code in backend should be validated by \"radon\" tool in CI.\r\n\r\n## Actual Behavior\r\n\r\nMedTagger backend uses a few linters already but we should add more validators to increate automation and code quality.\n", "before_files": [{"content": "\"\"\"Script that can migrate existing HBase schema or prepare empty database with given schema.\n\nHow to use it?\n--------------\nRun this script just by executing following line in the root directory of this project:\n\n    (venv) $ python3.6 scripts/migrate_hbase.py\n\n\"\"\"\nimport argparse\nimport logging\nimport logging.config\n\nfrom medtagger.clients.hbase_client import HBaseClient\nfrom utils import get_connection_to_hbase, user_agrees\n\nlogging.config.fileConfig('logging.conf')\nlogger = logging.getLogger(__name__)\n\nparser = argparse.ArgumentParser(description='HBase migration.')\nparser.add_argument('-y', '--yes', dest='yes', action='store_const', const=True)\nargs = parser.parse_args()\n\n\nHBASE_SCHEMA = HBaseClient.HBASE_SCHEMA\nconnection = get_connection_to_hbase()\nexisting_tables = set(connection.tables())\nschema_tables = set(HBASE_SCHEMA)\ntables_to_drop = list(existing_tables - schema_tables)\nfor table_name in tables_to_drop:\n    if args.yes or user_agrees('Do you want to drop table \"{}\"?'.format(table_name)):\n        logger.info('Dropping table \"%s\".', table_name)\n        table = connection.table(table_name)\n        table.drop()\n\nfor table_name in HBASE_SCHEMA:\n    table = connection.table(table_name)\n    if not table.exists():\n        if args.yes or user_agrees('Do you want to create table \"{}\"?'.format(table_name)):\n            list_of_columns = HBASE_SCHEMA[table_name]\n            logger.info('Creating table \"%s\" with columns %s.', table_name, list_of_columns)\n            table.create(*list_of_columns)\n            table.enable_if_exists_checks()\n    else:\n        existing_column_families = set(table.columns())\n        schema_column_families = set(HBASE_SCHEMA[table_name])\n        columns_to_add = list(schema_column_families - existing_column_families)\n        columns_to_drop = list(existing_column_families - schema_column_families)\n\n        if columns_to_add:\n            if args.yes or user_agrees('Do you want to add columns {} to \"{}\"?'.format(columns_to_add, table_name)):\n                table.add_columns(*columns_to_add)\n\n        if columns_to_drop:\n            if args.yes or user_agrees('Do you want to drop columns {} from \"{}\"?'.format(columns_to_drop, table_name)):\n                table.drop_columns(*columns_to_drop)\n", "path": "backend/scripts/migrate_hbase.py"}], "after_files": [{"content": "\"\"\"Script that can migrate existing HBase schema or prepare empty database with given schema.\n\nHow to use it?\n--------------\nRun this script just by executing following line in the root directory of this project:\n\n    (venv) $ python3.6 scripts/migrate_hbase.py\n\n\"\"\"\nimport argparse\nimport logging\nimport logging.config\n\nfrom starbase import Table\n\nfrom medtagger.clients.hbase_client import HBaseClient\nfrom utils import get_connection_to_hbase, user_agrees\n\nlogging.config.fileConfig('logging.conf')\nlogger = logging.getLogger(__name__)\n\nparser = argparse.ArgumentParser(description='HBase migration.')\nparser.add_argument('-y', '--yes', dest='yes', action='store_const', const=True)\nargs = parser.parse_args()\n\n\ndef create_new_table(table: Table) -> None:\n    \"\"\"Create new table once user agrees on that.\"\"\"\n    table_name = table.name\n    if args.yes or user_agrees('Do you want to create table \"{}\"?'.format(table_name)):\n        list_of_columns = HBaseClient.HBASE_SCHEMA[table_name]\n        logger.info('Creating table \"%s\" with columns %s.', table_name, list_of_columns)\n        table.create(*list_of_columns)\n        table.enable_if_exists_checks()\n\n\ndef update_table_schema(table: Table) -> None:\n    \"\"\"Update table schema once user agrees on that.\"\"\"\n    table_name = table.name\n    existing_column_families = set(table.columns())\n    schema_column_families = set(HBaseClient.HBASE_SCHEMA[table_name])\n    columns_to_add = list(schema_column_families - existing_column_families)\n    columns_to_drop = list(existing_column_families - schema_column_families)\n\n    if columns_to_add:\n        if args.yes or user_agrees('Do you want to add columns {} to \"{}\"?'.format(columns_to_add, table_name)):\n            table.add_columns(*columns_to_add)\n\n    if columns_to_drop:\n        if args.yes or user_agrees('Do you want to drop columns {} from \"{}\"?'.format(columns_to_drop, table_name)):\n            table.drop_columns(*columns_to_drop)\n\n\ndef drop_table(table: Table) -> None:\n    \"\"\"Drop table once user agrees on that.\"\"\"\n    table_name = table.name\n    if args.yes or user_agrees('Do you want to drop table \"{}\"?'.format(table_name)):\n        logger.info('Dropping table \"%s\".', table_name)\n        table.drop()\n\n\ndef main() -> None:\n    \"\"\"Run main functionality of this script.\"\"\"\n    connection = get_connection_to_hbase()\n    existing_tables = set(connection.tables())\n    schema_tables = set(HBaseClient.HBASE_SCHEMA)\n    tables_to_drop = list(existing_tables - schema_tables)\n\n    for table_name in tables_to_drop:\n        table = connection.table(table_name)\n        drop_table(table)\n\n    for table_name in HBaseClient.HBASE_SCHEMA:\n        table = connection.table(table_name)\n        if not table.exists():\n            create_new_table(table)\n        else:\n            update_table_schema(table)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "backend/scripts/migrate_hbase.py"}]}