Mon, 20 Mar 2023 10:43:29 +0100
Syntax Checker
- Added the capability to define names to be treated as builtin names by the `pyflakes` checker (see configuration dialog `Editor` => `Code Checkers` page.
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
2 | |
9653
e67609152c5e
Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9591
diff
changeset
|
3 | # Copyright (c) 2011 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
4 | # |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
5 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
6 | """ |
7639
422fd05e9c91
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7637
diff
changeset
|
7 | Module implementing the syntax check for Python 3. |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
8 | """ |
4543
2e6a880670e9
Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4385
diff
changeset
|
9 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9462
diff
changeset
|
10 | import ast |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
11 | import builtins |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9462
diff
changeset
|
12 | import contextlib |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9462
diff
changeset
|
13 | import multiprocessing |
7637
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
14 | import queue |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
15 | import re |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
16 | import traceback |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
17 | |
8243
cc717c2ae956
Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8234
diff
changeset
|
18 | with contextlib.suppress(ImportError): |
3173
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
19 | from pyflakes.checker import Checker |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9462
diff
changeset
|
20 | from pyflakes.messages import ImportStarUsage, ImportStarUsed |
3173
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
21 | |
6107
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
22 | VcsConflictMarkerRegExpList = ( |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
23 | re.compile( |
6109
041715a2f703
Another fix for the VCS conflict markers regexp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6108
diff
changeset
|
24 | r"""^<<<<<<< .*?\|\|\|\|\|\|\| .*?=======.*?>>>>>>> .*?$""", |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
25 | re.MULTILINE | re.DOTALL, |
6107
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
26 | ), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
27 | re.compile(r"""^<<<<<<< .*?=======.*?>>>>>>> .*?$""", re.MULTILINE | re.DOTALL), |
6107
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
28 | ) |
3173
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
29 | |
6119
18fb5d765f3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6109
diff
changeset
|
30 | |
3173
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
31 | def initService(): |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
32 | """ |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
33 | Initialize the service and return the entry point. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
34 | |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
35 | @return the entry point for the background client |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
36 | @rtype function |
3173
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
37 | """ |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
38 | return pySyntaxAndPyflakesCheck |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
39 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
40 | |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
41 | def initBatchService(): |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
42 | """ |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
43 | Initialize the batch service and return the entry point. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
45 | @return the entry point for the background client |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
46 | @rtype function |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
47 | """ |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
48 | return pySyntaxAndPyflakesBatchCheck |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
49 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
50 | |
5586
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
51 | def extractLineFlags(line, startComment="#", endComment="", flagsLine=False): |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
52 | """ |
3065
070b35dde35e
Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2571
diff
changeset
|
53 | Function to extract flags starting and ending with '__' from a line |
070b35dde35e
Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2571
diff
changeset
|
54 | comment. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
55 | |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
56 | @param line line to extract flags from |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
57 | @type str |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
58 | @param startComment string identifying the start of the comment |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
59 | @type str |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
60 | @param endComment string identifying the end of a comment |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
61 | @type str |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
62 | @param flagsLine flag indicating to check for a flags only line |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
63 | @type bool |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
64 | @return list containing the extracted flags |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
65 | @rtype list of str |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
66 | """ |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
67 | flags = [] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
69 | if not flagsLine or (flagsLine and line.strip().startswith(startComment)): |
5586
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
70 | pos = line.rfind(startComment) |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
71 | if pos >= 0: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | comment = line[pos + len(startComment) :].strip() |
5586
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
73 | if endComment: |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
74 | endPos = line.rfind(endComment) |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
75 | if endPos >= 0: |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
76 | comment = comment[:endPos] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
77 | flags = [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
78 | f.strip() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
79 | for f in comment.split() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
80 | if (f.startswith("__") and f.endswith("__")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | ] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
82 | flags += [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
83 | f.strip().lower() for f in comment.split() if f in ("noqa", "NOQA") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
84 | ] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
85 | return flags |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
86 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
87 | |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
88 | def pySyntaxAndPyflakesCheck( |
9924
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
89 | filename, |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
90 | codestring, |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
91 | checkFlakes=True, |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
92 | ignoreStarImportWarnings=False, |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
93 | additionalBuiltins=None, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
94 | ): |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
95 | """ |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
96 | Function to compile one Python source file to Python bytecode |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
97 | and to perform a pyflakes check. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
98 | |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
99 | @param filename source filename |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
100 | @type str |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
101 | @param codestring string containing the code to compile |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
102 | @type str |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
103 | @param checkFlakes flag indicating to do a pyflakes check |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
104 | @type bool |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
105 | @param ignoreStarImportWarnings flag indicating to ignore 'star import' warnings |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
106 | @type bool |
9924
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
107 | @param additionalBuiltins list of names pyflakes should consider as builtins |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
108 | @type list of str |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
109 | @return dictionary with the keys 'error' and 'warnings' which |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
110 | hold a list containing details about the error/warnings |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
111 | (file name, line number, column, codestring (only at syntax |
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
112 | errors), the message, a list with arguments for the message) |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
113 | @rtype dict |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
114 | """ |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
115 | return __pySyntaxAndPyflakesCheck( |
9924
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
116 | filename, codestring, checkFlakes, ignoreStarImportWarnings, additionalBuiltins |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
117 | ) |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
118 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
119 | |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
120 | def pySyntaxAndPyflakesBatchCheck(argumentsList, send, fx, cancelled, maxProcesses=0): |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
121 | """ |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
122 | Module function to check syntax for a batch of files. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
123 | |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
124 | @param argumentsList list of arguments tuples as given for pySyntaxAndPyflakesCheck |
5762
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
125 | @type list |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
126 | @param send reference to send function |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
127 | @type func |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
128 | @param fx registered service name |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
129 | @type str |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
130 | @param cancelled reference to function checking for a cancellation |
5762
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
131 | @type func |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
132 | @param maxProcesses number of processes to be used |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
133 | @type int |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
134 | """ |
5762
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
135 | if maxProcesses == 0: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
136 | # determine based on CPU count |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
137 | try: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
138 | NumberOfProcesses = multiprocessing.cpu_count() |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
139 | if NumberOfProcesses >= 1: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
140 | NumberOfProcesses -= 1 |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
141 | except NotImplementedError: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
142 | NumberOfProcesses = 1 |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
143 | else: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
144 | NumberOfProcesses = maxProcesses |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
145 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
146 | # Create queues |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
147 | taskQueue = multiprocessing.Queue() |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
148 | doneQueue = multiprocessing.Queue() |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
149 | |
9289
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
150 | # Submit tasks (initially two times the number of processes) |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
151 | tasks = len(argumentsList) |
9292
a5c8a0213fe3
Fixed an issue in the multiprocessing usage causing a traceback when then number of tasks is smaller than the number of worker processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9289
diff
changeset
|
152 | initialTasks = min(2 * NumberOfProcesses, tasks) |
9289
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
153 | for _ in range(initialTasks): |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
154 | taskQueue.put(argumentsList.pop(0)) |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
155 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
156 | # Start worker processes |
8650
100726f55a9a
Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
157 | workers = [ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
158 | multiprocessing.Process(target=workerTask, args=(taskQueue, doneQueue)) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
159 | for _ in range(NumberOfProcesses) |
8650
100726f55a9a
Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
160 | ] |
100726f55a9a
Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
161 | for worker in workers: |
100726f55a9a
Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
162 | worker.start() |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
163 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
164 | # Get and send results |
9289
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
165 | for _ in range(tasks): |
5672
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
166 | resultSent = False |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
167 | wasCancelled = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
168 | |
5672
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
169 | while not resultSent: |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
170 | try: |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
171 | # get result (waiting max. 3 seconds and send it to frontend |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
172 | filename, result = doneQueue.get() |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
173 | send(fx, filename, result) |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
174 | resultSent = True |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
175 | except queue.Empty: |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
176 | # ignore empty queue, just carry on |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
177 | if cancelled(): |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
178 | wasCancelled = True |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
179 | break |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
180 | |
5672
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
181 | if wasCancelled or cancelled(): |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
182 | # just exit the loop ignoring the results of queued tasks |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
183 | break |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
184 | |
9289
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
185 | if argumentsList: |
ba49c41e8f63
Did some optimizations in the multiprocessing code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9284
diff
changeset
|
186 | taskQueue.put(argumentsList.pop(0)) |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
187 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
188 | # Tell child processes to stop |
6188
5a6ae3be31e6
Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6119
diff
changeset
|
189 | for _ in range(NumberOfProcesses): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
190 | taskQueue.put("STOP") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
191 | |
8650
100726f55a9a
Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
192 | for worker in workers: |
100726f55a9a
Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
193 | worker.join() |
100726f55a9a
Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
194 | worker.close() |
9284
3b3a4f659782
"Blacked" the sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9279
diff
changeset
|
195 | |
9279
e252f827aaa7
Added code to explicitly close the queues to/from the workers at the end of a batch check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
196 | taskQueue.close() |
e252f827aaa7
Added code to explicitly close the queues to/from the workers at the end of a batch check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
197 | doneQueue.close() |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
198 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
199 | |
8650
100726f55a9a
Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
200 | def workerTask(inputQueue, outputQueue): |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
201 | """ |
7335
07ed3d73bf58
Syntax Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7256
diff
changeset
|
202 | Module function acting as the parallel worker for the syntax check. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
203 | |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
204 | @param inputQueue input queue |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
205 | @type multiprocessing.Queue |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
206 | @param outputQueue output queue |
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
207 | @type multiprocessing.Queue |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
208 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
209 | for filename, args in iter(inputQueue.get, "STOP"): |
9924
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
210 | source, checkFlakes, ignoreStarImportWarnings, additionalBuiltins = args |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
211 | result = __pySyntaxAndPyflakesCheck( |
9924
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
212 | filename, source, checkFlakes, ignoreStarImportWarnings, additionalBuiltins |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
213 | ) |
5588
6ba512d9f46a
Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5586
diff
changeset
|
214 | outputQueue.put((filename, result)) |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
215 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
216 | |
9508
5a02bdb1dcba
Harmonized the naming of some code in the syntax checker plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9507
diff
changeset
|
217 | def __pySyntaxAndPyflakesCheck( |
9924
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
218 | filename, |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
219 | codestring, |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
220 | checkFlakes=True, |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
221 | ignoreStarImportWarnings=False, |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
222 | additionalBuiltins=None, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
223 | ): |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
224 | """ |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
225 | Function to compile one Python source file to Python bytecode |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
226 | and to perform a pyflakes check. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
227 | |
8205
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
228 | @param filename source filename |
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
229 | @type str |
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
230 | @param codestring string containing the code to compile |
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
231 | @type str |
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
232 | @param checkFlakes flag indicating to do a pyflakes check |
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
233 | @type bool |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
234 | @param ignoreStarImportWarnings flag indicating to |
8205
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
235 | ignore 'star import' warnings |
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
236 | @type bool |
9924
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
237 | @param additionalBuiltins list of names pyflakes should consider as builtins |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
238 | @type list of str |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
239 | @return dictionary with the keys 'error' and 'warnings' which |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
240 | hold a list containing details about the error/ warnings |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
241 | (file name, line number, column, codestring (only at syntax |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
242 | errors), the message, a list with arguments for the message) |
8205
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
243 | @rtype dict |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
244 | """ |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
245 | try: |
3635
fc024806236d
Extended the syntax checker to check for VCS conflict markers left over from failed merges.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3630
diff
changeset
|
246 | # Check for VCS conflict markers |
6107
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
247 | for conflictMarkerRe in VcsConflictMarkerRegExpList: |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
248 | conflict = conflictMarkerRe.search(codestring) |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
249 | if conflict is not None: |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
250 | start, i = conflict.span() |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
251 | lineindex = 1 + codestring.count("\n", 0, start) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
252 | return [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
253 | {"error": (filename, lineindex, 0, "", "VCS conflict marker found")} |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
254 | ] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
255 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
256 | if filename.endswith(".ptl"): |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
257 | try: |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
258 | import quixote.ptl_compile # __IGNORE_WARNING_I10__ |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
259 | except ImportError: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
260 | return [{"error": (filename, 0, 0, "", "Quixote plugin not found.")}] |
7637
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
261 | template = quixote.ptl_compile.Template(codestring, filename) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
262 | template.compile() |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
263 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
264 | module = builtins.compile(codestring, filename, "exec", ast.PyCF_ONLY_AST) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
265 | except SyntaxError as detail: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
266 | index = 0 |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
267 | code = "" |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
268 | error = "" |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
269 | lines = traceback.format_exception_only(SyntaxError, detail) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
270 | match = re.match( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
271 | r'\s*File "(.+)", line (\d+)', lines[0].replace("<string>", filename) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
272 | ) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
273 | if match is not None: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
274 | fn, line = match.group(1, 2) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
275 | if lines[1].startswith("SyntaxError:"): |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
276 | error = re.match("SyntaxError: (.+)", lines[1]).group(1) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
277 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
278 | code = re.match("(.+)", lines[1]).group(1) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
279 | for seLine in lines[2:]: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
280 | if seLine.startswith("SyntaxError:"): |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
281 | error = re.match("SyntaxError: (.+)", seLine).group(1) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
282 | elif seLine.rstrip().endswith("^"): |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
283 | index = len(seLine.rstrip()) - 4 |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
284 | else: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
285 | fn = detail.filename |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
286 | line = detail.lineno or 1 |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
287 | error = detail.msg |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
288 | return [{"error": (fn, int(line), index, code.strip(), error)}] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
289 | except ValueError as detail: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
290 | try: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
291 | fn = detail.filename |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
292 | line = detail.lineno |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
293 | error = detail.msg |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
294 | except AttributeError: |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
295 | fn = filename |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
296 | line = 1 |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
297 | error = str(detail) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
298 | return [{"error": (fn, line, 0, "", error)}] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
299 | except Exception as detail: |
9462
e65379fdbd97
Changed code to resolve or acknowledge some potential security issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9292
diff
changeset
|
300 | with contextlib.suppress(AttributeError): |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
301 | fn = detail.filename |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
302 | line = detail.lineno |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
303 | error = detail.msg |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
304 | return [{"error": (fn, line, 0, "", error)}] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
305 | |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
306 | # pyflakes |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
307 | if not checkFlakes: |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
308 | return [{}] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
309 | |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
310 | results = [] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
311 | lines = codestring.splitlines() |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
312 | try: |
9924
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
313 | warnings = Checker( |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
314 | module, filename, builtins=additionalBuiltins, withDoctest=True |
b41c9a7bcbbb
Syntax Checker
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
315 | ) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
316 | warnings.messages.sort(key=lambda a: a.lineno) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
317 | for warning in warnings.messages: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
318 | if ignoreStarImportWarnings and isinstance( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
319 | warning, (ImportStarUsed, ImportStarUsage) |
5363
cbe61c2f9772
Extended the code of the flakes checker plug-in to really ignore the * imports warnings, if configured that way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
320 | ): |
3065
070b35dde35e
Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2571
diff
changeset
|
321 | continue |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
322 | |
3177
5af61402d74d
Update pyflakes to 0.7.3
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3173
diff
changeset
|
323 | _fn, lineno, col, message, msg_args = warning.getMessageData() |
5586
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
324 | lineFlags = extractLineFlags(lines[lineno - 1].strip()) |
8243
cc717c2ae956
Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8234
diff
changeset
|
325 | with contextlib.suppress(IndexError): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
326 | lineFlags += extractLineFlags(lines[lineno].strip(), flagsLine=True) |
9591
3c56c81a70be
Added the "__IGNORE_FLAKES_WARNING__" flag to the syntax checker to suppress a pyflakes warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9508
diff
changeset
|
327 | if ( |
3c56c81a70be
Added the "__IGNORE_FLAKES_WARNING__" flag to the syntax checker to suppress a pyflakes warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9508
diff
changeset
|
328 | "__IGNORE_WARNING__" not in lineFlags |
3c56c81a70be
Added the "__IGNORE_FLAKES_WARNING__" flag to the syntax checker to suppress a pyflakes warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9508
diff
changeset
|
329 | and "__IGNORE_FLAKES_WARNING__" not in lineFlags |
3c56c81a70be
Added the "__IGNORE_FLAKES_WARNING__" flag to the syntax checker to suppress a pyflakes warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9508
diff
changeset
|
330 | and "noqa" not in lineFlags |
3c56c81a70be
Added the "__IGNORE_FLAKES_WARNING__" flag to the syntax checker to suppress a pyflakes warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9508
diff
changeset
|
331 | ): |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
332 | results.append((_fn, lineno, col, "", message, msg_args)) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
333 | except SyntaxError as err: |
8234
fcb6b4b96274
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8217
diff
changeset
|
334 | msg = err.text.strip() if err.text.strip() else err.msg |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
335 | results.append((filename, err.lineno, 0, "FLAKES_ERROR", msg, [])) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
336 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
337 | return [{"warnings": results}] |