The following issues were found
Lib/lib2to3/fixes/fix_nonzero.py
7 issues
Line: 5
Column: 1
# Author: Collin Winter
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixNonzero(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
Reported by Pylint.
Line: 6
Column: 1
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixNonzero(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
classdef< 'class' any+ ':'
Reported by Pylint.
Line: 18
Column: 25
any* > >
"""
def transform(self, node, results):
name = results["name"]
new = Name("__bool__", prefix=name.prefix)
name.replace(new)
Reported by Pylint.
Line: 8
Column: 1
from .. import fixer_base
from ..fixer_util import Name
class FixNonzero(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
classdef< 'class' any+ ':'
suite< any*
funcdef< 'def' name='__nonzero__'
Reported by Pylint.
Line: 8
Column: 1
from .. import fixer_base
from ..fixer_util import Name
class FixNonzero(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
classdef< 'class' any+ ':'
suite< any*
funcdef< 'def' name='__nonzero__'
Reported by Pylint.
Line: 18
Column: 5
any* > >
"""
def transform(self, node, results):
name = results["name"]
new = Name("__bool__", prefix=name.prefix)
name.replace(new)
Reported by Pylint.
Line: 18
Column: 5
any* > >
"""
def transform(self, node, results):
name = results["name"]
new = Name("__bool__", prefix=name.prefix)
name.replace(new)
Reported by Pylint.
Lib/lib2to3/fixes/fix_asserts.py
7 issues
Line: 5
Column: 1
# Author: Ezio Melotti
from ..fixer_base import BaseFix
from ..fixer_util import Name
NAMES = dict(
assert_="assertTrue",
assertEquals="assertEqual",
Reported by Pylint.
Line: 6
Column: 1
# Author: Ezio Melotti
from ..fixer_base import BaseFix
from ..fixer_util import Name
NAMES = dict(
assert_="assertTrue",
assertEquals="assertEqual",
assertNotEquals="assertNotEqual",
Reported by Pylint.
Line: 32
Column: 25
power< any+ trailer< '.' meth=(%s)> any* >
""" % '|'.join(map(repr, NAMES))
def transform(self, node, results):
name = results["meth"][0]
name.replace(Name(NAMES[str(name)], prefix=name.prefix))
Reported by Pylint.
Line: 26
Column: 1
)
class FixAsserts(BaseFix):
PATTERN = """
power< any+ trailer< '.' meth=(%s)> any* >
""" % '|'.join(map(repr, NAMES))
Reported by Pylint.
Line: 26
Column: 1
)
class FixAsserts(BaseFix):
PATTERN = """
power< any+ trailer< '.' meth=(%s)> any* >
""" % '|'.join(map(repr, NAMES))
Reported by Pylint.
Line: 32
Column: 5
power< any+ trailer< '.' meth=(%s)> any* >
""" % '|'.join(map(repr, NAMES))
def transform(self, node, results):
name = results["meth"][0]
name.replace(Name(NAMES[str(name)], prefix=name.prefix))
Reported by Pylint.
Line: 32
Column: 5
power< any+ trailer< '.' meth=(%s)> any* >
""" % '|'.join(map(repr, NAMES))
def transform(self, node, results):
name = results["meth"][0]
name.replace(Name(NAMES[str(name)], prefix=name.prefix))
Reported by Pylint.
Lib/idlelib/idle_test/test_mainmenu.py
7 issues
Line: 34
Column: 21
if menutup[0] == menu:
break
else:
self.assertTrue(0, f"{menu} not in menudefs")
self.assertTrue(any(re.search(pattern, menuitem[0])
for menuitem in menutup[1]
if menuitem is not None), # Separator.
f"{pattern} not in {menu}")
Reported by Pylint.
Line: 5
Column: 1
# Reported as 88%; mocking turtledemo absence would have no point.
from idlelib import mainmenu
import re
import unittest
class MainMenuTest(unittest.TestCase):
Reported by Pylint.
Line: 6
Column: 1
from idlelib import mainmenu
import re
import unittest
class MainMenuTest(unittest.TestCase):
def test_menudefs(self):
Reported by Pylint.
Line: 9
Column: 1
import unittest
class MainMenuTest(unittest.TestCase):
def test_menudefs(self):
actual = [item[0] for item in mainmenu.menudefs]
expect = ['file', 'edit', 'format', 'run', 'shell',
'debug', 'options', 'window', 'help']
Reported by Pylint.
Line: 11
Column: 5
class MainMenuTest(unittest.TestCase):
def test_menudefs(self):
actual = [item[0] for item in mainmenu.menudefs]
expect = ['file', 'edit', 'format', 'run', 'shell',
'debug', 'options', 'window', 'help']
self.assertEqual(actual, expect)
Reported by Pylint.
Line: 17
Column: 5
'debug', 'options', 'window', 'help']
self.assertEqual(actual, expect)
def test_default_keydefs(self):
self.assertGreaterEqual(len(mainmenu.default_keydefs), 50)
def test_tcl_indexes(self):
# Test tcl patterns used to find menuitem to alter.
# On failure, change pattern here and in function(s).
Reported by Pylint.
Line: 20
Column: 5
def test_default_keydefs(self):
self.assertGreaterEqual(len(mainmenu.default_keydefs), 50)
def test_tcl_indexes(self):
# Test tcl patterns used to find menuitem to alter.
# On failure, change pattern here and in function(s).
# Patterns here have '.*' for re instead of '*' for tcl.
for menu, pattern in (
('debug', '.*tack.*iewer'), # PyShell.debug_menu_postcommand
Reported by Pylint.
Lib/_aix_support.py
7 issues
Line: 89
Column: 9
try:
build_date = int(build_date)
except (ValueError, TypeError):
raise ValueError(f"AIX_BUILDDATE is not defined or invalid: "
f"{build_date!r}")
return _aix_tag(_aix_bgt(), build_date)
Reported by Pylint.
Line: 7
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import sysconfig
try:
import subprocess
except ImportError: # pragma: no cover
# _aix_support is used in distutils by setup.py to build C extensions,
# before subprocess dependencies like _posixsubprocess are available.
import _bootsubprocess as subprocess
Reported by Bandit.
Line: 14
Column: 1
import _bootsubprocess as subprocess
def _aix_tag(vrtl, bd):
# type: (List[int], int) -> str
# Infer the ABI bitwidth from maxsize (assuming 64 bit as the default)
_sz = 32 if sys.maxsize == (2**31-1) else 64
_bd = bd if bd != 0 else 9988
# vrtl[version, release, technology_level]
Reported by Pylint.
Line: 26
Column: 11
# extract version, release and technology level from a VRMF string
def _aix_vrtl(vrmf):
# type: (str) -> List[int]
v, r, tl = vrmf.split(".")[:3]
return [int(v[-1]), int(r), int(tl)]
def _aix_bos_rte():
# type: () -> Tuple[str, int]
Reported by Pylint.
Line: 26
Column: 8
# extract version, release and technology level from a VRMF string
def _aix_vrtl(vrmf):
# type: (str) -> List[int]
v, r, tl = vrmf.split(".")[:3]
return [int(v[-1]), int(r), int(tl)]
def _aix_bos_rte():
# type: () -> Tuple[str, int]
Reported by Pylint.
Line: 26
Column: 5
# extract version, release and technology level from a VRMF string
def _aix_vrtl(vrmf):
# type: (str) -> List[int]
v, r, tl = vrmf.split(".")[:3]
return [int(v[-1]), int(r), int(tl)]
def _aix_bos_rte():
# type: () -> Tuple[str, int]
Reported by Pylint.
Line: 65
Column: 11
e.g., "aix-6107-1415-32" for AIX 6.1 TL7 bd 1415, 32-bit
and, "aix-6107-1415-64" for AIX 6.1 TL7 bd 1415, 64-bit
"""
vrmf, bd = _aix_bos_rte()
return _aix_tag(_aix_vrtl(vrmf), bd)
# extract vrtl from the BUILD_GNU_TYPE as an int
def _aix_bgt():
Reported by Pylint.
Lib/lib2to3/fixes/fix_basestring.py
7 issues
Line: 5
Column: 1
# Author: Christian Heimes
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixBasestring(fixer_base.BaseFix):
BM_compatible = True
Reported by Pylint.
Line: 6
Column: 1
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixBasestring(fixer_base.BaseFix):
BM_compatible = True
PATTERN = "'basestring'"
Reported by Pylint.
Line: 13
Column: 31
PATTERN = "'basestring'"
def transform(self, node, results):
return Name("str", prefix=node.prefix)
Reported by Pylint.
Line: 8
Column: 1
from .. import fixer_base
from ..fixer_util import Name
class FixBasestring(fixer_base.BaseFix):
BM_compatible = True
PATTERN = "'basestring'"
def transform(self, node, results):
Reported by Pylint.
Line: 8
Column: 1
from .. import fixer_base
from ..fixer_util import Name
class FixBasestring(fixer_base.BaseFix):
BM_compatible = True
PATTERN = "'basestring'"
def transform(self, node, results):
Reported by Pylint.
Line: 13
Column: 5
PATTERN = "'basestring'"
def transform(self, node, results):
return Name("str", prefix=node.prefix)
Reported by Pylint.
Line: 13
Column: 5
PATTERN = "'basestring'"
def transform(self, node, results):
return Name("str", prefix=node.prefix)
Reported by Pylint.
Doc/tools/extensions/patchlevel.py
7 issues
Line: 19
Column: 1
import re
import sys
def get_header_version_info(srcdir):
patchlevel_h = os.path.join(srcdir, '..', 'Include', 'patchlevel.h')
# This won't pick out all #defines, but it will pick up the ones we
# care about.
rx = re.compile(r'\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)')
Reported by Pylint.
Line: 24
Column: 5
# This won't pick out all #defines, but it will pick up the ones we
# care about.
rx = re.compile(r'\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)')
d = {}
with open(patchlevel_h) as f:
for line in f:
m = rx.match(line)
Reported by Pylint.
Line: 26
Column: 5
# care about.
rx = re.compile(r'\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)')
d = {}
with open(patchlevel_h) as f:
for line in f:
m = rx.match(line)
if m is not None:
name, value = m.group(1, 2)
Reported by Pylint.
Line: 27
Column: 32
rx = re.compile(r'\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)')
d = {}
with open(patchlevel_h) as f:
for line in f:
m = rx.match(line)
if m is not None:
name, value = m.group(1, 2)
d[name] = value
Reported by Pylint.
Line: 29
Column: 13
d = {}
with open(patchlevel_h) as f:
for line in f:
m = rx.match(line)
if m is not None:
name, value = m.group(1, 2)
d[name] = value
release = version = '%s.%s' % (d['PY_MAJOR_VERSION'], d['PY_MINOR_VERSION'])
Reported by Pylint.
Line: 49
Column: 1
return version, release
def get_sys_version_info():
major, minor, micro, level, serial = sys.version_info
release = version = '%s.%s' % (major, minor)
release += '.%s' % micro
if level != 'final':
release += '%s%s' % (level[0], serial)
Reported by Pylint.
Line: 58
Column: 1
return version, release
def get_version_info():
try:
return get_header_version_info('.')
except (IOError, OSError):
version, release = get_sys_version_info()
print('Can\'t get version info from Include/patchlevel.h, ' \
Reported by Pylint.
Lib/lib2to3/fixes/fix_buffer.py
7 issues
Line: 7
Column: 1
"""Fixer that changes buffer(...) into memoryview(...)."""
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixBuffer(fixer_base.BaseFix):
BM_compatible = True
Reported by Pylint.
Line: 8
Column: 1
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixBuffer(fixer_base.BaseFix):
BM_compatible = True
Reported by Pylint.
Line: 20
Column: 25
power< name='buffer' trailer< '(' [any] ')' > any* >
"""
def transform(self, node, results):
name = results["name"]
name.replace(Name("memoryview", prefix=name.prefix))
Reported by Pylint.
Line: 11
Column: 1
from ..fixer_util import Name
class FixBuffer(fixer_base.BaseFix):
BM_compatible = True
explicit = True # The user must ask for this fixer
PATTERN = """
Reported by Pylint.
Line: 11
Column: 1
from ..fixer_util import Name
class FixBuffer(fixer_base.BaseFix):
BM_compatible = True
explicit = True # The user must ask for this fixer
PATTERN = """
Reported by Pylint.
Line: 20
Column: 5
power< name='buffer' trailer< '(' [any] ')' > any* >
"""
def transform(self, node, results):
name = results["name"]
name.replace(Name("memoryview", prefix=name.prefix))
Reported by Pylint.
Line: 20
Column: 5
power< name='buffer' trailer< '(' [any] ')' > any* >
"""
def transform(self, node, results):
name = results["name"]
name.replace(Name("memoryview", prefix=name.prefix))
Reported by Pylint.
Lib/lib2to3/fixes/fix_funcattrs.py
7 issues
Line: 5
Column: 1
# Author: Collin Winter
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixFuncattrs(fixer_base.BaseFix):
BM_compatible = True
Reported by Pylint.
Line: 6
Column: 1
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixFuncattrs(fixer_base.BaseFix):
BM_compatible = True
Reported by Pylint.
Line: 18
Column: 25
| 'func_dict') > any* >
"""
def transform(self, node, results):
attr = results["attr"][0]
attr.replace(Name(("__%s__" % attr.value[5:]),
prefix=attr.prefix))
Reported by Pylint.
Line: 9
Column: 1
from ..fixer_util import Name
class FixFuncattrs(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
power< any+ trailer< '.' attr=('func_closure' | 'func_doc' | 'func_globals'
| 'func_name' | 'func_defaults' | 'func_code'
Reported by Pylint.
Line: 9
Column: 1
from ..fixer_util import Name
class FixFuncattrs(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
power< any+ trailer< '.' attr=('func_closure' | 'func_doc' | 'func_globals'
| 'func_name' | 'func_defaults' | 'func_code'
Reported by Pylint.
Line: 18
Column: 5
| 'func_dict') > any* >
"""
def transform(self, node, results):
attr = results["attr"][0]
attr.replace(Name(("__%s__" % attr.value[5:]),
prefix=attr.prefix))
Reported by Pylint.
Line: 18
Column: 5
| 'func_dict') > any* >
"""
def transform(self, node, results):
attr = results["attr"][0]
attr.replace(Name(("__%s__" % attr.value[5:]),
prefix=attr.prefix))
Reported by Pylint.
Lib/lib2to3/fixes/fix_methodattrs.py
7 issues
Line: 6
Column: 1
# Author: Christian Heimes
# Local imports
from .. import fixer_base
from ..fixer_util import Name
MAP = {
"im_func" : "__func__",
"im_self" : "__self__",
Reported by Pylint.
Line: 7
Column: 1
# Local imports
from .. import fixer_base
from ..fixer_util import Name
MAP = {
"im_func" : "__func__",
"im_self" : "__self__",
"im_class" : "__self__.__class__"
Reported by Pylint.
Line: 21
Column: 25
power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* >
"""
def transform(self, node, results):
attr = results["attr"][0]
new = MAP[attr.value]
attr.replace(Name(new, prefix=attr.prefix))
Reported by Pylint.
Line: 15
Column: 1
"im_class" : "__self__.__class__"
}
class FixMethodattrs(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* >
"""
Reported by Pylint.
Line: 15
Column: 1
"im_class" : "__self__.__class__"
}
class FixMethodattrs(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* >
"""
Reported by Pylint.
Line: 21
Column: 5
power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* >
"""
def transform(self, node, results):
attr = results["attr"][0]
new = MAP[attr.value]
attr.replace(Name(new, prefix=attr.prefix))
Reported by Pylint.
Line: 21
Column: 5
power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* >
"""
def transform(self, node, results):
attr = results["attr"][0]
new = MAP[attr.value]
attr.replace(Name(new, prefix=attr.prefix))
Reported by Pylint.
Lib/idlelib/idle_test/test_debugobj_r.py
7 issues
Line: 4
Column: 1
"Test debugobj_r, coverage 56%."
from idlelib import debugobj_r
import unittest
class WrappedObjectTreeItemTest(unittest.TestCase):
def test_getattr(self):
Reported by Pylint.
Line: 7
Column: 1
import unittest
class WrappedObjectTreeItemTest(unittest.TestCase):
def test_getattr(self):
ti = debugobj_r.WrappedObjectTreeItem(list)
self.assertEqual(ti.append, list.append)
Reported by Pylint.
Line: 9
Column: 5
class WrappedObjectTreeItemTest(unittest.TestCase):
def test_getattr(self):
ti = debugobj_r.WrappedObjectTreeItem(list)
self.assertEqual(ti.append, list.append)
class StubObjectTreeItemTest(unittest.TestCase):
Reported by Pylint.
Line: 10
Column: 9
class WrappedObjectTreeItemTest(unittest.TestCase):
def test_getattr(self):
ti = debugobj_r.WrappedObjectTreeItem(list)
self.assertEqual(ti.append, list.append)
class StubObjectTreeItemTest(unittest.TestCase):
def test_init(self):
Reported by Pylint.
Line: 13
Column: 1
ti = debugobj_r.WrappedObjectTreeItem(list)
self.assertEqual(ti.append, list.append)
class StubObjectTreeItemTest(unittest.TestCase):
def test_init(self):
ti = debugobj_r.StubObjectTreeItem('socket', 1111)
self.assertEqual(ti.sockio, 'socket')
self.assertEqual(ti.oid, 1111)
Reported by Pylint.
Line: 15
Column: 5
class StubObjectTreeItemTest(unittest.TestCase):
def test_init(self):
ti = debugobj_r.StubObjectTreeItem('socket', 1111)
self.assertEqual(ti.sockio, 'socket')
self.assertEqual(ti.oid, 1111)
Reported by Pylint.
Line: 16
Column: 9
class StubObjectTreeItemTest(unittest.TestCase):
def test_init(self):
ti = debugobj_r.StubObjectTreeItem('socket', 1111)
self.assertEqual(ti.sockio, 'socket')
self.assertEqual(ti.oid, 1111)
if __name__ == '__main__':
Reported by Pylint.