8th day of python challenges 111-117
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""test"""
|
||||
@@ -0,0 +1,13 @@
|
||||
"""test relative import"""
|
||||
# pylint: disable=no-absolute-import
|
||||
from __future__ import print_function
|
||||
import func_w0401
|
||||
__revision__ = filter(None, map(str, (1, 2, 3)))
|
||||
|
||||
|
||||
def function():
|
||||
"""something"""
|
||||
print(func_w0401)
|
||||
unic = u"unicode"
|
||||
low = unic.looower
|
||||
return low
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Bad continuations in dictionary comprehensions."""
|
||||
|
||||
__revision__ = 0
|
||||
|
||||
# Dictionary comprehensions should not require extra indentation when breaking
|
||||
# before the 'for', which is not part of the value
|
||||
C1 = {'key{}'.format(x): 'value{}'.format(x)
|
||||
for x in range(3)}
|
||||
|
||||
C2 = {'key{}'.format(x): 'value{}'.format(x) for x in
|
||||
range(3)}
|
||||
|
||||
# Dictionary comprehensions with multiple loops broken in different places
|
||||
C3 = {x*y: (x, y) for x in range(3) for y in range(3)}
|
||||
|
||||
C4 = {x*y: (x, y)
|
||||
for x in range(3) for y in range(3)}
|
||||
|
||||
C5 = {x*y: (x, y) for x
|
||||
in range(3) for y in range(3)}
|
||||
|
||||
C6 = {x*y: (x, y) for x in range(3)
|
||||
for y in range(3)}
|
||||
|
||||
C7 = {key:
|
||||
key ** 2
|
||||
for key in range(10)}
|
||||
|
||||
C8 = {
|
||||
key: key ** 2
|
||||
for key in range(10)}
|
||||
|
||||
# Misaligned cases for dict comprehensions
|
||||
C9 = {'key{}'.format(x): 'value{}'.format(x)
|
||||
for x in range(3)} # [bad-continuation]
|
||||
|
||||
C9 = {'key{}'.format(x): 'value{}'.format(x)
|
||||
for x in range(3)} # [bad-continuation]
|
||||
@@ -0,0 +1,24 @@
|
||||
# pylint: disable=E1101
|
||||
# pylint: disable=C0103
|
||||
# pylint: disable=R0903, useless-object-inheritance, unnecessary-pass
|
||||
"""test bugfix for #113231 in logging checker
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
# Muck up the names in an effort to confuse...
|
||||
import logging as renamed_logging
|
||||
|
||||
__revision__ = ''
|
||||
|
||||
class Logger(object):
|
||||
"""Fake logger"""
|
||||
pass
|
||||
|
||||
logger = renamed_logging.getLogger(__name__)
|
||||
fake_logger = Logger()
|
||||
|
||||
# Statements that should be flagged:
|
||||
renamed_logging.warning('%s, %s' % (4, 5))
|
||||
logger.warning('%s' % 5)
|
||||
|
||||
# Statements that should not be flagged:
|
||||
fake_logger.warn('%s' % 5)
|
||||
@@ -0,0 +1,14 @@
|
||||
# This is a very very very very very very very very very very very very very very very very very very very very very long line.
|
||||
# pylint: disable=line-too-long
|
||||
"""Make sure enable/disable pragmas work for messages that are applied to lines and not syntax nodes.
|
||||
|
||||
A disable pragma for a message that applies to nodes is applied to the whole
|
||||
block if it comes before the first statement (excluding the docstring). For
|
||||
line-based messages, this behavior needs to be altered to really only apply to
|
||||
the enclosed lines.
|
||||
"""
|
||||
# pylint: enable=line-too-long
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
print('This is a very long line which the linter will warn about, now that line-too-long has been enabled again.')
|
||||
@@ -0,0 +1,11 @@
|
||||
"""bla"""
|
||||
# pylint: disable=no-absolute-import
|
||||
|
||||
from input import func_w0233
|
||||
|
||||
__revision__ = 'yo'
|
||||
|
||||
class Aaaa(func_w0233.AAAA):
|
||||
"""test dotted name in ancestors"""
|
||||
def __init__(self):
|
||||
func_w0233.AAAA.__init__(self)
|
||||
@@ -0,0 +1,4 @@
|
||||
# pylint:enable=W04044
|
||||
"""check unknown option
|
||||
"""
|
||||
__revision__ = 1
|
||||
@@ -0,0 +1,20 @@
|
||||
"""check for method without self as first argument
|
||||
"""
|
||||
# pylint: disable=useless-object-inheritance
|
||||
from __future__ import print_function
|
||||
__revision__ = 0
|
||||
|
||||
|
||||
class Abcd(object):
|
||||
"""dummy class"""
|
||||
|
||||
def __init__(truc):
|
||||
"""method without self"""
|
||||
print(1)
|
||||
|
||||
def abdc(yoo):
|
||||
"""another test"""
|
||||
print(yoo)
|
||||
def edf(self):
|
||||
"""just another method"""
|
||||
print('yapudju in', self)
|
||||
@@ -0,0 +1,28 @@
|
||||
# pylint: disable=E1101, no-absolute-import
|
||||
"""Test checking of log format strings
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
__revision__ = ''
|
||||
|
||||
|
||||
def pprint():
|
||||
"""Test string format in logging statements.
|
||||
"""
|
||||
# These should all emit lint errors:
|
||||
logging.info(0, '') # 1205
|
||||
logging.info('', '') # 1205
|
||||
logging.info('%s%', '') # 1201
|
||||
logging.info('%s%s', '') # 1206
|
||||
logging.info('%s%y', '', '') # 1200
|
||||
logging.info('%s%s', '', '', '') # 1205
|
||||
|
||||
# These should be okay:
|
||||
logging.info(1)
|
||||
logging.info(True)
|
||||
logging.info('')
|
||||
logging.info('%s%')
|
||||
logging.info('%s', '')
|
||||
logging.info('%s%%', '')
|
||||
logging.info('%s%s', '', '')
|
||||
@@ -0,0 +1,21 @@
|
||||
"""test string format error
|
||||
"""
|
||||
# pylint: disable=print-statement,unsupported-binary-operation
|
||||
from __future__ import print_function
|
||||
|
||||
PARG_1 = PARG_2 = PARG_3 = 1
|
||||
|
||||
def pprint():
|
||||
"""Test string format
|
||||
"""
|
||||
print("%s %s" % {'PARG_1': 1, 'PARG_2': 2}) # E1306
|
||||
print("%s" % (PARG_1, PARG_2)) # E1305
|
||||
print("%(PARG_1)d %d" % {'PARG_1': 1, 'PARG_2': 2}) # E1302
|
||||
print("%(PARG_1)d %(PARG_2)d" % {'PARG_1': 1}) # E1304
|
||||
print("%(PARG_1)d %(PARG_2)d" % {'PARG_1': 1, 'PARG_2':2, 'PARG_3':3}) #W1301
|
||||
print("%(PARG_1)d %(PARG_2)d" % {'PARG_1': 1, 2:3}) # W1300 E1304
|
||||
print("%(PARG_1)d %(PARG_2)d" % (2, 3)) # 1303
|
||||
print("%(PARG_1)d %(PARG_2)d" % [2, 3]) # 1303
|
||||
print("%2z" % PARG_1)
|
||||
print("strange format %2" % PARG_2)
|
||||
print("works in 3 %a" % 1)
|
||||
@@ -0,0 +1,30 @@
|
||||
# pylint:disable=W0105, W0511, misplaced-comparison-constant, comparison-with-itself
|
||||
"""Stray backslash escapes may be missing a raw-string prefix."""
|
||||
|
||||
__revision__ = '$Id$'
|
||||
|
||||
# Bad escape sequences, which probably don't do what you expect.
|
||||
A = "\[\]\\"
|
||||
assert '\/' == '\\/'
|
||||
ESCAPE_BACKSLASH = '\`'
|
||||
|
||||
# Valid escape sequences.
|
||||
NEWLINE = "\n"
|
||||
OLD_ESCAPES = '\a\b\f\n\t\r\v'
|
||||
HEX = '\xad\x0a\x0d'
|
||||
FALSE_OCTAL = '\o123\o000' # Not octal in Python
|
||||
OCTAL = '\123\000'
|
||||
NOT_OCTAL = '\888\999'
|
||||
NUL = '\0'
|
||||
UNICODE = u'\u1234'
|
||||
HIGH_UNICODE = u'\U0000abcd'
|
||||
QUOTES = '\'\"'
|
||||
LITERAL_NEWLINE = '\
|
||||
'
|
||||
ESCAPE_UNICODE = "\\\\n"
|
||||
|
||||
# Bad docstring
|
||||
"""Even in a docstring
|
||||
|
||||
You shouldn't have ambiguous text like: C:\Program Files\alpha
|
||||
"""
|
||||
@@ -0,0 +1,42 @@
|
||||
# pylint: disable=C0111, W0232, useless-object-inheritance
|
||||
"""check for methods first arguments
|
||||
"""
|
||||
|
||||
__revision__ = 0
|
||||
|
||||
|
||||
class Obj(object):
|
||||
# C0202, classmethod
|
||||
def __new__(something):
|
||||
pass
|
||||
|
||||
# C0202, classmethod
|
||||
def class1(cls):
|
||||
pass
|
||||
class1 = classmethod(class1)
|
||||
|
||||
def class2(other):
|
||||
pass
|
||||
class2 = classmethod(class2)
|
||||
|
||||
|
||||
class Meta(type):
|
||||
# C0204, metaclass __new__
|
||||
def __new__(other, name, bases, dct):
|
||||
pass
|
||||
|
||||
# C0203, metaclass method
|
||||
def method1(cls):
|
||||
pass
|
||||
|
||||
def method2(other):
|
||||
pass
|
||||
|
||||
# C0205, metaclass classmethod
|
||||
def class1(cls):
|
||||
pass
|
||||
class1 = classmethod(class1)
|
||||
|
||||
def class2(other):
|
||||
pass
|
||||
class2 = classmethod(class2)
|
||||
@@ -0,0 +1,4 @@
|
||||
# pylint:disable=W0404
|
||||
"""check warning on local disabling
|
||||
"""
|
||||
__revision__ = 1
|
||||
@@ -0,0 +1,4 @@
|
||||
# pylint:enable=W0404
|
||||
"""check warning on local enabling
|
||||
"""
|
||||
__revision__ = 1
|
||||
@@ -0,0 +1,8 @@
|
||||
# pylint: skip-file
|
||||
"""disable-all is usable as an inline option"""
|
||||
|
||||
# no warning should be issued
|
||||
try:
|
||||
import this
|
||||
except:
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
# pylint: disable-all
|
||||
"""disable-all is usable as an inline option"""
|
||||
|
||||
# no warning should be issued
|
||||
try:
|
||||
import this
|
||||
except:
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
"""Test for reporting of suppressed messages."""
|
||||
|
||||
__revision__ = 0
|
||||
|
||||
def suppressed():
|
||||
"""A function with an unused variable."""
|
||||
# pylint: disable=W0612
|
||||
var = 0
|
||||
@@ -0,0 +1,22 @@
|
||||
"""Deprecated suppression style."""
|
||||
|
||||
__revision__ = None
|
||||
|
||||
a = 1 # pylint: disable=invalid-name
|
||||
b = 1 # pylint: disable-msg=invalid-name
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
c = 1
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
# pylint: disable-msg=invalid-name
|
||||
d = 1
|
||||
# pylint: enable-msg=invalid-name
|
||||
|
||||
# pylint: disable-msg=C0103
|
||||
e = 1
|
||||
# pylint: enable-msg=C0103
|
||||
|
||||
# pylint: disable=C0103
|
||||
f = 1
|
||||
# pylint: enable=C0103
|
||||
@@ -0,0 +1,13 @@
|
||||
"""Logging warnings using a logger class."""
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
|
||||
__revision__ = ''
|
||||
|
||||
LOG = logging.getLogger("domain")
|
||||
LOG.debug("%s" % "junk")
|
||||
LOG.log(logging.DEBUG, "%s" % "junk")
|
||||
LOG2 = LOG.debug
|
||||
LOG2("%s" % "junk")
|
||||
|
||||
logging.getLogger("domain").debug("%s" % "junk")
|
||||
@@ -0,0 +1,8 @@
|
||||
"""Tests for loopvar-in-closure."""
|
||||
|
||||
__revision__ = 0
|
||||
|
||||
|
||||
def bad_case():
|
||||
"""Loop variable from dict comprehension."""
|
||||
return {x: lambda: x for x in range(10)}
|
||||
@@ -0,0 +1,9 @@
|
||||
"""http://www.logilab.org/ticket/6949."""
|
||||
from __future__ import print_function
|
||||
__revision__ = None
|
||||
|
||||
print(__dict__ is not None)
|
||||
|
||||
__dict__ = {}
|
||||
|
||||
print(__dict__ is not None)
|
||||
@@ -0,0 +1,8 @@
|
||||
"""pylint doesn't see the NameError in this module"""
|
||||
|
||||
__revision__ = None
|
||||
|
||||
MSG = "hello %s" % MSG
|
||||
|
||||
MSG2 = ("hello %s" %
|
||||
MSG2)
|
||||
@@ -0,0 +1,14 @@
|
||||
"""Make sure warnings about redefinitions do not trigger for dummy variables."""
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
_, INTERESTING = 'a=b'.split('=')
|
||||
|
||||
value = 10
|
||||
|
||||
|
||||
def clobbering():
|
||||
"""Clobbers a dummy name from the outer scope."""
|
||||
value = 9
|
||||
for _ in range(7):
|
||||
print(value)
|
||||
@@ -0,0 +1,12 @@
|
||||
# pylint: disable=R0903, useless-object-inheritance
|
||||
"""#10075"""
|
||||
|
||||
__revision__ = 1
|
||||
|
||||
class Aaa(object):
|
||||
"""docstring"""
|
||||
def __init__(self):
|
||||
def inner_function(arg):
|
||||
"""inner docstring"""
|
||||
return arg + 4
|
||||
self.func = inner_function
|
||||
@@ -0,0 +1,98 @@
|
||||
#pylint: disable=C0103,R0904,R0903,W0201,no-absolute-import, useless-object-inheritance
|
||||
"""
|
||||
This module demonstrates a possible problem of pyLint with calling __init__ s
|
||||
from inherited classes.
|
||||
Initializations done there are not considered, which results in Error E0203 for
|
||||
self.cookedq.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import telnetlib
|
||||
|
||||
class SeeTelnet(telnetlib.Telnet):
|
||||
"""
|
||||
Extension of telnetlib.
|
||||
"""
|
||||
|
||||
def __init__(self, host=None, port=0):
|
||||
"""
|
||||
Constructor.
|
||||
When called without arguments, create an unconnected instance.
|
||||
With a hostname argument, it connects the instance; a port
|
||||
number is optional.
|
||||
Parameter:
|
||||
- host: IP address of the host
|
||||
- port: Port number
|
||||
"""
|
||||
telnetlib.Telnet.__init__(self, host, port)
|
||||
|
||||
def readUntilArray(self, matches, _=None):
|
||||
"""
|
||||
Read until a given string is encountered or until timeout.
|
||||
...
|
||||
"""
|
||||
self.process_rawq()
|
||||
maxLength = 0
|
||||
for match in matches:
|
||||
if len(match) > maxLength:
|
||||
maxLength = len(match)
|
||||
|
||||
class Base(object):
|
||||
"""bla bla"""
|
||||
dougloup_papa = None
|
||||
|
||||
def __init__(self):
|
||||
self._var = False
|
||||
|
||||
class Derived(Base):
|
||||
"""derived blabla"""
|
||||
dougloup_moi = None
|
||||
def Work(self):
|
||||
"""do something"""
|
||||
# E0203 - Access to member '_var' before its definition
|
||||
if self._var:
|
||||
print("True")
|
||||
else:
|
||||
print("False")
|
||||
self._var = True
|
||||
|
||||
# E0203 - Access to member 'dougloup_papa' before its definition
|
||||
if self.dougloup_papa:
|
||||
print('dougloup !')
|
||||
self.dougloup_papa = True
|
||||
# E0203 - Access to member 'dougloup_moi' before its definition
|
||||
if self.dougloup_moi:
|
||||
print('dougloup !')
|
||||
self.dougloup_moi = True
|
||||
|
||||
|
||||
class QoSALConnection(object):
|
||||
"""blabla"""
|
||||
|
||||
_the_instance = None
|
||||
|
||||
def __new__(cls):
|
||||
if cls._the_instance is None:
|
||||
cls._the_instance = object.__new__(cls)
|
||||
return cls._the_instance
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
class DefinedOutsideInit(object):
|
||||
"""use_attr is seen as the method defining attr because its in
|
||||
first position
|
||||
"""
|
||||
def __init__(self):
|
||||
self.reset()
|
||||
|
||||
def use_attr(self):
|
||||
"""use and set members"""
|
||||
if self.attr:
|
||||
print('hop')
|
||||
self.attr = 10
|
||||
|
||||
def reset(self):
|
||||
"""reset members"""
|
||||
self.attr = 4
|
||||
@@ -0,0 +1,35 @@
|
||||
# pylint:disable=R0201, print-statement, too-few-public-methods, useless-object-inheritance
|
||||
"""Checks that class variables are seen as inherited !
|
||||
"""
|
||||
__revision__ = ''
|
||||
|
||||
class BaseClass(object):
|
||||
"""A simple base class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.base_var = {}
|
||||
|
||||
def met(self):
|
||||
"""yo"""
|
||||
def meeting(self, with_):
|
||||
"""ye"""
|
||||
return with_
|
||||
class MyClass(BaseClass):
|
||||
"""Inherits from BaseClass
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
BaseClass.__init__(self)
|
||||
self.var = {}
|
||||
|
||||
def met(self):
|
||||
"""Checks that base_var is not seen as defined outsite '__init__'
|
||||
"""
|
||||
self.var[1] = 'one'
|
||||
self.base_var[1] = 'one'
|
||||
return self.base_var, self.var
|
||||
|
||||
if __name__ == '__main__':
|
||||
OBJ = MyClass()
|
||||
OBJ.met()
|
||||
@@ -0,0 +1,11 @@
|
||||
"""test import from a builtin module"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from math import log10
|
||||
|
||||
__revision__ = None
|
||||
|
||||
|
||||
def log10_2():
|
||||
"""bla bla bla"""
|
||||
return log10(2)
|
||||
@@ -0,0 +1,18 @@
|
||||
"""Test that valid class attribute doesn't trigger errors"""
|
||||
__revision__ = 'sponge bob'
|
||||
# pylint: disable=useless-object-inheritance
|
||||
|
||||
class Clazz(object):
|
||||
"dummy class"
|
||||
|
||||
def __init__(self):
|
||||
self.topic = 5
|
||||
self._data = 45
|
||||
|
||||
def change_type(self, new_class):
|
||||
"""Change type"""
|
||||
self.__class__ = new_class
|
||||
|
||||
def do_nothing(self):
|
||||
"I do nothing useful"
|
||||
return self.topic + 56
|
||||
@@ -0,0 +1,33 @@
|
||||
# pylint: disable=C0111,R0903,W0232, useless-object-inheritance
|
||||
"""
|
||||
#2479
|
||||
|
||||
R0201 (formely W0212), Method could be a function shouldn't be emitted in case
|
||||
like factory method pattern
|
||||
"""
|
||||
__revision__ = 1
|
||||
|
||||
class XAsub(object):
|
||||
pass
|
||||
class XBsub(XAsub):
|
||||
pass
|
||||
class XCsub(XAsub):
|
||||
pass
|
||||
|
||||
class Aimpl(object):
|
||||
# disable "method could be a function" on classes which are not overriding
|
||||
# the factory method because in that case the usage of polymorphism is not
|
||||
# detected
|
||||
# pylint: disable=R0201
|
||||
def makex(self):
|
||||
return XAsub()
|
||||
|
||||
class Bimpl(Aimpl):
|
||||
|
||||
def makex(self):
|
||||
return XBsub()
|
||||
|
||||
class Cimpl(Aimpl):
|
||||
|
||||
def makex(self):
|
||||
return XCsub()
|
||||
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
#3123: W0212 false positive on static method
|
||||
"""
|
||||
__revision__ = 1
|
||||
|
||||
# pylint: disable=no-classmethod-decorator, no-staticmethod-decorator, useless-object-inheritance
|
||||
class A3123(object):
|
||||
"""oypuee"""
|
||||
_protected = 1
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
def cmeth(cls, val):
|
||||
"""set protected member"""
|
||||
cls._protected = +val
|
||||
|
||||
cmeth = classmethod(cmeth)
|
||||
|
||||
def smeth(val):
|
||||
"""set protected member"""
|
||||
A3123._protected += val
|
||||
|
||||
smeth = staticmethod(smeth)
|
||||
|
||||
prop = property(lambda self: self._protected)
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- pylint: disable=W0232,R0903, useless-object-inheritance
|
||||
"""Test that decorators sees the class namespace - just like
|
||||
function default values does but function body doesn't.
|
||||
|
||||
https://www.logilab.net/elo/ticket/3711 - bug finding decorator arguments
|
||||
https://www.logilab.net/elo/ticket/5626 - name resolution bug inside classes
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
class Test(object):
|
||||
"""test class"""
|
||||
ident = lambda x: x
|
||||
|
||||
@ident(ident)
|
||||
def method(self, val=ident(7), func=ident):
|
||||
"""hop"""
|
||||
print(self)
|
||||
return func(val)
|
||||
@@ -0,0 +1,38 @@
|
||||
# pylint: disable=R0903, useless-object-inheritance
|
||||
"""
|
||||
False positive case of E1101:
|
||||
|
||||
The error is triggered when the attribute set in the base class is
|
||||
modified with augmented assignment in a derived class.
|
||||
|
||||
http://www.logilab.org/ticket/9588
|
||||
"""
|
||||
__revision__ = 0
|
||||
|
||||
class BaseClass(object):
|
||||
"The base class"
|
||||
def __init__(self):
|
||||
"Set an attribute."
|
||||
self.e1101 = 1
|
||||
|
||||
class FalsePositiveClass(BaseClass):
|
||||
"The first derived class which triggers the false positive"
|
||||
def __init__(self):
|
||||
"Augmented assignment triggers E1101."
|
||||
BaseClass.__init__(self)
|
||||
self.e1101 += 1
|
||||
|
||||
def countup(self):
|
||||
"Consequently this also triggers E1101."
|
||||
self.e1101 += 1
|
||||
|
||||
class NegativeClass(BaseClass):
|
||||
"The second derived class, which does not trigger the error E1101"
|
||||
def __init__(self):
|
||||
"Ordinary assignment is OK."
|
||||
BaseClass.__init__(self)
|
||||
self.e1101 = self.e1101 + 1
|
||||
|
||||
def countup(self):
|
||||
"No problem."
|
||||
self.e1101 += 1
|
||||
@@ -0,0 +1,21 @@
|
||||
# pylint: disable=W0232,R0903,W0613, useless-object-inheritance
|
||||
"""tagging a function as a class method cause a crash when checking for
|
||||
signature overriding
|
||||
"""
|
||||
|
||||
def fetch_config(mainattr=None):
|
||||
"""return a class method"""
|
||||
|
||||
def fetch_order(cls, attr, var):
|
||||
"""a class method"""
|
||||
if attr == mainattr:
|
||||
return var
|
||||
return None
|
||||
fetch_order = classmethod(fetch_order)
|
||||
return fetch_order
|
||||
|
||||
class Aaa(object):
|
||||
"""hop"""
|
||||
fetch_order = fetch_config('A')
|
||||
|
||||
__revision__ = None
|
||||
@@ -0,0 +1,33 @@
|
||||
# pylint: disable=R0903, useless-object-inheritance, unnecessary-pass
|
||||
"""Backend Base Classes for the schwelm user DB"""
|
||||
|
||||
__revision__ = "alpha"
|
||||
|
||||
class Aaa(object):
|
||||
"""docstring"""
|
||||
def __init__(self):
|
||||
self.__setattr__('a', 'b')
|
||||
|
||||
|
||||
def one_public(self):
|
||||
"""docstring"""
|
||||
pass
|
||||
|
||||
def another_public(self):
|
||||
"""docstring"""
|
||||
pass
|
||||
|
||||
class Bbb(Aaa):
|
||||
"""docstring"""
|
||||
pass
|
||||
|
||||
class Ccc(Aaa):
|
||||
"""docstring"""
|
||||
|
||||
class Ddd(Aaa):
|
||||
"""docstring"""
|
||||
pass
|
||||
|
||||
class Eee(Ddd):
|
||||
"""docstring"""
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
"""https://www.logilab.net/elo/ticket/18862"""
|
||||
from __future__ import print_function
|
||||
__revision__ = 1
|
||||
def function():
|
||||
"""hop"""
|
||||
ggg = lambda: xxx
|
||||
xxx = 1
|
||||
print(ggg())
|
||||
@@ -0,0 +1,20 @@
|
||||
# pylint: disable=R0903, metaclass-assignment, useless-object-inheritance
|
||||
"""test attribute access on metaclass"""
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
class Meta(type):
|
||||
"""the meta class"""
|
||||
def __init__(cls, name, bases, dictionary):
|
||||
super(Meta, cls).__init__(name, bases, dictionary)
|
||||
print(cls, cls._meta_args)
|
||||
delattr(cls, '_meta_args')
|
||||
|
||||
class Test(object):
|
||||
"""metaclassed class"""
|
||||
__metaclass__ = Meta
|
||||
_meta_args = ('foo', 'bar')
|
||||
|
||||
def __init__(self):
|
||||
print('__init__', self)
|
||||
@@ -0,0 +1,45 @@
|
||||
"""check builtin data descriptors such as mode and name attributes
|
||||
on a file are correctly handled
|
||||
|
||||
bug notified by Pierre Rouleau on 2005-04-24
|
||||
"""
|
||||
from __future__ import print_function
|
||||
__revision__ = None
|
||||
|
||||
class File(file): # pylint: disable=file-builtin
|
||||
""" Testing new-style class inheritance from file"""
|
||||
|
||||
#
|
||||
def __init__(self, name, mode="r", buffering=-1, verbose=False):
|
||||
"""Constructor"""
|
||||
|
||||
self.was_modified = False
|
||||
self.verbose = verbose
|
||||
super(File, self).__init__(name, mode, buffering)
|
||||
if self.verbose:
|
||||
print("File %s is opened. The mode is: %s" % (self.name,
|
||||
self.mode))
|
||||
|
||||
#
|
||||
def write(self, a_string):
|
||||
""" Write a string to the file."""
|
||||
|
||||
super(File, self).write(a_string)
|
||||
self.was_modified = True
|
||||
|
||||
#
|
||||
def writelines(self, sequence):
|
||||
""" Write a sequence of strings to the file. """
|
||||
|
||||
super(File, self).writelines(sequence)
|
||||
self.was_modified = True
|
||||
|
||||
#
|
||||
def close(self):
|
||||
"""Close the file."""
|
||||
|
||||
if self.verbose:
|
||||
print("Closing file %s" % self.name)
|
||||
|
||||
super(File, self).close()
|
||||
self.was_modified = False
|
||||
@@ -0,0 +1,42 @@
|
||||
''' Test for inheritance '''
|
||||
from __future__ import print_function
|
||||
__revision__ = 1
|
||||
# pylint: disable=too-few-public-methods, using-constant-test, useless-object-inheritance
|
||||
class AAAA(object):
|
||||
''' class AAAA '''
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def method1(self):
|
||||
''' method 1 '''
|
||||
print(self)
|
||||
|
||||
def method2(self):
|
||||
''' method 2 '''
|
||||
print(self)
|
||||
|
||||
class BBBB(AAAA):
|
||||
''' class BBBB '''
|
||||
|
||||
def __init__(self):
|
||||
AAAA.__init__(self)
|
||||
|
||||
# should ignore docstring calling from class AAAA
|
||||
def method1(self):
|
||||
AAAA.method1(self)
|
||||
|
||||
class CCCC(BBBB):
|
||||
''' class CCCC '''
|
||||
|
||||
def __init__(self):
|
||||
BBBB.__init__(self)
|
||||
|
||||
# should ignore docstring since CCCC is inherited from BBBB which is
|
||||
# inherited from AAAA containing method2
|
||||
if __revision__:
|
||||
def method2(self):
|
||||
AAAA.method2(self)
|
||||
else:
|
||||
def method2(self):
|
||||
AAAA.method1(self)
|
||||
@@ -0,0 +1,18 @@
|
||||
# pylint: disable=R0903, useless-object-inheritance
|
||||
"""Test case for the problem described below :
|
||||
- A class extends 'object'
|
||||
- This class defines its own __init__()
|
||||
* pylint will therefore check that baseclasses' init()
|
||||
are called
|
||||
- If this class defines an 'object' attribute, then pylint
|
||||
will use this new definition when trying to retrieve
|
||||
object.__init__()
|
||||
"""
|
||||
|
||||
__revision__ = None
|
||||
|
||||
class Statement(object):
|
||||
""" ... """
|
||||
def __init__(self):
|
||||
pass
|
||||
object = None
|
||||
@@ -0,0 +1,21 @@
|
||||
# pylint: disable=C0111,R0903, useless-object-inheritance
|
||||
"""#3291"""
|
||||
from __future__ import print_function
|
||||
|
||||
class Myarray(object):
|
||||
def __init__(self, array):
|
||||
self.array = array
|
||||
|
||||
def __mul__(self, val):
|
||||
return Myarray(val)
|
||||
|
||||
def astype(self):
|
||||
return "ASTYPE", self
|
||||
|
||||
def randint(maximum):
|
||||
if maximum is not None:
|
||||
return Myarray([1, 2, 3]) * 2
|
||||
|
||||
return int(5)
|
||||
|
||||
print(randint(1).astype()) # we don't wan't an error for astype access
|
||||
@@ -0,0 +1,24 @@
|
||||
# pylint: disable=R0903, useless-object-inheritance
|
||||
"""
|
||||
Simple test case for an annoying behavior in pylint.
|
||||
"""
|
||||
|
||||
__revision__ = 'pouet'
|
||||
|
||||
class Test(object):
|
||||
"""Smallest test case for reported issue."""
|
||||
|
||||
def __init__(self):
|
||||
self._thing = None
|
||||
|
||||
@property
|
||||
def myattr(self):
|
||||
"""Getter for myattr"""
|
||||
return self._thing
|
||||
|
||||
@myattr.setter
|
||||
def myattr(self, value):
|
||||
"""Setter for myattr."""
|
||||
self._thing = value
|
||||
|
||||
Test().myattr = 'grou'
|
||||
@@ -0,0 +1,21 @@
|
||||
"""http://www.logilab.org/ticket/8771"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
def generator():
|
||||
"""yield as assignment"""
|
||||
yield 45
|
||||
xxxx = yield 123
|
||||
print(xxxx)
|
||||
|
||||
def generator_fp1(seq):
|
||||
"""W0631 false positive"""
|
||||
for val in seq:
|
||||
pass
|
||||
for val in seq:
|
||||
yield val
|
||||
|
||||
def generator_fp2():
|
||||
"""E0601 false positive"""
|
||||
xxxx = 12
|
||||
yield xxxx
|
||||
@@ -0,0 +1,8 @@
|
||||
""" module doc """
|
||||
# pylint: disable=useless-return
|
||||
__revision__ = None
|
||||
|
||||
def somegen():
|
||||
"""this kind of mix is OK"""
|
||||
yield 1
|
||||
return
|
||||
@@ -0,0 +1,8 @@
|
||||
"""test no crash on __file__ global"""
|
||||
|
||||
def func():
|
||||
"""override __file__"""
|
||||
global __file__
|
||||
__file__ = 'hop'
|
||||
|
||||
__revision__ = 'pouet'
|
||||
@@ -0,0 +1,15 @@
|
||||
"""pylint should detect yield and return mix inside generators"""
|
||||
# pylint: disable=using-constant-test, inconsistent-return-statements
|
||||
def somegen():
|
||||
"""this is a bad generator"""
|
||||
if True:
|
||||
return 1
|
||||
else:
|
||||
yield 2
|
||||
|
||||
def moregen():
|
||||
"""this is another bad generator"""
|
||||
if True:
|
||||
yield 1
|
||||
else:
|
||||
return 2
|
||||
@@ -0,0 +1,61 @@
|
||||
# pylint: disable=useless-return, useless-object-inheritance
|
||||
"""check assignment to function call where the function doesn't return
|
||||
|
||||
'E1111': ('Assigning to function call which doesn\'t return',
|
||||
'Used when an assignment is done on a function call but the \
|
||||
infered function doesn\'t return anything.'),
|
||||
'W1111': ('Assigning to function call which only returns None',
|
||||
'Used when an assignment is done on a function call but the \
|
||||
infered function returns nothing but None.'),
|
||||
|
||||
"""
|
||||
from __future__ import generators, print_function
|
||||
|
||||
def func_no_return():
|
||||
"""function without return"""
|
||||
print('dougloup')
|
||||
|
||||
A = func_no_return()
|
||||
|
||||
|
||||
def func_return_none():
|
||||
"""function returning none"""
|
||||
print('dougloup')
|
||||
return None
|
||||
|
||||
A = func_return_none()
|
||||
|
||||
|
||||
def func_implicit_return_none():
|
||||
"""Function returning None from bare return statement."""
|
||||
return
|
||||
|
||||
A = func_implicit_return_none()
|
||||
|
||||
|
||||
def func_return_none_and_smth():
|
||||
"""function returning none and something else"""
|
||||
print('dougloup')
|
||||
if 2 or 3:
|
||||
return None
|
||||
return 3
|
||||
|
||||
A = func_return_none_and_smth()
|
||||
|
||||
def generator():
|
||||
"""no problemo"""
|
||||
yield 2
|
||||
|
||||
A = generator()
|
||||
|
||||
class Abstract(object):
|
||||
"""bla bla"""
|
||||
|
||||
def abstract_method(self):
|
||||
"""use to return something in concrete implementation"""
|
||||
raise NotImplementedError
|
||||
|
||||
def use_abstract(self):
|
||||
"""should not issue E1111"""
|
||||
var = self.abstract_method()
|
||||
print(var)
|
||||
@@ -0,0 +1,20 @@
|
||||
"""check unused import for metaclasses
|
||||
"""
|
||||
# pylint: disable=too-few-public-methods,wrong-import-position,ungrouped-imports
|
||||
__revision__ = 1
|
||||
import abc
|
||||
import sys
|
||||
from abc import ABCMeta
|
||||
from abc import ABCMeta as SomethingElse
|
||||
|
||||
class Meta(metaclass=abc.ABCMeta):
|
||||
""" Test """
|
||||
def __init__(self):
|
||||
self.data = sys.executable
|
||||
self.test = abc
|
||||
|
||||
class Meta2(metaclass=ABCMeta):
|
||||
""" Test """
|
||||
|
||||
class Meta3(metaclass=SomethingElse):
|
||||
""" test """
|
||||
@@ -0,0 +1,3 @@
|
||||
"""check unused import from a wildcard import"""
|
||||
# pylint: disable=no-absolute-import
|
||||
from input.func_w0611 import *
|
||||
@@ -0,0 +1,12 @@
|
||||
"""test global statement"""
|
||||
|
||||
__revision__ = 0
|
||||
|
||||
exec 'a = __revision__'
|
||||
exec 'a = 1' in {}
|
||||
|
||||
exec 'a = 1' in globals()
|
||||
|
||||
def func():
|
||||
"""exec in local scope"""
|
||||
exec 'b = 1'
|
||||
@@ -0,0 +1,51 @@
|
||||
# pylint: disable=R0903,W0212,W0403,W0406,no-absolute-import,wrong-import-order, useless-object-inheritance
|
||||
|
||||
"""test for call to __init__ from a non ancestor class
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from . import func_w0233
|
||||
import nonexistant
|
||||
__revision__ = '$Id: func_w0233.py,v 1.2 2004-09-29 08:35:13 syt Exp $'
|
||||
|
||||
class AAAA(object):
|
||||
"""ancestor 1"""
|
||||
|
||||
def __init__(self):
|
||||
print('init', self)
|
||||
BBBBMixin.__init__(self)
|
||||
|
||||
class BBBBMixin(object):
|
||||
"""ancestor 2"""
|
||||
|
||||
def __init__(self):
|
||||
print('init', self)
|
||||
|
||||
class CCC(BBBBMixin, func_w0233.AAAA, func_w0233.BBBB, nonexistant.AClass):
|
||||
"""mix different things, some inferable some not"""
|
||||
def __init__(self):
|
||||
BBBBMixin.__init__(self)
|
||||
func_w0233.AAAA.__init__(self)
|
||||
func_w0233.BBBB.__init__(self)
|
||||
nonexistant.AClass.__init__(self)
|
||||
|
||||
class DDDD(AAAA):
|
||||
"""call superclass constructor in disjunct branches"""
|
||||
def __init__(self, value):
|
||||
if value:
|
||||
AAAA.__init__(self)
|
||||
else:
|
||||
AAAA.__init__(self)
|
||||
|
||||
class Super(dict):
|
||||
""" test late binding super() call """
|
||||
def __init__(self):
|
||||
base = super()
|
||||
base.__init__()
|
||||
|
||||
class Super2(dict):
|
||||
""" Using the same idiom as Super, but without calling
|
||||
the __init__ method.
|
||||
"""
|
||||
def __init__(self):
|
||||
base = super()
|
||||
base.__woohoo__()
|
||||
@@ -0,0 +1,4 @@
|
||||
"""check use of l as long int marker
|
||||
"""
|
||||
# pylint: disable=long-suffix
|
||||
__revision__ = 1l
|
||||
@@ -0,0 +1,9 @@
|
||||
"""test cyclic import
|
||||
"""
|
||||
# pylint: disable=no-absolute-import
|
||||
from __future__ import print_function
|
||||
|
||||
from . import w0401_cycle
|
||||
|
||||
if w0401_cycle:
|
||||
print(w0401_cycle)
|
||||
@@ -0,0 +1,9 @@
|
||||
"""test cyclic import
|
||||
"""
|
||||
# pylint: disable=no-absolute-import
|
||||
from __future__ import print_function
|
||||
|
||||
from . import w0401_cycle # pylint: disable=cyclic-import
|
||||
|
||||
if w0401_cycle:
|
||||
print(w0401_cycle)
|
||||
@@ -0,0 +1,11 @@
|
||||
"""Test disabling of cyclic import check inside a function
|
||||
"""
|
||||
# pylint: disable=no-absolute-import
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
def func():
|
||||
"""Test disabling of cyclic import check inside a function"""
|
||||
from . import w0401_cycle # pylint: disable=cyclic-import
|
||||
if w0401_cycle:
|
||||
print(w0401_cycle)
|
||||
@@ -0,0 +1,2 @@
|
||||
"""Our big package."""
|
||||
__revision__ = None
|
||||
@@ -0,0 +1,9 @@
|
||||
"""All the things!"""
|
||||
# pylint: disable=no-absolute-import
|
||||
from .thing1 import THING1
|
||||
from .thing2 import THING2
|
||||
from .thing2 import THING1_PLUS_THING2
|
||||
__revision__ = None
|
||||
|
||||
_ = (THING1, THING2, THING1_PLUS_THING2)
|
||||
del _
|
||||
@@ -0,0 +1,3 @@
|
||||
"""The first thing."""
|
||||
__revision__ = None
|
||||
THING1 = "I am thing1"
|
||||
@@ -0,0 +1,7 @@
|
||||
"""The second thing."""
|
||||
# pylint: disable=no-absolute-import
|
||||
from .all_the_things import THING1
|
||||
__revision__ = None
|
||||
|
||||
THING2 = "I am thing2"
|
||||
THING1_PLUS_THING2 = "%s, plus %s" % (THING1, THING2)
|
||||
@@ -0,0 +1,27 @@
|
||||
"""Unittests for W0404 (reimport)"""
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import sys
|
||||
|
||||
import xml.etree.ElementTree
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from email import encoders
|
||||
import email.encoders
|
||||
|
||||
import sys #pylint: disable=ungrouped-imports,wrong-import-order
|
||||
__revision__ = 0
|
||||
|
||||
def no_reimport():
|
||||
"""docstring"""
|
||||
import os
|
||||
print(os)
|
||||
|
||||
|
||||
def reimport():
|
||||
"""This function contains a reimport."""
|
||||
import sys
|
||||
del sys
|
||||
|
||||
|
||||
del sys, ElementTree, xml.etree.ElementTree, encoders, email.encoders
|
||||
@@ -0,0 +1,31 @@
|
||||
"""check reimport
|
||||
"""
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
# pylint: disable=using-constant-test,ungrouped-imports,wrong-import-position
|
||||
import os
|
||||
from os.path import join, exists
|
||||
import os
|
||||
import re as _re
|
||||
|
||||
__revision__ = 0
|
||||
_re.match('yo', '.*')
|
||||
|
||||
if __revision__:
|
||||
print(os)
|
||||
from os.path import exists
|
||||
print(join, exists)
|
||||
|
||||
def func(yooo):
|
||||
"""reimport in different scope"""
|
||||
import os as ass
|
||||
ass.remove(yooo)
|
||||
import re
|
||||
re.compile('.*')
|
||||
|
||||
if 1: # pylint: disable=using-constant-test
|
||||
import sys
|
||||
print(sys.modules)
|
||||
else:
|
||||
print('bla')
|
||||
import sys
|
||||
@@ -0,0 +1,10 @@
|
||||
"""test module importing itself"""
|
||||
# pylint: disable=no-absolute-import,using-constant-test
|
||||
from __future__ import print_function
|
||||
from . import func_w0406
|
||||
|
||||
__revision__ = 0
|
||||
|
||||
|
||||
if __revision__:
|
||||
print(func_w0406)
|
||||
@@ -0,0 +1,25 @@
|
||||
"""check unused import
|
||||
"""
|
||||
# pylint: disable=no-absolute-import, useless-object-inheritance
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
class NonRegr(object):
|
||||
"""???"""
|
||||
def __init__(self):
|
||||
print('initialized')
|
||||
|
||||
def sys(self):
|
||||
"""should not get sys from there..."""
|
||||
print(self, sys)
|
||||
|
||||
def dummy(self, truc):
|
||||
"""yo"""
|
||||
return self, truc
|
||||
|
||||
def blop(self):
|
||||
"""yo"""
|
||||
print(self, 'blip')
|
||||
@@ -0,0 +1,37 @@
|
||||
"""test unused variable
|
||||
"""
|
||||
# pylint: disable=invalid-name, redefined-outer-name, no-absolute-import
|
||||
from __future__ import print_function
|
||||
PATH = OS = collections = deque = None
|
||||
|
||||
def function(matches):
|
||||
""""yo"""
|
||||
aaaa = 1
|
||||
index = -1
|
||||
for match in matches:
|
||||
index += 1
|
||||
print(match)
|
||||
|
||||
def visit_if(self, node):
|
||||
"""increments the branches counter"""
|
||||
branches = 1
|
||||
# don't double count If nodes coming from some 'elif'
|
||||
if node.orelse and len(node.orelse) > 1:
|
||||
branches += 1
|
||||
self.inc_branch(branches)
|
||||
self.stmts += branches
|
||||
|
||||
def test_global():
|
||||
""" Test various assignments of global
|
||||
variables through imports.
|
||||
"""
|
||||
global PATH, OS, collections, deque
|
||||
from os import path as PATH
|
||||
import os as OS
|
||||
import collections
|
||||
from collections import deque
|
||||
# make sure that these triggers unused-variable
|
||||
from sys import platform
|
||||
from sys import version as VERSION
|
||||
import this
|
||||
import re as RE
|
||||
@@ -0,0 +1,42 @@
|
||||
# pylint: disable=R0903, print-statement, useless-object-inheritance
|
||||
"""test unused argument
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
def function(arg=1):
|
||||
"""ignore arg"""
|
||||
|
||||
|
||||
class AAAA(object):
|
||||
"""dummy class"""
|
||||
|
||||
def method(self, arg):
|
||||
"""dummy method"""
|
||||
print(self)
|
||||
def __init__(self, *unused_args, **unused_kwargs):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def selected(cls, *args, **kwargs):
|
||||
"""called by the registry when the vobject has been selected.
|
||||
"""
|
||||
return cls
|
||||
|
||||
def using_inner_function(self, etype, size=1):
|
||||
"""return a fake result set for a particular entity type"""
|
||||
rset = AAAA([('A',)]*size, '%s X' % etype,
|
||||
description=[(etype,)]*size)
|
||||
def inner(row, col=0, etype=etype, req=self, rset=rset):
|
||||
"""inner using all its argument"""
|
||||
# pylint: disable = E1103
|
||||
return req.vreg.etype_class(etype)(req, rset, row, col)
|
||||
# pylint: disable = W0201
|
||||
rset.get_entity = inner
|
||||
|
||||
class BBBB(object):
|
||||
"""dummy class"""
|
||||
|
||||
def __init__(self, arg):
|
||||
"""Constructor with an extra parameter. Should raise a warning"""
|
||||
self.spam = 1
|
||||
@@ -0,0 +1,17 @@
|
||||
"""Test for W0623, overwriting names in exception handlers."""
|
||||
# pylint: disable=unnecessary-pass
|
||||
|
||||
__revision__ = ''
|
||||
|
||||
class MyError(Exception):
|
||||
"""Special exception class."""
|
||||
pass
|
||||
|
||||
|
||||
def some_function():
|
||||
"""A function."""
|
||||
|
||||
try:
|
||||
{}["a"]
|
||||
except KeyError as some_function: # W0623
|
||||
pass
|
||||
@@ -0,0 +1,11 @@
|
||||
"""test code similarities
|
||||
by defaut docstring are not considered
|
||||
"""
|
||||
__revision__ = 'id'
|
||||
A = 2
|
||||
B = 3
|
||||
C = A + B
|
||||
# need more than X lines to trigger the message
|
||||
C *= 2
|
||||
A -= B
|
||||
# all this should be detected
|
||||
@@ -0,0 +1,16 @@
|
||||
quicksort = lambda a: qs1(a,0,len(a)-1) ; import a
|
||||
qs1 = lambda a,lo,hi: qs2(a,lo,hi) if lo<hi else a ; import b
|
||||
qs2 = lambda a,lo,hi: qs3(lo,hi,*qsp(a,lo,hi)) ; import c
|
||||
qs3 = lambda lo,hi,a,p: qs1(qs1(a,p+1,hi),lo,p-1) ; import d
|
||||
qsp = lambda a,lo,hi: qsp1(a,lo,hi,a[hi],lo,lo) ; import e
|
||||
qsp1 = lambda a,lo,hi,p,i,j: qsp2(a,lo,hi,p,i,j,j<hi) ; import f
|
||||
qsp2 = lambda a,lo,hi,p,i,j,c: qspt(a,lo,hi,p,i,j,qsp3 if c else qsp7); import g
|
||||
qspt = lambda a,lo,hi,p,i,j,n: n(a,lo,hi,p,i,j) ; import h
|
||||
qsp3 = lambda a,lo,hi,p,i,j: qsp4(a,lo,hi,p,i,j,a[j]<p) ; import i
|
||||
qsp4 = lambda a,lo,hi,p,i,j,c: qspt(a,lo,hi,p,i,j,qsp5 if c else qsp6); import j
|
||||
qsp5 = lambda a,lo,hi,p,i,j: qsp1(sw(a,i,j),lo,hi,p,i+1,j+1) ; import k
|
||||
qsp6 = lambda a,lo,hi,p,i,j: qsp1(a,lo,hi,p,i,j+1) ; import l
|
||||
qsp7 = lambda a,lo,hi,p,i,j: (sw(a,i,hi), i) ; import m
|
||||
sw = lambda a,i,j: sw1(enumerate(a),i,j,a[i],(-1,a[j])) ; import n
|
||||
sw1 = lambda a,i,j,ai,aj: sw2([aj if x[0]==i else x for x in a],j,ai) ; import o
|
||||
sw2 = lambda a,j,ai: [ai if x[0]==j else x[1] for x in a] ; import p
|
||||
@@ -0,0 +1,6 @@
|
||||
"""#5575: by default no W0704 warning on bare pass in except"""
|
||||
|
||||
try:
|
||||
__exception__ = 0
|
||||
except ValueError:
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
from foo import (
|
||||
bar,
|
||||
baz,
|
||||
quux,
|
||||
quuux,
|
||||
quuuux,
|
||||
quuuuux,
|
||||
)
|
||||
4
venv/lib/python3.6/site-packages/pylint/test/input/noext
Normal file
4
venv/lib/python3.6/site-packages/pylint/test/input/noext
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
"""a python file without .py extension"""
|
||||
|
||||
__revision__ = None
|
||||
@@ -0,0 +1 @@
|
||||
"""test"""
|
||||
22
venv/lib/python3.6/site-packages/pylint/test/input/similar1
Normal file
22
venv/lib/python3.6/site-packages/pylint/test/input/similar1
Normal file
@@ -0,0 +1,22 @@
|
||||
import one
|
||||
from two import two
|
||||
three
|
||||
four
|
||||
five
|
||||
six # comments optionally ignored
|
||||
seven
|
||||
eight
|
||||
nine
|
||||
''' ten
|
||||
eleven
|
||||
twelve '''
|
||||
thirteen
|
||||
fourteen
|
||||
fifteen
|
||||
|
||||
|
||||
|
||||
|
||||
sixteen
|
||||
seventeen
|
||||
eighteen
|
||||
22
venv/lib/python3.6/site-packages/pylint/test/input/similar2
Normal file
22
venv/lib/python3.6/site-packages/pylint/test/input/similar2
Normal file
@@ -0,0 +1,22 @@
|
||||
import one
|
||||
from two import two
|
||||
three
|
||||
four
|
||||
five
|
||||
six
|
||||
seven
|
||||
eight
|
||||
nine
|
||||
''' ten
|
||||
ELEVEN
|
||||
twelve '''
|
||||
thirteen
|
||||
fourteen
|
||||
FIFTEEN
|
||||
|
||||
|
||||
|
||||
|
||||
sixteen
|
||||
seventeen
|
||||
eighteen
|
||||
@@ -0,0 +1,9 @@
|
||||
"""w0401 dependency
|
||||
"""
|
||||
# pylint: disable=print-statement, no-absolute-import
|
||||
from __future__ import print_function
|
||||
|
||||
from . import func_w0401
|
||||
|
||||
if func_w0401:
|
||||
print(input)
|
||||
@@ -0,0 +1,11 @@
|
||||
"""test code similarities
|
||||
by defaut docstring are not considered
|
||||
"""
|
||||
__revision__ = 'id'
|
||||
A = 2
|
||||
B = 3
|
||||
C = A + B
|
||||
# need more than X lines to trigger the message
|
||||
C *= 2
|
||||
A -= B
|
||||
# all this should be detected
|
||||
Reference in New Issue
Block a user