Skip to content
Snippets Groups Projects
Commit 996b3fb5 authored by Daniel Miller's avatar Daniel Miller Committed by Claudiu Popa
Browse files

Respect disable=... in config with --py3k (#1726)

parent 99abc893
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4,18 +4,7 @@ Pylint's ChangeLog
What's New in Pylint 1.8?
=========================
 
* New warning `shallow-copy-environ` added
Shallow copy of os.environ doesn't work as people may expect. os.environ
is not a dict object but rather a proxy object, so any changes made
on copy may have unexpected effects on os.environ
Instead of copy.copy(os.environ) method os.environ.copy() should be
used.
See https://bugs.python.org/issue15373 for details.
Close #1301
* Respect disable=... in config file when running with --py3k.
 
* Do not display no-absolute-import warning multiple times per file.
 
Loading
Loading
Loading
Loading
@@ -595,6 +595,10 @@ class PyLinter(config.OptionsManagerMixIn,
for msg_id in self._checker_messages('python3'):
if msg_id.startswith('E'):
self.enable(msg_id)
config_parser = self.cfgfile_parser
if config_parser.has_option('MESSAGES CONTROL', 'disable'):
value = config_parser.get('MESSAGES CONTROL', 'disable')
self.global_set_option('disable', value)
else:
self.disable('python3')
self.set_option('reports', False)
Loading
Loading
@@ -614,6 +618,10 @@ class PyLinter(config.OptionsManagerMixIn,
self.enable(msg_id)
else:
self.disable(msg_id)
config_parser = self.cfgfile_parser
if config_parser.has_option('MESSAGES CONTROL', 'disable'):
value = config_parser.get('MESSAGES CONTROL', 'disable')
self.global_set_option('disable', value)
self._python3_porting_mode = True
 
# block level option handling #############################################
Loading
Loading
[MESSAGES CONTROL]
disable=no-absolute-import
"""Contains both normal error messages and Python3 porting error messages."""
# pylint: disable=too-few-public-methods
# error: import missing `from __future__ import absolute_import`
import sys
# error: Use raise ErrorClass(args) instead of raise ErrorClass, args.
raise Exception, 1
class Test(object):
"""dummy"""
def __init__(self):
# warning: Calling a dict.iter*() method
{1: 2}.iteritems()
return 42
# error: print statement used
print 'not in python3'
Loading
Loading
@@ -237,6 +237,41 @@ class TestRunTC(object):
self._test_output([module, "--py3k", "-E", "--msg-template='{msg}'"],
expected_output=expected)
 
@pytest.mark.skipif(sys.version_info[0] > 2, reason="Requires the --py3k flag.")
def test_py3k_commutative_with_config_disable(self):
module = join(HERE, 'regrtest_data', 'py3k_errors_and_warnings.py')
rcfile = join(HERE, 'regrtest_data', 'py3k-disabled.rc')
cmd = [module, "--msg-template='{msg}'", "--reports=n"]
expected = textwrap.dedent("""
************* Module py3k_errors_and_warnings
import missing `from __future__ import absolute_import`
Use raise ErrorClass(args) instead of raise ErrorClass, args.
Calling a dict.iter*() method
print statement used
""")
self._test_output(cmd + ["--py3k"], expected_output=expected)
expected = textwrap.dedent("""
************* Module py3k_errors_and_warnings
Use raise ErrorClass(args) instead of raise ErrorClass, args.
Calling a dict.iter*() method
print statement used
""")
self._test_output(cmd + ["--py3k", "--rcfile", rcfile],
expected_output=expected)
expected = textwrap.dedent("""
************* Module py3k_errors_and_warnings
Use raise ErrorClass(args) instead of raise ErrorClass, args.
print statement used
""")
self._test_output(cmd + ["--py3k", "-E", "--rcfile", rcfile],
expected_output=expected)
self._test_output(cmd + ["-E", "--py3k", "--rcfile", rcfile],
expected_output=expected)
def test_abbreviations_are_not_supported(self):
expected = "no such option: --load-plugin"
self._test_output([".", "--load-plugin"], expected_output=expected)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment