Exemplo n.º 1
0
# Muck up the names in an effort to confuse...
import logging as renamed_logging
import os as logging
from uninferable import UNINFERABLE

FORMAT_STR = '{0}, {1}'

# Statements that should be flagged:
renamed_logging.debug('{0}, {1}'.format(4, 5)) # [logging-format-interpolation]
renamed_logging.log(renamed_logging.DEBUG, 'msg: {}'.format('Run!')) # [logging-format-interpolation]
renamed_logging.debug(FORMAT_STR.format(4, 5)) # [logging-format-interpolation]
renamed_logging.log(renamed_logging.DEBUG, FORMAT_STR.format(4, 5)) # [logging-format-interpolation]
renamed_logging.info("Read {l} rows".format(l=123456789)) # [logging-format-interpolation]

# Statements that should not be flagged:
renamed_logging.debug(format(66, 'x'))
renamed_logging.debug(builtins.format(66, 'x'))
renamed_logging.log(renamed_logging.DEBUG, 'msg: Run!'.upper())
logging.debug('{0}, {1}'.format(4, 5))
logging.log(logging.DEBUG, 'msg: {}'.format('Run!'))
renamed_logging.info("Read {l:,d} rows".format(l=123456789))
renamed_logging.info(UNINFERABLE.format(l=123456789))


class Logger(renamed_logging.Logger):
    pass

custom_logger = Logger('three')
custom_logger.info('testing {0}'.format('info'))  # [logging-format-interpolation]
custom_logger.info('testing %s' % 'info')  # [logging-not-lazy]
Exemplo n.º 2
0
# pylint: disable=E1101, no-absolute-import
"""test checking use of the logging module
"""

__revision__ = ''

# Muck up the names in an effort to confuse...
import logging as renamed_logging
import os as logging

# Statements that should be flagged:
renamed_logging.warn('%s, %s' % (4, 5))
renamed_logging.exception('%s' % 'Exceptional!')
renamed_logging.log(renamed_logging.INFO, 'msg: %s' % 'Run!')

# Statements that should not be flagged:
renamed_logging.warn('%s, %s', 4, 5)
renamed_logging.log(renamed_logging.INFO, 'msg: %s', 'Run!')
renamed_logging.warn('%s' + ' the rest of a single string')
logging.warn('%s, %s' % (4, 5))
logging.log(logging.INFO, 'msg: %s' % 'Run!')
import logging as renamed_logging
import os as logging
from uninferable import UNINFERABLE

FORMAT_STR = '{0}, {1}'

# Statements that should be flagged:
renamed_logging.debug('{0}, {1}'.format(4, 5)) # [logging-format-interpolation]
renamed_logging.log(renamed_logging.DEBUG, 'msg: {}'.format('Run!')) # [logging-format-interpolation]
renamed_logging.debug(FORMAT_STR.format(4, 5)) # [logging-format-interpolation]
renamed_logging.log(renamed_logging.DEBUG, FORMAT_STR.format(4, 5)) # [logging-format-interpolation]
renamed_logging.info("Read {l} rows".format(l=123456789)) # [logging-format-interpolation]

# Statements that should not be flagged:
renamed_logging.debug(format(66, 'x'))
renamed_logging.debug(builtins.format(66, 'x'))
renamed_logging.log(renamed_logging.DEBUG, 'msg: Run!'.upper())
logging.debug('{0}, {1}'.format(4, 5))
logging.log(logging.DEBUG, 'msg: {}'.format('Run!'))
renamed_logging.info("Read {l:,d} rows".format(l=123456789))
renamed_logging.info(UNINFERABLE.format(l=123456789))


class Logger(renamed_logging.Logger):
    pass

custom_logger = Logger('three')

custom_logger.info('testing {0}'.format('info'))  # [logging-format-interpolation]
custom_logger.info('testing %s' % 'info') # [logging-not-lazy]
Exemplo n.º 4
0
renamed_logging.debug("{0}, {1}".format(4,
                                        5))  # [logging-format-interpolation]
renamed_logging.log(renamed_logging.DEBUG,
                    "msg: {}".format("Run!"))  # [logging-format-interpolation]
renamed_logging.debug(FORMAT_STR.format(4,
                                        5))  # [logging-format-interpolation]
renamed_logging.log(renamed_logging.DEBUG,
                    FORMAT_STR.format(4, 5))  # [logging-format-interpolation]
renamed_logging.info(
    "Read {l} rows".format(l=123456789))  # [logging-format-interpolation]

# Statements that should not be flagged:
renamed_logging.debug(format(66, "x"))
renamed_logging.debug(builtins.format(66, "x"))
renamed_logging.log(renamed_logging.DEBUG, "msg: Run!".upper())
logging.debug("{0}, {1}".format(4, 5))
logging.log(logging.DEBUG, "msg: {}".format("Run!"))
renamed_logging.info("Read {l:,d} rows".format(l=123456789))
renamed_logging.info(UNINFERABLE.format(l=123456789))


class Logger(renamed_logging.Logger):
    pass


custom_logger = Logger("three")

custom_logger.info(
    "testing {0}".format("info"))  # [logging-format-interpolation]
custom_logger.info("testing %s" % "info")  # [logging-not-lazy]
Exemplo n.º 5
0
# pylint: disable=missing-docstring,no-member,deprecated-method,invalid-name

# Muck up the names in an effort to confuse...
import logging as renamed_logging
import os as logging

var = "123"
# Statements that should be flagged:
renamed_logging.warn('%s, %s' % (4, 5))             # [logging-not-lazy]
renamed_logging.exception('%s' % 'Exceptional!')    # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO, 'msg: %s' % 'Run!')  # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO, "Var: " + var)  # [logging-not-lazy]

var_name = 'Var:'
# Statements that should not be flagged:
renamed_logging.warn('%s, %s', 4, 5)
renamed_logging.log(renamed_logging.INFO, 'msg: %s', 'Run!')
renamed_logging.warn('%s' + ' the rest of a single string')
renamed_logging.log(renamed_logging.INFO, var_name + var)
logging.warn('%s, %s' % (4, 5))
logging.log(logging.INFO, 'msg: %s' % 'Run!')
logging.log("Var: " + var)
Exemplo n.º 6
0
# pylint: disable=E1101, no-absolute-import, import-error,line-too-long, missing-docstring,wrong-import-order,wrong-import-position

try:
    import __builtin__ as builtins
except ImportError:
    import builtins

# Muck up the names in an effort to confuse...
import logging as renamed_logging
import os as logging

FORMAT_STR = "{0}, {1}"

# Statements that should be flagged:
renamed_logging.debug("{0}, {1}".format(4, 5))  # [logging-format-interpolation]
renamed_logging.log(renamed_logging.DEBUG, "msg: {}".format("Run!"))  # [logging-format-interpolation]
renamed_logging.debug(FORMAT_STR.format(4, 5))  # [logging-format-interpolation]
renamed_logging.log(renamed_logging.DEBUG, FORMAT_STR.format(4, 5))  # [logging-format-interpolation]

# Statements that should not be flagged:
renamed_logging.debug(format(66, "x"))
renamed_logging.debug(builtins.format(66, "x"))
renamed_logging.log(renamed_logging.DEBUG, "msg: Run!".upper())
logging.debug("{0}, {1}".format(4, 5))
logging.log(logging.DEBUG, "msg: {}".format("Run!"))
# pylint: disable=missing-docstring,no-member,deprecated-method,invalid-name

# Muck up the names in an effort to confuse...
import logging as renamed_logging
import os as logging

var = "123"
var_name = "Var:"
# Statements that should be flagged:
renamed_logging.warn("%s, %s" % (4, 5))  # [logging-not-lazy]
renamed_logging.exception("%s" % "Exceptional!")  # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO,
                    "msg: %s" % "Run!")  # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO, "Var: " + var)  # [logging-not-lazy]
renamed_logging.warn("%s" +
                     " the rest of a single string")  # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO, var_name + var)  # [logging-not-lazy]

var_name = "Var:"
# Statements that should not be flagged:
renamed_logging.warn("%s, %s", 4, 5)
renamed_logging.log(renamed_logging.INFO, "msg: %s", "Run!")
logging.warn("%s, %s" % (4, 5))
logging.log(logging.INFO, "msg: %s" % "Run!")
logging.log("Var: " + var)