Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • pycqa/pylint
1 result
Show changes
Commits on Source (8)
Loading
Loading
@@ -164,6 +164,15 @@ What's New in Pylint 1.8?
modules when checking import order.
Close #1702
 
* Fix ``pylint disable=fixme`` directives ignored for comments following the
last statement in a file.
Close #1681
* Fix ``line-too-long`` message deactivated by wrong disable directive.
The directive ``disable=fixme`` doesn't deactivate anymore the emission
of ``line-too-long`` message for long commented lines.
Close #1741
What's New in Pylint 1.7.1?
=========================
 
Loading
Loading
Loading
Loading
@@ -357,3 +357,10 @@ Other Changes
* Fix no ``wrong-import-order`` message emitted on ordering of first and third party libraries.
With this fix, pylint distinguishes first and third party modules when checking
import order.
* Fix the ignored ``pylint disable=fixme`` directives for comments following
the last statement in a file.
* Fix ``line-too-long`` message deactivated by wrong disable directive.
The directive ``disable=fixme`` doesn't deactivate anymore the emission
of ``line-too-long`` message for long commented lines.
Loading
Loading
@@ -1000,8 +1000,12 @@ class FormatChecker(BaseTokenChecker):
# Don't count excess whitespace in the line length.
line = stripped_line
mobj = OPTION_RGX.search(line)
if mobj and mobj.group(1).split('=', 1)[0].strip() == 'disable':
line = line.split('#')[0].rstrip()
if mobj and '=' in line:
front_of_equal, back_of_equal = mobj.group(1).split('=', 1)
if front_of_equal.strip() == 'disable':
if 'line-too-long' in [_msg_id.strip() for _msg_id in back_of_equal.split(',')]:
return None
line = line.rsplit('#', 1)[0].rstrip()
 
if len(line) > max_chars and not ignore_long_line.search(line):
self.add_message('line-too-long', line=i, args=(len(line), max_chars))
Loading
Loading
Loading
Loading
@@ -17,6 +17,7 @@ import six
 
from pylint.interfaces import IRawChecker
from pylint.checkers import BaseChecker
from pylint.utils import OPTION_RGX
 
 
MSGS = {
Loading
Loading
@@ -50,7 +51,22 @@ class EncodingChecker(BaseChecker):
'help': ('List of note tags to take in consideration, '
'separated by a comma.')}),)
 
def _check_note(self, notes, lineno, line):
def _check_note(self, notes, lineno, line, module_last_lineno):
"""
Add the message 'fixme' in case a note is found in the line.
:param notes: regular expression object matching any notes
(XXX, TODO, FIXME) behind a '#'
:type notes: re.pattern object
:param lineno: line number
:type lineno: int
:param line: line to be checked
:type line: str
:param module_last_lineno: last line number of the module as parsed by astroid
(may be different from real last line number in case
commented lines exist at the end of the module)
:type module_last_lineno: int
"""
# First, simply check if the notes are in the line at all. This is an
# optimisation to prevent using the regular expression on every line,
# but rather only on lines which may actually contain one of the notes.
Loading
Loading
@@ -65,8 +81,25 @@ class EncodingChecker(BaseChecker):
match = notes.search(line)
if not match:
return
self.add_message('fixme', args=line[match.start(1):].rstrip(),
line=lineno)
# In case the module ends with commented lines, the astroid parser
# don't take into account those lines, then:
# - the line number of those lines is greater than the
# module last line number (module.tolineno)
# - astroid module object can't inform pylint
# of disabled messages in those extra lines.
if lineno > module_last_lineno:
disable_option_match = OPTION_RGX.search(line)
if disable_option_match:
try:
_, value = disable_option_match.group(1).split('=', 1)
values = [_val.strip().upper() for _val in value.split(',')]
if set(values) & set(self.config.notes):
return
except ValueError:
self.add_message('bad-inline-option',
args=disable_option_match.group(1).strip(), line=line)
return
self.add_message('fixme', args=line[match.start(1):].rstrip(), line=lineno)
 
def _check_encoding(self, lineno, line, file_encoding):
try:
Loading
Loading
@@ -100,7 +133,7 @@ class EncodingChecker(BaseChecker):
for lineno, line in enumerate(stream):
line = self._check_encoding(lineno + 1, line, encoding)
if line is not None and notes:
self._check_note(notes, lineno + 1, line)
self._check_note(notes, lineno + 1, line, module.tolineno)
 
 
def register(linter):
Loading
Loading
Loading
Loading
@@ -349,6 +349,7 @@ class RefactoringChecker(checkers.BaseTokenChecker):
self._check_consistent_returns(node)
self._return_nodes[node.name] = []
 
@utils.check_messages('stop-iteration-return')
def visit_raise(self, node):
self._check_stop_iteration_inside_generator(node)
 
Loading
Loading
@@ -371,6 +372,7 @@ class RefactoringChecker(checkers.BaseTokenChecker):
stopiteration_qname = '{}.StopIteration'.format(utils.EXCEPTIONS_MODULE)
return any(_class.qname() == stopiteration_qname for _class in exc.mro())
 
@utils.check_messages('stop-iteration-return')
def visit_call(self, node):
self._check_raising_stopiteration_in_generator_next_call(node)
 
Loading
Loading
# -*- encoding=utf-8 -*-
# pylint: disable=missing-docstring, unused-variable
 
# +1: [fixme]
# FIXME: beep
 
Loading
Loading
@@ -16,3 +16,6 @@ def function():
xxx = "n/a" # XXX: Fix this later
# +1: [fixme]
#FIXME: no space after hash
#FIXME: in fact nothing to fix #pylint: disable=fixme
#TODO: in fact nothing to do #pylint: disable=fixme
#TODO: in fact nothing to do #pylint: disable=line-too-long, fixme
# pylint: disable=invalid-encoded-data
# pylint: disable=invalid-encoded-data, fixme
# +1: [line-too-long]
#####################################################################################################
# +1: [line-too-long]
Loading
Loading
@@ -16,6 +16,11 @@ badname = 'This line is already longer than 100 characters even without the prag
# http://example.com/this/is/a/very/long/url?but=splitting&urls=is&a=pain&so=they&can=be&long
# +1: [line-too-long]
# This line is toooooooooooooooooooooooooooooooooooooooooooooooo looooooooooooooooooooooooooooooooooooooooong #pylint: disable=fixme
# +1: [line-too-long]
#TODO: This line is toooooooooooooooooooooooooooooooooooooooooooooooo looooooooooooooooooooooooooooooooooooooooong #pylint: disable=fixme
def function():
# +3: [line-too-long]
Loading
Loading
line-too-long:3::Line too long (101/100)
line-too-long:5::Line too long (104/100)
line-too-long:15::Line too long (102/100)
line-too-long:24::Line too long (105/100)
line-too-long:20::Line too long (109/100)
line-too-long:23::Line too long (114/100)
line-too-long:29::Line too long (105/100)