We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add more annotation keywords to the Editor (e.g. BUG, OPTIMIZE, etc)
Code annotation analysis makes a blue check sign in the editor, which is a useful feature to find TODOs or FIXMEs.

But could it add more words? On the net, and more importantly in [pep8 index](https://www.python.org/dev/peps/pep-0350/#mnemonics), we can find many other tags, eg BUG, HACK, OPTIMIZE, etc.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `spyder/utils/codeanalysis.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright © Spyder Project Contributors
4 # Licensed under the terms of the MIT License
5 # (see spyder/__init__.py for details)
6 
7 """
8 Source code analysis utilities
9 """
10 
11 import sys
12 import re
13 import os
14 import tempfile
15 import traceback
16 
17 # Local import
18 from spyder.config.base import _, DEBUG
19 from spyder.utils import programs, encoding
20 from spyder.py3compat import to_text_string, to_binary_string, PY3
21 from spyder import dependencies
22 DEBUG_EDITOR = DEBUG >= 3
23 
24 #==============================================================================
25 # Pyflakes/pep8 code analysis
26 #==============================================================================
27 TASKS_PATTERN = r"(^|#)[ ]*(TODO|FIXME|XXX|HINT|TIP|@todo)([^#]*)"
28 
29 #TODO: this is a test for the following function
30 def find_tasks(source_code):
31     """Find tasks in source code (TODO, FIXME, XXX, ...)"""
32     results = []
33     for line, text in enumerate(source_code.splitlines()):
34         for todo in re.findall(TASKS_PATTERN, text):
35             results.append((todo[-1].strip().capitalize(), line+1))
36     return results
37 
38 
39 def check_with_pyflakes(source_code, filename=None):
40     """Check source code with pyflakes
41     Returns an empty list if pyflakes is not installed"""
42     try:
43         if filename is None:
44             filename = '<string>'
45         try:
46             source_code += '\n'
47         except TypeError:
48             # Python 3
49             source_code += to_binary_string('\n')
50             
51         import _ast
52         from pyflakes.checker import Checker
53         # First, compile into an AST and handle syntax errors.
54         try:
55             tree = compile(source_code, filename, "exec", _ast.PyCF_ONLY_AST)
56         except SyntaxError as value:
57             # If there's an encoding problem with the file, the text is None.
58             if value.text is None:
59                 results = []
60             else:
61                 results = [(value.args[0], value.lineno)]
62         except (ValueError, TypeError):
63             # Example of ValueError: file contains invalid \x escape character
64             # (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674797)
65             # Example of TypeError: file contains null character
66             # (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674796)
67             results = []
68         else:
69             # Okay, it's syntactically valid.  Now check it.
70             w = Checker(tree, filename)
71             w.messages.sort(key=lambda x: x.lineno)
72             results = []
73             coding = encoding.get_coding(source_code)
74             lines = source_code.splitlines()
75             for warning in w.messages:
76                 if 'analysis:ignore' not in \
77                    to_text_string(lines[warning.lineno-1], coding):
78                     results.append((warning.message % warning.message_args,
79                                     warning.lineno))
80     except Exception:
81         # Never return None to avoid lock in spyder/widgets/editor.py
82         # See Issue 1547
83         results = []
84         if DEBUG_EDITOR:
85             traceback.print_exc()  # Print exception in internal console
86     return results
87 
88 # Required version:
89 # Why 0.5 (Python2)? Because it's based on _ast (thread-safe)
90 PYFLAKES_REQVER = '>=0.6.0' if PY3 else '>=0.5.0'
91 dependencies.add("pyflakes", _("Real-time code analysis on the Editor"),
92                  required_version=PYFLAKES_REQVER)
93 
94 PYCODESTYLE_REQVER = '>=2.3'
95 dependencies.add("pycodestyle", _("Real-time code style analysis on the Editor"),
96                  required_version=PYCODESTYLE_REQVER)
97 
98 
99 def is_pyflakes_installed():
100     """Return True if pyflakes required version is installed"""
101     return programs.is_module_installed('pyflakes', PYFLAKES_REQVER)
102 
103 
104 def get_checker_executable(name):
105     """Return checker executable in the form of a list of arguments
106     for subprocess.Popen"""
107     if programs.is_program_installed(name):
108         # Checker is properly installed
109         return [name]
110     else:
111         path1 = programs.python_script_exists(package=None,
112                                               module=name+'_script')
113         path2 = programs.python_script_exists(package=None, module=name)
114         if path1 is not None:  # checker_script.py is available
115             # Checker script is available but has not been installed
116             # (this may work with pyflakes)
117             return [sys.executable, path1]
118         elif path2 is not None:  # checker.py is available
119             # Checker package is available but its script has not been
120             # installed (this works with pycodestyle but not with pyflakes)
121             return [sys.executable, path2]
122 
123 
124 def check(args, source_code, filename=None, options=None):
125     """Check source code with checker defined with *args* (list)
126     Returns an empty list if checker is not installed"""
127     if args is None:
128         return []
129     if options is not None:
130         args += options
131     if any(['pyflakes' in arg for arg in args]):
132         #  Pyflakes requires an ending new line (pycodestyle don't! -- see Issue 1123)
133         #  Note: this code is not used right now as it is faster to invoke 
134         #  pyflakes in current Python interpreter (see `check_with_pyflakes` 
135         #  function above) than calling it through a subprocess
136         source_code += '\n'
137     if filename is None:
138         # Creating a temporary file because file does not exist yet 
139         # or is not up-to-date
140         tempfd = tempfile.NamedTemporaryFile(suffix=".py", delete=False)
141         tempfd.write(source_code)
142         tempfd.close()
143         args.append(tempfd.name)
144     else:
145         args.append(filename)
146     cmd = args[0]
147     cmdargs = args[1:]
148     proc = programs.run_program(cmd, cmdargs)
149     output = proc.communicate()[0].strip().decode().splitlines()
150     if filename is None:
151         os.unlink(tempfd.name)
152     results = []
153     coding = encoding.get_coding(source_code)
154     lines = source_code.splitlines()
155     for line in output:
156         lineno = int(re.search(r'(\:[\d]+\:)', line).group()[1:-1])
157         try:
158             text = to_text_string(lines[lineno-1], coding)
159         except TypeError:
160             text = to_text_string(lines[lineno-1])
161         if 'analysis:ignore' not in text:
162             message = line[line.find(': ')+2:]
163             results.append((message, lineno))
164     return results
165 
166 
167 def check_with_pep8(source_code, filename=None):
168     """Check source code with pycodestyle"""
169     try:
170         args = get_checker_executable('pycodestyle')
171         results = check(args, source_code, filename=filename, options=['-r'])
172     except Exception:
173         # Never return None to avoid lock in spyder/widgets/editor.py
174         # See Issue 1547
175         results = []
176         if DEBUG_EDITOR:
177             traceback.print_exc()  # Print exception in internal console
178     return results
179 
180 
181 if __name__ == '__main__':
182 #    fname = __file__
183     fname = os.path.join(os.path.dirname(__file__),
184                          os.pardir, os.pardir, 'bootstrap.py')
185     code = open(fname).read()
186     check_results = check_with_pyflakes(code, fname)+\
187                     check_with_pep8(code, fname)+find_tasks(code)
188 #    check_results = check_with_pep8(code, fname)
189     for message, line in check_results:
190         sys.stdout.write("Message: %s -- Line: %s\n" % (message, line))
191
```
--- 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/spyder/utils/codeanalysis.py b/spyder/utils/codeanalysis.py
--- a/spyder/utils/codeanalysis.py
+++ b/spyder/utils/codeanalysis.py
@@ -24,7 +24,8 @@
 #==============================================================================
 # Pyflakes/pep8 code analysis
 #==============================================================================
-TASKS_PATTERN = r"(^|#)[ ]*(TODO|FIXME|XXX|HINT|TIP|@todo)([^#]*)"
+TASKS_PATTERN = r"(^|#)[ ]*(TODO|FIXME|XXX|HINT|TIP|@todo|" \
+                r"HACK|BUG|OPTIMIZE|!!!|\?\?\?)([^#]*)"
 
 #TODO: this is a test for the following function
 def find_tasks(source_code):

{"golden_diff": "diff --git a/spyder/utils/codeanalysis.py b/spyder/utils/codeanalysis.py\n--- a/spyder/utils/codeanalysis.py\n+++ b/spyder/utils/codeanalysis.py\n@@ -24,7 +24,8 @@\n #==============================================================================\r\n # Pyflakes/pep8 code analysis\r\n #==============================================================================\r\n-TASKS_PATTERN = r\"(^|#)[ ]*(TODO|FIXME|XXX|HINT|TIP|@todo)([^#]*)\"\r\n+TASKS_PATTERN = r\"(^|#)[ ]*(TODO|FIXME|XXX|HINT|TIP|@todo|\" \\\r\n+                r\"HACK|BUG|OPTIMIZE|!!!|\\?\\?\\?)([^#]*)\"\r\n \r\n #TODO: this is a test for the following function\r\n def find_tasks(source_code):\n", "issue": "Add more annotation keywords to the Editor (e.g. BUG, OPTIMIZE, etc)\nCode annotation analysis makes a blue check sign in the editor, which is a useful feature to find TODOs or FIXMEs.\r\n\r\nBut could it add more words? On the net, and more importantly in [pep8 index](https://www.python.org/dev/peps/pep-0350/#mnemonics), we can find many other tags, eg BUG, HACK, OPTIMIZE, etc.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\r\n#\r\n# Copyright \u00a9 Spyder Project Contributors\r\n# Licensed under the terms of the MIT License\r\n# (see spyder/__init__.py for details)\r\n\r\n\"\"\"\r\nSource code analysis utilities\r\n\"\"\"\r\n\r\nimport sys\r\nimport re\r\nimport os\r\nimport tempfile\r\nimport traceback\r\n\r\n# Local import\r\nfrom spyder.config.base import _, DEBUG\r\nfrom spyder.utils import programs, encoding\r\nfrom spyder.py3compat import to_text_string, to_binary_string, PY3\r\nfrom spyder import dependencies\r\nDEBUG_EDITOR = DEBUG >= 3\r\n\r\n#==============================================================================\r\n# Pyflakes/pep8 code analysis\r\n#==============================================================================\r\nTASKS_PATTERN = r\"(^|#)[ ]*(TODO|FIXME|XXX|HINT|TIP|@todo)([^#]*)\"\r\n\r\n#TODO: this is a test for the following function\r\ndef find_tasks(source_code):\r\n    \"\"\"Find tasks in source code (TODO, FIXME, XXX, ...)\"\"\"\r\n    results = []\r\n    for line, text in enumerate(source_code.splitlines()):\r\n        for todo in re.findall(TASKS_PATTERN, text):\r\n            results.append((todo[-1].strip().capitalize(), line+1))\r\n    return results\r\n\r\n\r\ndef check_with_pyflakes(source_code, filename=None):\r\n    \"\"\"Check source code with pyflakes\r\n    Returns an empty list if pyflakes is not installed\"\"\"\r\n    try:\r\n        if filename is None:\r\n            filename = '<string>'\r\n        try:\r\n            source_code += '\\n'\r\n        except TypeError:\r\n            # Python 3\r\n            source_code += to_binary_string('\\n')\r\n            \r\n        import _ast\r\n        from pyflakes.checker import Checker\r\n        # First, compile into an AST and handle syntax errors.\r\n        try:\r\n            tree = compile(source_code, filename, \"exec\", _ast.PyCF_ONLY_AST)\r\n        except SyntaxError as value:\r\n            # If there's an encoding problem with the file, the text is None.\r\n            if value.text is None:\r\n                results = []\r\n            else:\r\n                results = [(value.args[0], value.lineno)]\r\n        except (ValueError, TypeError):\r\n            # Example of ValueError: file contains invalid \\x escape character\r\n            # (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674797)\r\n            # Example of TypeError: file contains null character\r\n            # (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674796)\r\n            results = []\r\n        else:\r\n            # Okay, it's syntactically valid.  Now check it.\r\n            w = Checker(tree, filename)\r\n            w.messages.sort(key=lambda x: x.lineno)\r\n            results = []\r\n            coding = encoding.get_coding(source_code)\r\n            lines = source_code.splitlines()\r\n            for warning in w.messages:\r\n                if 'analysis:ignore' not in \\\r\n                   to_text_string(lines[warning.lineno-1], coding):\r\n                    results.append((warning.message % warning.message_args,\r\n                                    warning.lineno))\r\n    except Exception:\r\n        # Never return None to avoid lock in spyder/widgets/editor.py\r\n        # See Issue 1547\r\n        results = []\r\n        if DEBUG_EDITOR:\r\n            traceback.print_exc()  # Print exception in internal console\r\n    return results\r\n\r\n# Required version:\r\n# Why 0.5 (Python2)? Because it's based on _ast (thread-safe)\r\nPYFLAKES_REQVER = '>=0.6.0' if PY3 else '>=0.5.0'\r\ndependencies.add(\"pyflakes\", _(\"Real-time code analysis on the Editor\"),\r\n                 required_version=PYFLAKES_REQVER)\r\n\r\nPYCODESTYLE_REQVER = '>=2.3'\r\ndependencies.add(\"pycodestyle\", _(\"Real-time code style analysis on the Editor\"),\r\n                 required_version=PYCODESTYLE_REQVER)\r\n\r\n\r\ndef is_pyflakes_installed():\r\n    \"\"\"Return True if pyflakes required version is installed\"\"\"\r\n    return programs.is_module_installed('pyflakes', PYFLAKES_REQVER)\r\n\r\n\r\ndef get_checker_executable(name):\r\n    \"\"\"Return checker executable in the form of a list of arguments\r\n    for subprocess.Popen\"\"\"\r\n    if programs.is_program_installed(name):\r\n        # Checker is properly installed\r\n        return [name]\r\n    else:\r\n        path1 = programs.python_script_exists(package=None,\r\n                                              module=name+'_script')\r\n        path2 = programs.python_script_exists(package=None, module=name)\r\n        if path1 is not None:  # checker_script.py is available\r\n            # Checker script is available but has not been installed\r\n            # (this may work with pyflakes)\r\n            return [sys.executable, path1]\r\n        elif path2 is not None:  # checker.py is available\r\n            # Checker package is available but its script has not been\r\n            # installed (this works with pycodestyle but not with pyflakes)\r\n            return [sys.executable, path2]\r\n\r\n\r\ndef check(args, source_code, filename=None, options=None):\r\n    \"\"\"Check source code with checker defined with *args* (list)\r\n    Returns an empty list if checker is not installed\"\"\"\r\n    if args is None:\r\n        return []\r\n    if options is not None:\r\n        args += options\r\n    if any(['pyflakes' in arg for arg in args]):\r\n        #  Pyflakes requires an ending new line (pycodestyle don't! -- see Issue 1123)\r\n        #  Note: this code is not used right now as it is faster to invoke \r\n        #  pyflakes in current Python interpreter (see `check_with_pyflakes` \r\n        #  function above) than calling it through a subprocess\r\n        source_code += '\\n'\r\n    if filename is None:\r\n        # Creating a temporary file because file does not exist yet \r\n        # or is not up-to-date\r\n        tempfd = tempfile.NamedTemporaryFile(suffix=\".py\", delete=False)\r\n        tempfd.write(source_code)\r\n        tempfd.close()\r\n        args.append(tempfd.name)\r\n    else:\r\n        args.append(filename)\r\n    cmd = args[0]\r\n    cmdargs = args[1:]\r\n    proc = programs.run_program(cmd, cmdargs)\r\n    output = proc.communicate()[0].strip().decode().splitlines()\r\n    if filename is None:\r\n        os.unlink(tempfd.name)\r\n    results = []\r\n    coding = encoding.get_coding(source_code)\r\n    lines = source_code.splitlines()\r\n    for line in output:\r\n        lineno = int(re.search(r'(\\:[\\d]+\\:)', line).group()[1:-1])\r\n        try:\r\n            text = to_text_string(lines[lineno-1], coding)\r\n        except TypeError:\r\n            text = to_text_string(lines[lineno-1])\r\n        if 'analysis:ignore' not in text:\r\n            message = line[line.find(': ')+2:]\r\n            results.append((message, lineno))\r\n    return results\r\n\r\n\r\ndef check_with_pep8(source_code, filename=None):\r\n    \"\"\"Check source code with pycodestyle\"\"\"\r\n    try:\r\n        args = get_checker_executable('pycodestyle')\r\n        results = check(args, source_code, filename=filename, options=['-r'])\r\n    except Exception:\r\n        # Never return None to avoid lock in spyder/widgets/editor.py\r\n        # See Issue 1547\r\n        results = []\r\n        if DEBUG_EDITOR:\r\n            traceback.print_exc()  # Print exception in internal console\r\n    return results\r\n\r\n\r\nif __name__ == '__main__':\r\n#    fname = __file__\r\n    fname = os.path.join(os.path.dirname(__file__),\r\n                         os.pardir, os.pardir, 'bootstrap.py')\r\n    code = open(fname).read()\r\n    check_results = check_with_pyflakes(code, fname)+\\\r\n                    check_with_pep8(code, fname)+find_tasks(code)\r\n#    check_results = check_with_pep8(code, fname)\r\n    for message, line in check_results:\r\n        sys.stdout.write(\"Message: %s -- Line: %s\\n\" % (message, line))\r\n", "path": "spyder/utils/codeanalysis.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\r\n#\r\n# Copyright \u00a9 Spyder Project Contributors\r\n# Licensed under the terms of the MIT License\r\n# (see spyder/__init__.py for details)\r\n\r\n\"\"\"\r\nSource code analysis utilities\r\n\"\"\"\r\n\r\nimport sys\r\nimport re\r\nimport os\r\nimport tempfile\r\nimport traceback\r\n\r\n# Local import\r\nfrom spyder.config.base import _, DEBUG\r\nfrom spyder.utils import programs, encoding\r\nfrom spyder.py3compat import to_text_string, to_binary_string, PY3\r\nfrom spyder import dependencies\r\nDEBUG_EDITOR = DEBUG >= 3\r\n\r\n#==============================================================================\r\n# Pyflakes/pep8 code analysis\r\n#==============================================================================\r\nTASKS_PATTERN = r\"(^|#)[ ]*(TODO|FIXME|XXX|HINT|TIP|@todo|\" \\\r\n                r\"HACK|BUG|OPTIMIZE|!!!|\\?\\?\\?)([^#]*)\"\r\n\r\n#TODO: this is a test for the following function\r\ndef find_tasks(source_code):\r\n    \"\"\"Find tasks in source code (TODO, FIXME, XXX, ...)\"\"\"\r\n    results = []\r\n    for line, text in enumerate(source_code.splitlines()):\r\n        for todo in re.findall(TASKS_PATTERN, text):\r\n            results.append((todo[-1].strip().capitalize(), line+1))\r\n    return results\r\n\r\n\r\ndef check_with_pyflakes(source_code, filename=None):\r\n    \"\"\"Check source code with pyflakes\r\n    Returns an empty list if pyflakes is not installed\"\"\"\r\n    try:\r\n        if filename is None:\r\n            filename = '<string>'\r\n        try:\r\n            source_code += '\\n'\r\n        except TypeError:\r\n            # Python 3\r\n            source_code += to_binary_string('\\n')\r\n            \r\n        import _ast\r\n        from pyflakes.checker import Checker\r\n        # First, compile into an AST and handle syntax errors.\r\n        try:\r\n            tree = compile(source_code, filename, \"exec\", _ast.PyCF_ONLY_AST)\r\n        except SyntaxError as value:\r\n            # If there's an encoding problem with the file, the text is None.\r\n            if value.text is None:\r\n                results = []\r\n            else:\r\n                results = [(value.args[0], value.lineno)]\r\n        except (ValueError, TypeError):\r\n            # Example of ValueError: file contains invalid \\x escape character\r\n            # (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674797)\r\n            # Example of TypeError: file contains null character\r\n            # (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674796)\r\n            results = []\r\n        else:\r\n            # Okay, it's syntactically valid.  Now check it.\r\n            w = Checker(tree, filename)\r\n            w.messages.sort(key=lambda x: x.lineno)\r\n            results = []\r\n            coding = encoding.get_coding(source_code)\r\n            lines = source_code.splitlines()\r\n            for warning in w.messages:\r\n                if 'analysis:ignore' not in \\\r\n                   to_text_string(lines[warning.lineno-1], coding):\r\n                    results.append((warning.message % warning.message_args,\r\n                                    warning.lineno))\r\n    except Exception:\r\n        # Never return None to avoid lock in spyder/widgets/editor.py\r\n        # See Issue 1547\r\n        results = []\r\n        if DEBUG_EDITOR:\r\n            traceback.print_exc()  # Print exception in internal console\r\n    return results\r\n\r\n# Required version:\r\n# Why 0.5 (Python2)? Because it's based on _ast (thread-safe)\r\nPYFLAKES_REQVER = '>=0.6.0' if PY3 else '>=0.5.0'\r\ndependencies.add(\"pyflakes\", _(\"Real-time code analysis on the Editor\"),\r\n                 required_version=PYFLAKES_REQVER)\r\n\r\nPYCODESTYLE_REQVER = '>=2.3'\r\ndependencies.add(\"pycodestyle\", _(\"Real-time code style analysis on the Editor\"),\r\n                 required_version=PYCODESTYLE_REQVER)\r\n\r\n\r\ndef is_pyflakes_installed():\r\n    \"\"\"Return True if pyflakes required version is installed\"\"\"\r\n    return programs.is_module_installed('pyflakes', PYFLAKES_REQVER)\r\n\r\n\r\ndef get_checker_executable(name):\r\n    \"\"\"Return checker executable in the form of a list of arguments\r\n    for subprocess.Popen\"\"\"\r\n    if programs.is_program_installed(name):\r\n        # Checker is properly installed\r\n        return [name]\r\n    else:\r\n        path1 = programs.python_script_exists(package=None,\r\n                                              module=name+'_script')\r\n        path2 = programs.python_script_exists(package=None, module=name)\r\n        if path1 is not None:  # checker_script.py is available\r\n            # Checker script is available but has not been installed\r\n            # (this may work with pyflakes)\r\n            return [sys.executable, path1]\r\n        elif path2 is not None:  # checker.py is available\r\n            # Checker package is available but its script has not been\r\n            # installed (this works with pycodestyle but not with pyflakes)\r\n            return [sys.executable, path2]\r\n\r\n\r\ndef check(args, source_code, filename=None, options=None):\r\n    \"\"\"Check source code with checker defined with *args* (list)\r\n    Returns an empty list if checker is not installed\"\"\"\r\n    if args is None:\r\n        return []\r\n    if options is not None:\r\n        args += options\r\n    if any(['pyflakes' in arg for arg in args]):\r\n        #  Pyflakes requires an ending new line (pycodestyle don't! -- see Issue 1123)\r\n        #  Note: this code is not used right now as it is faster to invoke \r\n        #  pyflakes in current Python interpreter (see `check_with_pyflakes` \r\n        #  function above) than calling it through a subprocess\r\n        source_code += '\\n'\r\n    if filename is None:\r\n        # Creating a temporary file because file does not exist yet \r\n        # or is not up-to-date\r\n        tempfd = tempfile.NamedTemporaryFile(suffix=\".py\", delete=False)\r\n        tempfd.write(source_code)\r\n        tempfd.close()\r\n        args.append(tempfd.name)\r\n    else:\r\n        args.append(filename)\r\n    cmd = args[0]\r\n    cmdargs = args[1:]\r\n    proc = programs.run_program(cmd, cmdargs)\r\n    output = proc.communicate()[0].strip().decode().splitlines()\r\n    if filename is None:\r\n        os.unlink(tempfd.name)\r\n    results = []\r\n    coding = encoding.get_coding(source_code)\r\n    lines = source_code.splitlines()\r\n    for line in output:\r\n        lineno = int(re.search(r'(\\:[\\d]+\\:)', line).group()[1:-1])\r\n        try:\r\n            text = to_text_string(lines[lineno-1], coding)\r\n        except TypeError:\r\n            text = to_text_string(lines[lineno-1])\r\n        if 'analysis:ignore' not in text:\r\n            message = line[line.find(': ')+2:]\r\n            results.append((message, lineno))\r\n    return results\r\n\r\n\r\ndef check_with_pep8(source_code, filename=None):\r\n    \"\"\"Check source code with pycodestyle\"\"\"\r\n    try:\r\n        args = get_checker_executable('pycodestyle')\r\n        results = check(args, source_code, filename=filename, options=['-r'])\r\n    except Exception:\r\n        # Never return None to avoid lock in spyder/widgets/editor.py\r\n        # See Issue 1547\r\n        results = []\r\n        if DEBUG_EDITOR:\r\n            traceback.print_exc()  # Print exception in internal console\r\n    return results\r\n\r\n\r\nif __name__ == '__main__':\r\n#    fname = __file__\r\n    fname = os.path.join(os.path.dirname(__file__),\r\n                         os.pardir, os.pardir, 'bootstrap.py')\r\n    code = open(fname).read()\r\n    check_results = check_with_pyflakes(code, fname)+\\\r\n                    check_with_pep8(code, fname)+find_tasks(code)\r\n#    check_results = check_with_pep8(code, fname)\r\n    for message, line in check_results:\r\n        sys.stdout.write(\"Message: %s -- Line: %s\\n\" % (message, line))\r\n", "path": "spyder/utils/codeanalysis.py"}]}