prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  PyUnusedCodeBear: Implement remove_unused_variables
  The remove_unused_variables is implicitly passed on:
  https://github.com/coala/coala-bears/blob/master/bears/python/PyUnusedCodeBear.py#L33
  
  should be implemented as a setting in `run()`
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `bears/python/PyUnusedCodeBear.py`
  Content:
  ```
  1 import autoflake
  2 
  3 from coalib.bears.LocalBear import LocalBear
  4 from dependency_management.requirements.PipRequirement import PipRequirement
  5 from coalib.results.Diff import Diff
  6 from coalib.results.Result import Result
  7 
  8 
  9 class PyUnusedCodeBear(LocalBear):
  10     LANGUAGES = {'Python', 'Python 2', 'Python 3'}
  11     REQUIREMENTS = {PipRequirement('autoflake', '0.6.6')}
  12     AUTHORS = {'The coala developers'}
  13     AUTHORS_EMAILS = {'coala-devel@googlegroups.com'}
  14     LICENSE = 'AGPL-3.0'
  15     CAN_DETECT = {'Unused Code'}
  16 
  17     def run(self, filename, file,
  18             remove_all_unused_imports: bool=False):
  19         """
  20         Detects unused code. By default this functionality is limited to:
  21 
  22         - Unneeded pass statements.
  23         - Unneeded builtin imports.
  24 
  25         :param remove_all_unused_imports:
  26             True removes all unused imports - might have side effects
  27         """
  28 
  29         corrected = autoflake.fix_code(
  30                        ''.join(file),
  31                        additional_imports=None,
  32                        remove_all_unused_imports=remove_all_unused_imports,
  33                        remove_unused_variables=True
  34                        ).splitlines(True)
  35 
  36         for diff in Diff.from_string_arrays(file, corrected).split_diff():
  37             yield Result(self,
  38                          'This file contains unused source code.',
  39                          affected_code=(diff.range(filename),),
  40                          diffs={filename: diff})
  41
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/bears/python/PyUnusedCodeBear.py b/bears/python/PyUnusedCodeBear.py
  --- a/bears/python/PyUnusedCodeBear.py
  +++ b/bears/python/PyUnusedCodeBear.py
  @@ -15,7 +15,8 @@
       CAN_DETECT = {'Unused Code'}
   
       def run(self, filename, file,
  -            remove_all_unused_imports: bool=False):
  +            remove_all_unused_imports: bool=False,
  +            remove_unused_variables: bool=True):
           """
           Detects unused code. By default this functionality is limited to:
   
  @@ -24,13 +25,15 @@
   
           :param remove_all_unused_imports:
               True removes all unused imports - might have side effects
  +        :param remove_unused_variables:
  +            True removes unused variables - might have side effects
           """
   
           corrected = autoflake.fix_code(
                          ''.join(file),
                          additional_imports=None,
                          remove_all_unused_imports=remove_all_unused_imports,
  -                       remove_unused_variables=True
  +                       remove_unused_variables=remove_unused_variables
                          ).splitlines(True)
   
           for diff in Diff.from_string_arrays(file, corrected).split_diff():
  
verification_info: {"golden_diff": "diff --git a/bears/python/PyUnusedCodeBear.py b/bears/python/PyUnusedCodeBear.py\n--- a/bears/python/PyUnusedCodeBear.py\n+++ b/bears/python/PyUnusedCodeBear.py\n@@ -15,7 +15,8 @@\n     CAN_DETECT = {'Unused Code'}\n \n     def run(self, filename, file,\n-            remove_all_unused_imports: bool=False):\n+            remove_all_unused_imports: bool=False,\n+            remove_unused_variables: bool=True):\n         \"\"\"\n         Detects unused code. By default this functionality is limited to:\n \n@@ -24,13 +25,15 @@\n \n         :param remove_all_unused_imports:\n             True removes all unused imports - might have side effects\n+        :param remove_unused_variables:\n+            True removes unused variables - might have side effects\n         \"\"\"\n \n         corrected = autoflake.fix_code(\n                        ''.join(file),\n                        additional_imports=None,\n                        remove_all_unused_imports=remove_all_unused_imports,\n-                       remove_unused_variables=True\n+                       remove_unused_variables=remove_unused_variables\n                        ).splitlines(True)\n \n         for diff in Diff.from_string_arrays(file, corrected).split_diff():\n", "issue": "PyUnusedCodeBear: Implement remove_unused_variables\nThe remove_unused_variables is implicitly passed on:\r\nhttps://github.com/coala/coala-bears/blob/master/bears/python/PyUnusedCodeBear.py#L33\r\n\r\nshould be implemented as a setting in `run()`\n", "before_files": [{"content": "import autoflake\n\nfrom coalib.bears.LocalBear import LocalBear\nfrom dependency_management.requirements.PipRequirement import PipRequirement\nfrom coalib.results.Diff import Diff\nfrom coalib.results.Result import Result\n\n\nclass PyUnusedCodeBear(LocalBear):\n    LANGUAGES = {'Python', 'Python 2', 'Python 3'}\n    REQUIREMENTS = {PipRequirement('autoflake', '0.6.6')}\n    AUTHORS = {'The coala developers'}\n    AUTHORS_EMAILS = {'coala-devel@googlegroups.com'}\n    LICENSE = 'AGPL-3.0'\n    CAN_DETECT = {'Unused Code'}\n\n    def run(self, filename, file,\n            remove_all_unused_imports: bool=False):\n        \"\"\"\n        Detects unused code. By default this functionality is limited to:\n\n        - Unneeded pass statements.\n        - Unneeded builtin imports.\n\n        :param remove_all_unused_imports:\n            True removes all unused imports - might have side effects\n        \"\"\"\n\n        corrected = autoflake.fix_code(\n                       ''.join(file),\n                       additional_imports=None,\n                       remove_all_unused_imports=remove_all_unused_imports,\n                       remove_unused_variables=True\n                       ).splitlines(True)\n\n        for diff in Diff.from_string_arrays(file, corrected).split_diff():\n            yield Result(self,\n                         'This file contains unused source code.',\n                         affected_code=(diff.range(filename),),\n                         diffs={filename: diff})\n", "path": "bears/python/PyUnusedCodeBear.py"}], "after_files": [{"content": "import autoflake\n\nfrom coalib.bears.LocalBear import LocalBear\nfrom dependency_management.requirements.PipRequirement import PipRequirement\nfrom coalib.results.Diff import Diff\nfrom coalib.results.Result import Result\n\n\nclass PyUnusedCodeBear(LocalBear):\n    LANGUAGES = {'Python', 'Python 2', 'Python 3'}\n    REQUIREMENTS = {PipRequirement('autoflake', '0.6.6')}\n    AUTHORS = {'The coala developers'}\n    AUTHORS_EMAILS = {'coala-devel@googlegroups.com'}\n    LICENSE = 'AGPL-3.0'\n    CAN_DETECT = {'Unused Code'}\n\n    def run(self, filename, file,\n            remove_all_unused_imports: bool=False,\n            remove_unused_variables: bool=True):\n        \"\"\"\n        Detects unused code. By default this functionality is limited to:\n\n        - Unneeded pass statements.\n        - Unneeded builtin imports.\n\n        :param remove_all_unused_imports:\n            True removes all unused imports - might have side effects\n        :param remove_unused_variables:\n            True removes unused variables - might have side effects\n        \"\"\"\n\n        corrected = autoflake.fix_code(\n                       ''.join(file),\n                       additional_imports=None,\n                       remove_all_unused_imports=remove_all_unused_imports,\n                       remove_unused_variables=remove_unused_variables\n                       ).splitlines(True)\n\n        for diff in Diff.from_string_arrays(file, corrected).split_diff():\n            yield Result(self,\n                         'This file contains unused source code.',\n                         affected_code=(diff.range(filename),),\n                         diffs={filename: diff})\n", "path": "bears/python/PyUnusedCodeBear.py"}]}