Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Papa Tamsir Kane
erp5
Commits
53995c01
Commit
53995c01
authored
Jun 29, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support pylint 1.7.2 and astroid 1.5.3.
parent
1ed317d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
19 deletions
+53
-19
product/ERP5Type/Utils.py
product/ERP5Type/Utils.py
+9
-2
product/ERP5Type/patches/pylint.py
product/ERP5Type/patches/pylint.py
+19
-8
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+25
-9
No files found.
product/ERP5Type/Utils.py
View file @
53995c01
...
@@ -437,6 +437,7 @@ def checkPythonSourceCode(source_code_str):
...
@@ -437,6 +437,7 @@ def checkPythonSourceCode(source_code_str):
try
:
try
:
from
pylint.lint
import
Run
from
pylint.lint
import
Run
from
pylint.reporters.text
import
TextReporter
from
pylint.reporters.text
import
TextReporter
from
pylint
import
__version__
as
pylint_version
except
ImportError
,
error
:
except
ImportError
,
error
:
try
:
try
:
compile
(
source_code_str
,
'<string>'
,
'exec'
)
compile
(
source_code_str
,
'<string>'
,
'exec'
)
...
@@ -475,7 +476,13 @@ def checkPythonSourceCode(source_code_str):
...
@@ -475,7 +476,13 @@ def checkPythonSourceCode(source_code_str):
input_file
.
write
(
source_code_str
)
input_file
.
write
(
source_code_str
)
input_file
.
seek
(
0
)
input_file
.
seek
(
0
)
Run
([
input_file
.
name
,
'--reports=n'
,
'--indent-string=" "'
,
'--zope=y'
,
if
pylint_version
>
'1.7'
:
extra_arguments
=
[
'--generated-members=REQUEST,acl_users,aq_parent'
,
'--load-plugins=pylint.extensions.bad_builtin'
,]
else
:
# BBB
extra_arguments
=
[
'--zope=y'
,]
Run
([
input_file
.
name
,
'--reports=n'
,
'--indent-string=" "'
,
# Disable Refactoring and Convention messages which are too verbose
# Disable Refactoring and Convention messages which are too verbose
# TODO-arnau: Should perphaps check ERP5 Naming Conventions?
# TODO-arnau: Should perphaps check ERP5 Naming Conventions?
'--disable=R,C'
,
'--disable=R,C'
,
...
@@ -510,7 +517,7 @@ def checkPythonSourceCode(source_code_str):
...
@@ -510,7 +517,7 @@ def checkPythonSourceCode(source_code_str):
# 'Access to a protected member %s of a client class'
# 'Access to a protected member %s of a client class'
'--disable=W0212'
,
'--disable=W0212'
,
# string module does not only contain deprecated functions...
# string module does not only contain deprecated functions...
'--deprecated-modules=regsub,TERMIOS,Bastion,rexec'
],
'--deprecated-modules=regsub,TERMIOS,Bastion,rexec'
]
+
extra_arguments
,
reporter
=
TextReporter
(
output_file
),
exit
=
False
)
reporter
=
TextReporter
(
output_file
),
exit
=
False
)
output_file
.
reset
()
output_file
.
reset
()
...
...
product/ERP5Type/patches/pylint.py
View file @
53995c01
...
@@ -24,13 +24,20 @@ from inspect import getargspec
...
@@ -24,13 +24,20 @@ from inspect import getargspec
try
:
try
:
from
pylint.checkers
import
imports
from
pylint.checkers
import
imports
import
astroid
import
astroid
try
:
from
astroid.exceptions
import
AstroidImportError
,
InconsistentMroError
except
ImportError
:
# BBB for astroid < 1.5
from
astroid.exceptions
import
InferenceError
as
AstroidImportError
# BBB for astroid < 1.4
from
astroid.exceptions
import
InferenceError
as
InconsistentMroError
except
ImportError
:
except
ImportError
:
pass
pass
else
:
else
:
def
_get_imported_module
(
self
,
importnode
,
modname
):
def
_get_imported_module
(
self
,
importnode
,
modname
):
try
:
try
:
return
importnode
.
do_import_module
(
modname
)
return
importnode
.
do_import_module
(
modname
)
except
astroid
.
InferenceError
,
ex
:
except
(
AstroidImportError
,
InconsistentMroError
)
,
ex
:
# BEGIN
# BEGIN
# XXX-arnau: Ignore ERP5 dynamic modules, hackish but required
# XXX-arnau: Ignore ERP5 dynamic modules, hackish but required
...
@@ -64,11 +71,15 @@ else:
...
@@ -64,11 +71,15 @@ else:
args
=
repr
(
modname
)
args
=
repr
(
modname
)
self
.
add_message
(
"F0401"
,
args
=
args
,
node
=
importnode
)
self
.
add_message
(
"F0401"
,
args
=
args
,
node
=
importnode
)
if
'modnode'
in
getargspec
(
imports
.
ImportsChecker
.
get_imported_module
).
args
:
if
hasattr
(
imports
.
ImportsChecker
,
'get_imported_module'
):
# BBB for pylint < 1.4.0
# BBB for pylint < 1.6.0
def
get_imported_module
(
self
,
modnode
,
importnode
,
modname
):
if
'modnode'
in
getargspec
(
imports
.
ImportsChecker
.
get_imported_module
).
args
:
return
_get_imported_module
(
self
,
importnode
,
modname
)
# BBB for pylint < 1.4.0
else
:
def
get_imported_module
(
self
,
modnode
,
importnode
,
modname
):
get_imported_module
=
_get_imported_module
return
_get_imported_module
(
self
,
importnode
,
modname
)
else
:
get_imported_module
=
_get_imported_module
imports
.
ImportsChecker
.
get_imported_module
=
get_imported_module
imports
.
ImportsChecker
.
get_imported_module
=
get_imported_module
else
:
imports
.
ImportsChecker
.
_get_imported_module
=
_get_imported_module
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
53995c01
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
import
gc
import
gc
import
os
import
os
from
pylint
import
__version__
as
pylint_version
import
shutil
import
shutil
import
tempfile
import
tempfile
import
unittest
import
unittest
...
@@ -1688,11 +1689,18 @@ class _TestZodbComponent(SecurityTestCase):
...
@@ -1688,11 +1689,18 @@ class _TestZodbComponent(SecurityTestCase):
component
.
setTextContent
(
'import unexistent_module'
)
component
.
setTextContent
(
'import unexistent_module'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
if
pylint_version
<
'1.7'
:
# BBB for pylint < 1.7
[
m
.
getMessage
().
translate
()
for
m
in
component
.
checkConsistency
()],
self
.
assertEqual
(
[
"Error in Source Code: F: 1, 0: Unable to import 'unexistent_module' (import-error)"
])
[
m
.
getMessage
().
translate
()
for
m
in
component
.
checkConsistency
()],
self
.
assertEqual
(
component
.
getTextContentErrorMessageList
(),
[
"Error in Source Code: F: 1, 0: Unable to import 'unexistent_module' (import-error)"
])
[
"F: 1, 0: Unable to import 'unexistent_module' (import-error)"
])
self
.
assertEqual
(
component
.
getTextContentErrorMessageList
(),
[
"F: 1, 0: Unable to import 'unexistent_module' (import-error)"
])
else
:
self
.
assertEqual
(
[
m
.
getMessage
().
translate
()
for
m
in
component
.
checkConsistency
()],
[
"Error in Source Code: E: 1, 0: Unable to import 'unexistent_module' (Failed to import module unexistent_module with error:"
])
self
.
assertEqual
(
component
.
getTextContentErrorMessageList
(),
[
"E: 1, 0: Unable to import 'unexistent_module' (Failed to import module unexistent_module with error:"
])
self
.
assertEqual
(
component
.
getTextContentWarningMessageList
(),
self
.
assertEqual
(
component
.
getTextContentWarningMessageList
(),
[
"W: 1, 0: Unused import unexistent_module (unused-import)"
])
[
"W: 1, 0: Unused import unexistent_module (unused-import)"
])
...
@@ -1725,16 +1733,24 @@ class _TestZodbComponent(SecurityTestCase):
...
@@ -1725,16 +1733,24 @@ class _TestZodbComponent(SecurityTestCase):
[
ComponentMixin
.
_message_text_content_not_set
],
[
ComponentMixin
.
_message_text_content_not_set
],
[],
[],
[]),
[]),
(
'def foobar(*args, **kwargs)
\
n
return 42'
,
[
"Error in Source Code: E: 1, 0: invalid syntax (syntax-error)"
],
[
"E: 1, 0: invalid syntax (syntax-error)"
],
[]),
# Make sure that foobar NameError is at the end to make sure that after
# Make sure that foobar NameError is at the end to make sure that after
# defining foobar function, it is not available at all
# defining foobar function, it is not available at all
(
'foobar'
,
(
'foobar'
,
[
"Error in Source Code: E: 1, 0: Undefined variable 'foobar' (undefined-variable)"
],
[
"Error in Source Code: E: 1, 0: Undefined variable 'foobar' (undefined-variable)"
],
[
"E: 1, 0: Undefined variable 'foobar' (undefined-variable)"
],
[
"E: 1, 0: Undefined variable 'foobar' (undefined-variable)"
],
[
"W: 1, 0: Statement seems to have no effect (pointless-statement)"
]))
[
"W: 1, 0: Statement seems to have no effect (pointless-statement)"
]))
if
pylint_version
<
'1.7'
:
# BBB for pylint < 1.7
invalid_code_dict
+=
\
(
'def foobar(*args, **kwargs)
\
n
return 42'
,
[
"Error in Source Code: E: 1, 0: invalid syntax (syntax-error)"
],
[
"E: 1, 0: invalid syntax (syntax-error)"
],
[]),
else
:
invalid_code_dict
+=
\
(
'def foobar(*args, **kwargs)
\
n
return 42'
,
[
"Error in Source Code: E: 1, 0: invalid syntax (<string>, line 1) (syntax-error)"
],
[
"E: 1, 0: invalid syntax (<string>, line 1) (syntax-error)"
],
[]),
for
(
invalid_code
,
for
(
invalid_code
,
check_consistency_list
,
check_consistency_list
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment