The following issues were found

Lib/lib2to3/tests/data/py3_test_grammar.py
968 issues
function already defined line 312
Error

Line: 320 Column: 9

                      self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)")

        # argument annotation tests
        def f(x) -> list: pass
        self.assertEquals(f.__annotations__, {'return': list})
        def f(x:int): pass
        self.assertEquals(f.__annotations__, {'x': int})
        def f(*x:str): pass
        self.assertEquals(f.__annotations__, {'x': str})

            

Reported by Pylint.

function already defined line 312
Error

Line: 322 Column: 9

                      # argument annotation tests
        def f(x) -> list: pass
        self.assertEquals(f.__annotations__, {'return': list})
        def f(x:int): pass
        self.assertEquals(f.__annotations__, {'x': int})
        def f(*x:str): pass
        self.assertEquals(f.__annotations__, {'x': str})
        def f(**x:float): pass
        self.assertEquals(f.__annotations__, {'x': float})

            

Reported by Pylint.

function already defined line 312
Error

Line: 324 Column: 9

                      self.assertEquals(f.__annotations__, {'return': list})
        def f(x:int): pass
        self.assertEquals(f.__annotations__, {'x': int})
        def f(*x:str): pass
        self.assertEquals(f.__annotations__, {'x': str})
        def f(**x:float): pass
        self.assertEquals(f.__annotations__, {'x': float})
        def f(x, y:1+2): pass
        self.assertEquals(f.__annotations__, {'y': 3})

            

Reported by Pylint.

function already defined line 312
Error

Line: 326 Column: 9

                      self.assertEquals(f.__annotations__, {'x': int})
        def f(*x:str): pass
        self.assertEquals(f.__annotations__, {'x': str})
        def f(**x:float): pass
        self.assertEquals(f.__annotations__, {'x': float})
        def f(x, y:1+2): pass
        self.assertEquals(f.__annotations__, {'y': 3})
        def f(a, b:1, c:2, d): pass
        self.assertEquals(f.__annotations__, {'b': 1, 'c': 2})

            

Reported by Pylint.

function already defined line 312
Error

Line: 328 Column: 9

                      self.assertEquals(f.__annotations__, {'x': str})
        def f(**x:float): pass
        self.assertEquals(f.__annotations__, {'x': float})
        def f(x, y:1+2): pass
        self.assertEquals(f.__annotations__, {'y': 3})
        def f(a, b:1, c:2, d): pass
        self.assertEquals(f.__annotations__, {'b': 1, 'c': 2})
        def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass
        self.assertEquals(f.__annotations__,

            

Reported by Pylint.

function already defined line 312
Error

Line: 330 Column: 9

                      self.assertEquals(f.__annotations__, {'x': float})
        def f(x, y:1+2): pass
        self.assertEquals(f.__annotations__, {'y': 3})
        def f(a, b:1, c:2, d): pass
        self.assertEquals(f.__annotations__, {'b': 1, 'c': 2})
        def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass
        self.assertEquals(f.__annotations__,
                          {'b': 1, 'c': 2, 'e': 3, 'g': 6})
        def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10,

            

Reported by Pylint.

function already defined line 312
Error

Line: 332 Column: 9

                      self.assertEquals(f.__annotations__, {'y': 3})
        def f(a, b:1, c:2, d): pass
        self.assertEquals(f.__annotations__, {'b': 1, 'c': 2})
        def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass
        self.assertEquals(f.__annotations__,
                          {'b': 1, 'c': 2, 'e': 3, 'g': 6})
        def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10,
              **k:11) -> 12: pass
        self.assertEquals(f.__annotations__,

            

Reported by Pylint.

function already defined line 312
Error

Line: 335 Column: 9

                      def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass
        self.assertEquals(f.__annotations__,
                          {'b': 1, 'c': 2, 'e': 3, 'g': 6})
        def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10,
              **k:11) -> 12: pass
        self.assertEquals(f.__annotations__,
                          {'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
                           'k': 11, 'return': 12})
        # Check for SF Bug #1697248 - mixing decorators and a return annotation

            

Reported by Pylint.

function already defined line 312
Error

Line: 343 Column: 9

                      # Check for SF Bug #1697248 - mixing decorators and a return annotation
        def null(x): return x
        @null
        def f(x) -> list: pass
        self.assertEquals(f.__annotations__, {'return': list})

        # test closures with a variety of oparg's
        closure = 1
        def f(): return closure

            

Reported by Pylint.

function already defined line 312
Error

Line: 348 Column: 9

              
        # test closures with a variety of oparg's
        closure = 1
        def f(): return closure
        def f(x=1): return closure
        def f(*, k=1): return closure
        def f() -> int: return closure

        # Check ast errors in *args and *kwargs

            

Reported by Pylint.

Lib/tkinter/__init__.py
918 issues
Unable to import '_tkinter'
Error

Line: 37 Column: 1

              import sys
import types

import _tkinter # If this fails your Python may not be configured for Tk
TclError = _tkinter.TclError
from tkinter.constants import *
import re

wantobjects = 1

            

Reported by Pylint.

Instance of 'Misc' has no 'tk' member
Error

Line: 664 Column: 17

                      if self._tclCommands is not None:
            for name in self._tclCommands:
                #print '- Tkinter: deleted command', name
                self.tk.deletecommand(name)
            self._tclCommands = None

    def deletecommand(self, name):
        """Internal function.


            

Reported by Pylint.

Instance of 'Misc' has no 'tk' member
Error

Line: 672 Column: 9

              
        Delete the Tcl command provided in NAME."""
        #print '- Tkinter: deleted command', name
        self.tk.deletecommand(name)
        try:
            self._tclCommands.remove(name)
        except ValueError:
            pass


            

Reported by Pylint.

Instance of 'Misc' has no 'tk' member
Error

Line: 685 Column: 16

                      A parameter of 1 means adhere to Motif (e.g. no color
        change if mouse passes over slider).
        Returns the set value."""
        return self.tk.getboolean(self.tk.call(
            'set', 'tk_strictMotif', boolean))

    def tk_bisque(self):
        """Change the color scheme to light brown as used in Tk 3.6 and before."""
        self.tk.call('tk_bisque')

            

Reported by Pylint.

Instance of 'Misc' has no 'tk' member
Error

Line: 685 Column: 35

                      A parameter of 1 means adhere to Motif (e.g. no color
        change if mouse passes over slider).
        Returns the set value."""
        return self.tk.getboolean(self.tk.call(
            'set', 'tk_strictMotif', boolean))

    def tk_bisque(self):
        """Change the color scheme to light brown as used in Tk 3.6 and before."""
        self.tk.call('tk_bisque')

            

Reported by Pylint.

Instance of 'Misc' has no 'tk' member
Error

Line: 690 Column: 9

              
    def tk_bisque(self):
        """Change the color scheme to light brown as used in Tk 3.6 and before."""
        self.tk.call('tk_bisque')

    def tk_setPalette(self, *args, **kw):
        """Set a new color scheme for all widget elements.

        A single color as argument will cause that all colors of Tk

            

Reported by Pylint.

Instance of 'Misc' has no 'tk' member
Error

Line: 703 Column: 9

                      activeForeground, highlightBackground, selectBackground,
        background, highlightColor, selectForeground,
        disabledForeground, insertBackground, troughColor."""
        self.tk.call(('tk_setPalette',)
              + _flatten(args) + _flatten(list(kw.items())))

    def wait_variable(self, name='PY_VAR'):
        """Wait until the variable is modified.


            

Reported by Pylint.

Instance of 'Misc' has no 'tk' member
Error

Line: 711 Column: 9

              
        A parameter of type IntVar, StringVar, DoubleVar or
        BooleanVar must be given."""
        self.tk.call('tkwait', 'variable', name)
    waitvar = wait_variable # XXX b/w compat

    def wait_window(self, window=None):
        """Wait until a WIDGET is destroyed.


            

Reported by Pylint.

Instance of 'Misc' has no 'tk' member
Error

Line: 720 Column: 9

                      If no parameter is given self is used."""
        if window is None:
            window = self
        self.tk.call('tkwait', 'window', window._w)

    def wait_visibility(self, window=None):
        """Wait until the visibility of a WIDGET changes
        (e.g. it appears).


            

Reported by Pylint.

Instance of 'Misc' has no 'tk' member
Error

Line: 729 Column: 9

                      If no parameter is given self is used."""
        if window is None:
            window = self
        self.tk.call('tkwait', 'visibility', window._w)

    def setvar(self, name='PY_VAR', value='1'):
        """Set Tcl variable NAME to VALUE."""
        self.tk.setvar(name, value)


            

Reported by Pylint.

Lib/test/test_set.py
894 issues
Instance of 'TestJointOps' has no 'thetype' member
Error

Line: 48 Column: 18

                      self.word = word = 'simsalabim'
        self.otherword = 'madagascar'
        self.letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
        self.s = self.thetype(word)
        self.d = dict.fromkeys(word)

    def test_new_or_init(self):
        self.assertRaises(TypeError, self.thetype, [], 2)
        self.assertRaises(TypeError, set().__init__, a=1)

            

Reported by Pylint.

Instance of 'TestJointOps' has no 'assertRaises' member
Error

Line: 52 Column: 9

                      self.d = dict.fromkeys(word)

    def test_new_or_init(self):
        self.assertRaises(TypeError, self.thetype, [], 2)
        self.assertRaises(TypeError, set().__init__, a=1)

    def test_uniquification(self):
        actual = sorted(self.s)
        expected = sorted(self.d)

            

Reported by Pylint.

Instance of 'TestJointOps' has no 'thetype' member
Error

Line: 52 Column: 38

                      self.d = dict.fromkeys(word)

    def test_new_or_init(self):
        self.assertRaises(TypeError, self.thetype, [], 2)
        self.assertRaises(TypeError, set().__init__, a=1)

    def test_uniquification(self):
        actual = sorted(self.s)
        expected = sorted(self.d)

            

Reported by Pylint.

Instance of 'TestJointOps' has no 'assertRaises' member
Error

Line: 53 Column: 9

              
    def test_new_or_init(self):
        self.assertRaises(TypeError, self.thetype, [], 2)
        self.assertRaises(TypeError, set().__init__, a=1)

    def test_uniquification(self):
        actual = sorted(self.s)
        expected = sorted(self.d)
        self.assertEqual(actual, expected)

            

Reported by Pylint.

Instance of 'TestJointOps' has no 'assertEqual' member
Error

Line: 58 Column: 9

                  def test_uniquification(self):
        actual = sorted(self.s)
        expected = sorted(self.d)
        self.assertEqual(actual, expected)
        self.assertRaises(PassThru, self.thetype, check_pass_thru())
        self.assertRaises(TypeError, self.thetype, [[]])

    def test_len(self):
        self.assertEqual(len(self.s), len(self.d))

            

Reported by Pylint.

Instance of 'TestJointOps' has no 'thetype' member
Error

Line: 59 Column: 37

                      actual = sorted(self.s)
        expected = sorted(self.d)
        self.assertEqual(actual, expected)
        self.assertRaises(PassThru, self.thetype, check_pass_thru())
        self.assertRaises(TypeError, self.thetype, [[]])

    def test_len(self):
        self.assertEqual(len(self.s), len(self.d))


            

Reported by Pylint.

Instance of 'TestJointOps' has no 'assertRaises' member
Error

Line: 59 Column: 9

                      actual = sorted(self.s)
        expected = sorted(self.d)
        self.assertEqual(actual, expected)
        self.assertRaises(PassThru, self.thetype, check_pass_thru())
        self.assertRaises(TypeError, self.thetype, [[]])

    def test_len(self):
        self.assertEqual(len(self.s), len(self.d))


            

Reported by Pylint.

Instance of 'TestJointOps' has no 'assertRaises' member
Error

Line: 60 Column: 9

                      expected = sorted(self.d)
        self.assertEqual(actual, expected)
        self.assertRaises(PassThru, self.thetype, check_pass_thru())
        self.assertRaises(TypeError, self.thetype, [[]])

    def test_len(self):
        self.assertEqual(len(self.s), len(self.d))

    def test_contains(self):

            

Reported by Pylint.

Instance of 'TestJointOps' has no 'thetype' member
Error

Line: 60 Column: 38

                      expected = sorted(self.d)
        self.assertEqual(actual, expected)
        self.assertRaises(PassThru, self.thetype, check_pass_thru())
        self.assertRaises(TypeError, self.thetype, [[]])

    def test_len(self):
        self.assertEqual(len(self.s), len(self.d))

    def test_contains(self):

            

Reported by Pylint.

Instance of 'TestJointOps' has no 'assertEqual' member
Error

Line: 63 Column: 9

                      self.assertRaises(TypeError, self.thetype, [[]])

    def test_len(self):
        self.assertEqual(len(self.s), len(self.d))

    def test_contains(self):
        for c in self.letters:
            self.assertEqual(c in self.s, c in self.d)
        self.assertRaises(TypeError, self.s.__contains__, [[]])

            

Reported by Pylint.

Lib/test/test_statistics.py
838 issues
No value for argument 'data' in function call
Error

Line: 1960 Column: 13

                      with self.assertRaises(TypeError):
            fmean([10, None, 20])                   # non-numeric input
        with self.assertRaises(TypeError):
            fmean()                                 # missing data argument
        with self.assertRaises(TypeError):
            fmean([10, 20, 60], 70)                 # too many arguments

    def test_special_values(self):
        # Rules for special values are inherited from math.fsum()

            

Reported by Pylint.

No value for argument 'data' in function call
Error

Line: 2251 Column: 13

                      with self.assertRaises(TypeError):
            geometric_mean([10, None, 20])          # non-numeric input
        with self.assertRaises(TypeError):
            geometric_mean()                        # missing data argument
        with self.assertRaises(TypeError):
            geometric_mean([10, 20, 60], 70)        # too many arguments

    def test_special_values(self):
        # Rules for special values are inherited from math.fsum()

            

Reported by Pylint.

Too many positional arguments for function call
Error

Line: 2253 Column: 13

                      with self.assertRaises(TypeError):
            geometric_mean()                        # missing data argument
        with self.assertRaises(TypeError):
            geometric_mean([10, 20, 60], 70)        # too many arguments

    def test_special_values(self):
        # Rules for special values are inherited from math.fsum()
        geometric_mean = statistics.geometric_mean
        NaN = float('Nan')

            

Reported by Pylint.

No value for argument 'data' in function call
Error

Line: 2428 Column: 13

                      quantiles = statistics.quantiles
        StatisticsError = statistics.StatisticsError
        with self.assertRaises(TypeError):
            quantiles()                         # Missing arguments
        with self.assertRaises(TypeError):
            quantiles([10, 20, 30], 13, n=4)    # Too many arguments
        with self.assertRaises(TypeError):
            quantiles([10, 20, 30], 4)          # n is a positional argument
        with self.assertRaises(StatisticsError):

            

Reported by Pylint.

Too many positional arguments for function call
Error

Line: 2430 Column: 13

                      with self.assertRaises(TypeError):
            quantiles()                         # Missing arguments
        with self.assertRaises(TypeError):
            quantiles([10, 20, 30], 13, n=4)    # Too many arguments
        with self.assertRaises(TypeError):
            quantiles([10, 20, 30], 4)          # n is a positional argument
        with self.assertRaises(StatisticsError):
            quantiles([10, 20, 30], n=0)        # n is zero
        with self.assertRaises(StatisticsError):

            

Reported by Pylint.

Too many positional arguments for function call
Error

Line: 2432 Column: 13

                      with self.assertRaises(TypeError):
            quantiles([10, 20, 30], 13, n=4)    # Too many arguments
        with self.assertRaises(TypeError):
            quantiles([10, 20, 30], 4)          # n is a positional argument
        with self.assertRaises(StatisticsError):
            quantiles([10, 20, 30], n=0)        # n is zero
        with self.assertRaises(StatisticsError):
            quantiles([10, 20, 30], n=-1)       # n is negative
        with self.assertRaises(TypeError):

            

Reported by Pylint.

Instance of 'TestNormalDist' has no 'module' member
Error

Line: 2535 Column: 14

                  # implementing our own implementations from scratch.

    def test_slots(self):
        nd = self.module.NormalDist(300, 23)
        with self.assertRaises(TypeError):
            vars(nd)
        self.assertEqual(tuple(nd.__slots__), ('_mu', '_sigma'))

    def test_instantiation_and_attributes(self):

            

Reported by Pylint.

Instance of 'TestNormalDist' has no 'assertRaises' member
Error

Line: 2536 Column: 14

              
    def test_slots(self):
        nd = self.module.NormalDist(300, 23)
        with self.assertRaises(TypeError):
            vars(nd)
        self.assertEqual(tuple(nd.__slots__), ('_mu', '_sigma'))

    def test_instantiation_and_attributes(self):
        nd = self.module.NormalDist(500, 17)

            

Reported by Pylint.

Instance of 'TestNormalDist' has no 'assertEqual' member
Error

Line: 2538 Column: 9

                      nd = self.module.NormalDist(300, 23)
        with self.assertRaises(TypeError):
            vars(nd)
        self.assertEqual(tuple(nd.__slots__), ('_mu', '_sigma'))

    def test_instantiation_and_attributes(self):
        nd = self.module.NormalDist(500, 17)
        self.assertEqual(nd.mean, 500)
        self.assertEqual(nd.stdev, 17)

            

Reported by Pylint.

Instance of 'TestNormalDist' has no 'module' member
Error

Line: 2541 Column: 14

                      self.assertEqual(tuple(nd.__slots__), ('_mu', '_sigma'))

    def test_instantiation_and_attributes(self):
        nd = self.module.NormalDist(500, 17)
        self.assertEqual(nd.mean, 500)
        self.assertEqual(nd.stdev, 17)
        self.assertEqual(nd.variance, 17**2)

        # default arguments

            

Reported by Pylint.

Lib/test/test_types.py
796 issues
unsupported operand type(s) for |
Error

Line: 631 Column: 26

              class UnionTests(unittest.TestCase):

    def test_or_types_operator(self):
        self.assertEqual(int | str, typing.Union[int, str])
        self.assertNotEqual(int | list, typing.Union[int, str])
        self.assertEqual(str | int, typing.Union[int, str])
        self.assertEqual(int | None, typing.Union[int, None])
        self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 632 Column: 29

              
    def test_or_types_operator(self):
        self.assertEqual(int | str, typing.Union[int, str])
        self.assertNotEqual(int | list, typing.Union[int, str])
        self.assertEqual(str | int, typing.Union[int, str])
        self.assertEqual(int | None, typing.Union[int, None])
        self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)
        self.assertEqual(type(None) | int, None | int)

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 633 Column: 26

                  def test_or_types_operator(self):
        self.assertEqual(int | str, typing.Union[int, str])
        self.assertNotEqual(int | list, typing.Union[int, str])
        self.assertEqual(str | int, typing.Union[int, str])
        self.assertEqual(int | None, typing.Union[int, None])
        self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)
        self.assertEqual(type(None) | int, None | int)
        self.assertEqual(int | str | list, typing.Union[int, str, list])

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 634 Column: 26

                      self.assertEqual(int | str, typing.Union[int, str])
        self.assertNotEqual(int | list, typing.Union[int, str])
        self.assertEqual(str | int, typing.Union[int, str])
        self.assertEqual(int | None, typing.Union[int, None])
        self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)
        self.assertEqual(type(None) | int, None | int)
        self.assertEqual(int | str | list, typing.Union[int, str, list])
        self.assertEqual(int | (str | list), typing.Union[int, str, list])

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 635 Column: 26

                      self.assertNotEqual(int | list, typing.Union[int, str])
        self.assertEqual(str | int, typing.Union[int, str])
        self.assertEqual(int | None, typing.Union[int, None])
        self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)
        self.assertEqual(type(None) | int, None | int)
        self.assertEqual(int | str | list, typing.Union[int, str, list])
        self.assertEqual(int | (str | list), typing.Union[int, str, list])
        self.assertEqual(str | (int | list), typing.Union[int, str, list])

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 636 Column: 44

                      self.assertEqual(str | int, typing.Union[int, str])
        self.assertEqual(int | None, typing.Union[int, None])
        self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)
        self.assertEqual(type(None) | int, None | int)
        self.assertEqual(int | str | list, typing.Union[int, str, list])
        self.assertEqual(int | (str | list), typing.Union[int, str, list])
        self.assertEqual(str | (int | list), typing.Union[int, str, list])
        self.assertEqual(typing.List | typing.Tuple, typing.Union[typing.List, typing.Tuple])

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 636 Column: 26

                      self.assertEqual(str | int, typing.Union[int, str])
        self.assertEqual(int | None, typing.Union[int, None])
        self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)
        self.assertEqual(type(None) | int, None | int)
        self.assertEqual(int | str | list, typing.Union[int, str, list])
        self.assertEqual(int | (str | list), typing.Union[int, str, list])
        self.assertEqual(str | (int | list), typing.Union[int, str, list])
        self.assertEqual(typing.List | typing.Tuple, typing.Union[typing.List, typing.Tuple])

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 637 Column: 26

                      self.assertEqual(int | None, typing.Union[int, None])
        self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)
        self.assertEqual(type(None) | int, None | int)
        self.assertEqual(int | str | list, typing.Union[int, str, list])
        self.assertEqual(int | (str | list), typing.Union[int, str, list])
        self.assertEqual(str | (int | list), typing.Union[int, str, list])
        self.assertEqual(typing.List | typing.Tuple, typing.Union[typing.List, typing.Tuple])
        self.assertEqual(typing.List[int] | typing.Tuple[int], typing.Union[typing.List[int], typing.Tuple[int]])

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 637 Column: 44

                      self.assertEqual(int | None, typing.Union[int, None])
        self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)
        self.assertEqual(type(None) | int, None | int)
        self.assertEqual(int | str | list, typing.Union[int, str, list])
        self.assertEqual(int | (str | list), typing.Union[int, str, list])
        self.assertEqual(str | (int | list), typing.Union[int, str, list])
        self.assertEqual(typing.List | typing.Tuple, typing.Union[typing.List, typing.Tuple])
        self.assertEqual(typing.List[int] | typing.Tuple[int], typing.Union[typing.List[int], typing.Tuple[int]])

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 638 Column: 26

                      self.assertEqual(None | int, typing.Union[int, None])
        self.assertEqual(int | type(None), int | None)
        self.assertEqual(type(None) | int, None | int)
        self.assertEqual(int | str | list, typing.Union[int, str, list])
        self.assertEqual(int | (str | list), typing.Union[int, str, list])
        self.assertEqual(str | (int | list), typing.Union[int, str, list])
        self.assertEqual(typing.List | typing.Tuple, typing.Union[typing.List, typing.Tuple])
        self.assertEqual(typing.List[int] | typing.Tuple[int], typing.Union[typing.List[int], typing.Tuple[int]])
        self.assertEqual(typing.List[int] | None, typing.Union[typing.List[int], None])

            

Reported by Pylint.

Tools/stringbench/stringbench.py
794 issues
Uses of a deprecated module 'optparse'
Error

Line: 11 Column: 1

              import re
import sys
import datetime
import optparse

VERSION = '2.0'

def p(*args):
    sys.stdout.write(' '.join(str(s) for s in args) + '\n')

            

Reported by Pylint.

Unused variable 'x'
Error

Line: 79 Column: 9

              def in_test_quick_match_single_character(STR):
    s1 = STR("A" * 1000)
    s2 = STR("A")
    for x in _RANGE_1000:
        s2 in s1

@bench('"B" in "A"*1000', "no match, single character", 1000)
def in_test_no_match_single_character(STR):
    s1 = STR("A" * 1000)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 80 Column: 9

                  s1 = STR("A" * 1000)
    s2 = STR("A")
    for x in _RANGE_1000:
        s2 in s1

@bench('"B" in "A"*1000', "no match, single character", 1000)
def in_test_no_match_single_character(STR):
    s1 = STR("A" * 1000)
    s2 = STR("B")

            

Reported by Pylint.

Unused variable 'x'
Error

Line: 86 Column: 9

              def in_test_no_match_single_character(STR):
    s1 = STR("A" * 1000)
    s2 = STR("B")
    for x in _RANGE_1000:
        s2 in s1


@bench('"AB" in "AB"*1000', "early match, two characters", 1000)
def in_test_quick_match_two_characters(STR):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 87 Column: 9

                  s1 = STR("A" * 1000)
    s2 = STR("B")
    for x in _RANGE_1000:
        s2 in s1


@bench('"AB" in "AB"*1000', "early match, two characters", 1000)
def in_test_quick_match_two_characters(STR):
    s1 = STR("AB" * 1000)

            

Reported by Pylint.

Unused variable 'x'
Error

Line: 94 Column: 9

              def in_test_quick_match_two_characters(STR):
    s1 = STR("AB" * 1000)
    s2 = STR("AB")
    for x in _RANGE_1000:
        s2 in s1

@bench('"BC" in "AB"*1000', "no match, two characters", 1000)
def in_test_no_match_two_character(STR):
    s1 = STR("AB" * 1000)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 95 Column: 9

                  s1 = STR("AB" * 1000)
    s2 = STR("AB")
    for x in _RANGE_1000:
        s2 in s1

@bench('"BC" in "AB"*1000', "no match, two characters", 1000)
def in_test_no_match_two_character(STR):
    s1 = STR("AB" * 1000)
    s2 = STR("BC")

            

Reported by Pylint.

Unused variable 'x'
Error

Line: 101 Column: 9

              def in_test_no_match_two_character(STR):
    s1 = STR("AB" * 1000)
    s2 = STR("BC")
    for x in _RANGE_1000:
        s2 in s1

@bench('"BC" in ("AB"*300+"C")', "late match, two characters", 1000)
def in_test_slow_match_two_characters(STR):
    s1 = STR("AB" * 300+"C")

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 102 Column: 9

                  s1 = STR("AB" * 1000)
    s2 = STR("BC")
    for x in _RANGE_1000:
        s2 in s1

@bench('"BC" in ("AB"*300+"C")', "late match, two characters", 1000)
def in_test_slow_match_two_characters(STR):
    s1 = STR("AB" * 300+"C")
    s2 = STR("BC")

            

Reported by Pylint.

Unused variable 'x'
Error

Line: 108 Column: 9

              def in_test_slow_match_two_characters(STR):
    s1 = STR("AB" * 300+"C")
    s2 = STR("BC")
    for x in _RANGE_1000:
        s2 in s1

@bench('s="ABC"*33; (s+"E") in ((s+"D")*300+s+"E")',
       "late match, 100 characters", 100)
def in_test_slow_match_100_characters(STR):

            

Reported by Pylint.

Lib/test/test_subprocess.py
785 issues
subprocess call with shell=True identified, security issue.
Security injection

Line: 1460
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

                      ]
        with unittest.mock.patch.object(subprocess.Popen, '_execute_child'):
            for cmd, shell, code, sx in cases:
                p = subprocess.Popen(cmd, shell=shell)
                p.returncode = code
                self.assertEqual(repr(p), sx)

    def test_communicate_epipe_only_stdin(self):
        # Issue 10963: communicate() should hide EPIPE

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 1637
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

                      res = subprocess.run(path, stdout=subprocess.DEVNULL)
        self.assertEqual(res.returncode, 0)
        with self.assertRaises(TypeError):
            subprocess.run(path, stdout=subprocess.DEVNULL, shell=True)

    def test_run_with_bytes_path_and_arguments(self):
        # bpo-31961: test run([bytes_object, b'additional arguments'])
        path = os.fsencode(sys.executable)
        args = [path, '-c', b'import sys; sys.exit(57)']

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 2219
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

                      # Run command through the shell (sequence)
        newenv = os.environ.copy()
        newenv["FRUIT"] = "apple"
        p = subprocess.Popen(["echo $FRUIT"], shell=1,
                             stdout=subprocess.PIPE,
                             env=newenv)
        with p:
            self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")


            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 2638
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              
        # absolute bytes path as a string
        cmd = b"'%s' %s" % (abs_program, " ".join(args).encode("utf-8"))
        exitcode = subprocess.call(cmd, shell=True)
        self.assertEqual(exitcode, 0)

        # bytes program, unicode PATH
        env = os.environ.copy()
        env["PATH"] = path

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 3417
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

                      # Run command through the shell (sequence)
        newenv = os.environ.copy()
        newenv["FRUIT"] = "physalis"
        p = subprocess.Popen(["set"], shell=1,
                             stdout=subprocess.PIPE,
                             env=newenv)
        with p:
            self.assertIn(b"physalis", p.stdout.read())


            

Reported by Bandit.

Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 16 Column: 1

              import errno
import tempfile
import time
import traceback
import types
import selectors
import sysconfig
import select
import shutil

            

Reported by Pylint.

Unexpected keyword argument 'stdout' in function call
Error

Line: 233 Column: 22

                  def test_check_output_stdout_arg(self):
        # check_output() refuses to accept 'stdout' argument
        with self.assertRaises(ValueError) as c:
            output = subprocess.check_output(
                    [sys.executable, "-c", "print('will not be run')"],
                    stdout=sys.stdout)
            self.fail("Expected ValueError when stdout arg supplied.")
        self.assertIn('stdout', c.exception.args[0])


            

Reported by Pylint.

Module 'fcntl' has no 'F_GETPIPE_SZ' member
Error

Line: 698 Column: 57

                      test_pipe_r, test_pipe_w = os.pipe()
        try:
            # Get the default pipesize with F_GETPIPE_SZ
            pipesize_default = fcntl.fcntl(test_pipe_w, fcntl.F_GETPIPE_SZ)
        finally:
            os.close(test_pipe_r)
            os.close(test_pipe_w)
        pipesize = pipesize_default // 2
        if pipesize < 512:  # the POSIX minimum

            

Reported by Pylint.

Unexpected keyword argument 'pipesize' in constructor call
Error

Line: 706 Column: 13

                      if pipesize < 512:  # the POSIX minimum
            raise unittest.SkitTest(
                'default pipesize too small to perform test.')
        p = subprocess.Popen(
            [sys.executable, "-c",
             'import sys; sys.stdin.read(); sys.stdout.write("out"); '
             'sys.stderr.write("error!")'],
            stdin=subprocess.PIPE, stdout=subprocess.PIPE,
            stderr=subprocess.PIPE, pipesize=pipesize)

            

Reported by Pylint.

Module 'fcntl' has no 'F_GETPIPE_SZ' member
Error

Line: 715 Column: 48

                      try:
            for fifo in [p.stdin, p.stdout, p.stderr]:
                self.assertEqual(
                    fcntl.fcntl(fifo.fileno(), fcntl.F_GETPIPE_SZ),
                    pipesize)
            # Windows pipe size can be acquired via GetNamedPipeInfoFunction
            # https://docs.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-getnamedpipeinfo
            # However, this function is not yet in _winapi.
            p.stdin.write(b"pear")

            

Reported by Pylint.

Lib/test/test_sys_settrace.py
781 issues
Undefined variable 'bla'
Error

Line: 138 Column: 9

              def no_pop_blocks():
    y = 1
    while not y:
        bla
    x = 1

no_pop_blocks.events = [(0, 'call'),
                        (1, 'line'),
                        (2, 'line'),

            

Reported by Pylint.

Undefined variable 'D'
Error

Line: 903 Column: 28

                          if A:
                if B:
                    if C:
                        if D:
                            return False
                else:
                    return False
            elif E and F:
                return True

            

Reported by Pylint.

Undefined variable 'E'
Error

Line: 907 Column: 18

                                          return False
                else:
                    return False
            elif E and F:
                return True

        A = B = True
        C = False


            

Reported by Pylint.

Undefined variable 'F'
Error

Line: 907 Column: 24

                                          return False
                else:
                    return False
            elif E and F:
                return True

        A = B = True
        C = False


            

Reported by Pylint.

Method has no argument
Error

Line: 947 Column: 13

                      class C:
            def __enter__(self):
                return self
            def __exit__(*args):
                pass

        def func():
            with C():
                if False:

            

Reported by Pylint.

Undefined variable 'X'
Error

Line: 975 Column: 17

                              if False:
                    pass
            except Exception:
                X

        self.run_and_compare(func,
            [(0, 'call'),
             (1, 'line'),
             (2, 'line'),

            

Reported by Pylint.

Method has no argument
Error

Line: 1041 Column: 13

                      class C:
            def __enter__(self):
                return self
            def __exit__(*args):
                pass

        def func_break():
            for i in (1,2):
                with C():

            

Reported by Pylint.

Instance of 'int' has no 'no_such_attr' member
Error

Line: 1242 Column: 13

                      def f():
            x = 0
            # this should raise an error
            x.no_such_attr
        def g(frame, event, arg):
            if (event == 'exception'):
                type, exception, trace = arg
                self.assertIsInstance(exception, Exception)
            return g

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 1363 Column: 5

                      asyncio.set_event_loop_policy(None)
        self.compare_jump_output(expected, output)

    def jump_test(jumpFrom, jumpTo, expected, error=None, event='line'):
        """Decorator that creates a test that makes a jump
        from one place to another in the following code.
        """
        def decorator(func):
            @wraps(func)

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 1375 Column: 5

                          return test
        return decorator

    def async_jump_test(jumpFrom, jumpTo, expected, error=None, event='line'):
        """Decorator that creates a test that makes a jump
        from one place to another in the following asynchronous code.
        """
        def decorator(func):
            @wraps(func)

            

Reported by Pylint.

Lib/test/test_zipfile.py
775 issues
Instance of 'AbstractTestsWithSourceFile' has no 'assertEqual' member
Error

Line: 76 Column: 13

              
        # Read the ZIP archive
        with zipfile.ZipFile(f, "r", compression) as zipfp:
            self.assertEqual(zipfp.read(TESTFN), self.data)
            self.assertEqual(zipfp.read("another.name"), self.data)
            self.assertEqual(zipfp.read("strfile"), self.data)

            # Print the ZIP directory
            fp = io.StringIO()

            

Reported by Pylint.

Instance of 'AbstractTestsWithSourceFile' has no 'assertEqual' member
Error

Line: 77 Column: 13

                      # Read the ZIP archive
        with zipfile.ZipFile(f, "r", compression) as zipfp:
            self.assertEqual(zipfp.read(TESTFN), self.data)
            self.assertEqual(zipfp.read("another.name"), self.data)
            self.assertEqual(zipfp.read("strfile"), self.data)

            # Print the ZIP directory
            fp = io.StringIO()
            zipfp.printdir(file=fp)

            

Reported by Pylint.

Instance of 'AbstractTestsWithSourceFile' has no 'assertEqual' member
Error

Line: 78 Column: 13

                      with zipfile.ZipFile(f, "r", compression) as zipfp:
            self.assertEqual(zipfp.read(TESTFN), self.data)
            self.assertEqual(zipfp.read("another.name"), self.data)
            self.assertEqual(zipfp.read("strfile"), self.data)

            # Print the ZIP directory
            fp = io.StringIO()
            zipfp.printdir(file=fp)
            directory = fp.getvalue()

            

Reported by Pylint.

Instance of 'AbstractTestsWithSourceFile' has no 'assertEqual' member
Error

Line: 85 Column: 13

                          zipfp.printdir(file=fp)
            directory = fp.getvalue()
            lines = directory.splitlines()
            self.assertEqual(len(lines), 5) # Number of files + header

            self.assertIn('File Name', lines[0])
            self.assertIn('Modified', lines[0])
            self.assertIn('Size', lines[0])


            

Reported by Pylint.

Instance of 'AbstractTestsWithSourceFile' has no 'assertIn' member
Error

Line: 87 Column: 13

                          lines = directory.splitlines()
            self.assertEqual(len(lines), 5) # Number of files + header

            self.assertIn('File Name', lines[0])
            self.assertIn('Modified', lines[0])
            self.assertIn('Size', lines[0])

            fn, date, time_, size = lines[1].split()
            self.assertEqual(fn, 'another.name')

            

Reported by Pylint.

Instance of 'AbstractTestsWithSourceFile' has no 'assertIn' member
Error

Line: 88 Column: 13

                          self.assertEqual(len(lines), 5) # Number of files + header

            self.assertIn('File Name', lines[0])
            self.assertIn('Modified', lines[0])
            self.assertIn('Size', lines[0])

            fn, date, time_, size = lines[1].split()
            self.assertEqual(fn, 'another.name')
            self.assertTrue(time.strptime(date, '%Y-%m-%d'))

            

Reported by Pylint.

Instance of 'AbstractTestsWithSourceFile' has no 'assertIn' member
Error

Line: 89 Column: 13

              
            self.assertIn('File Name', lines[0])
            self.assertIn('Modified', lines[0])
            self.assertIn('Size', lines[0])

            fn, date, time_, size = lines[1].split()
            self.assertEqual(fn, 'another.name')
            self.assertTrue(time.strptime(date, '%Y-%m-%d'))
            self.assertTrue(time.strptime(time_, '%H:%M:%S'))

            

Reported by Pylint.

Instance of 'AbstractTestsWithSourceFile' has no 'assertEqual' member
Error

Line: 92 Column: 13

                          self.assertIn('Size', lines[0])

            fn, date, time_, size = lines[1].split()
            self.assertEqual(fn, 'another.name')
            self.assertTrue(time.strptime(date, '%Y-%m-%d'))
            self.assertTrue(time.strptime(time_, '%H:%M:%S'))
            self.assertEqual(size, str(len(self.data)))

            # Check the namelist

            

Reported by Pylint.

Instance of 'AbstractTestsWithSourceFile' has no 'assertTrue' member
Error

Line: 93 Column: 13

              
            fn, date, time_, size = lines[1].split()
            self.assertEqual(fn, 'another.name')
            self.assertTrue(time.strptime(date, '%Y-%m-%d'))
            self.assertTrue(time.strptime(time_, '%H:%M:%S'))
            self.assertEqual(size, str(len(self.data)))

            # Check the namelist
            names = zipfp.namelist()

            

Reported by Pylint.

Instance of 'AbstractTestsWithSourceFile' has no 'assertTrue' member
Error

Line: 94 Column: 13

                          fn, date, time_, size = lines[1].split()
            self.assertEqual(fn, 'another.name')
            self.assertTrue(time.strptime(date, '%Y-%m-%d'))
            self.assertTrue(time.strptime(time_, '%H:%M:%S'))
            self.assertEqual(size, str(len(self.data)))

            # Check the namelist
            names = zipfp.namelist()
            self.assertEqual(len(names), 4)

            

Reported by Pylint.

Lib/test/test_weakref.py
713 issues
__iter__ returns non-iterator
Error

Line: 401 Column: 13

                      obj = None

        class MyObj:
            def __iter__(self):
                nonlocal obj
                del obj
                return NotImplemented

        obj = MyObj()

            

Reported by Pylint.

class already defined line 455
Error

Line: 463 Column: 9

                      with self.assertRaises(TypeError):
            hash(weakref.proxy(obj))

        class MyObj:
            __hash__ = None

        obj = MyObj()
        with self.assertRaises(TypeError):
            hash(weakref.proxy(obj))

            

Reported by Pylint.

Argument 'self' passed by position and keyword in constructor call
Error

Line: 1570 Column: 17

                      # special keyword arguments
        o = Object(3)
        for kw in 'self', 'dict', 'other', 'iterable':
            d = weakref.WeakValueDictionary(**{kw: o})
            self.assertEqual(list(d.keys()), [kw])
            self.assertEqual(d[kw], o)

    def make_weak_valued_dict(self):
        dict = weakref.WeakValueDictionary()

            

Reported by Pylint.

Argument 'self' passed by position and keyword in method call
Error

Line: 1664 Column: 13

                      o = Object(3)
        for kw in 'self', 'dict', 'other', 'iterable':
            d = weakref.WeakValueDictionary()
            d.update(**{kw: o})
            self.assertEqual(list(d.keys()), [kw])
            self.assertEqual(d[kw], o)

    def test_weak_valued_union_operators(self):
        a = C()

            

Reported by Pylint.

Argument 'func' passed by position and keyword in constructor call
Error

Line: 2025 Column: 13

                      a = self.A()

        res = []
        f = weakref.finalize(a, fin, 1, 2, func=3, obj=4)
        self.assertEqual(f.peek(), (a, fin, (1, 2), {'func': 3, 'obj': 4}))
        f()
        self.assertEqual(res, [((1, 2), {'func': 3, 'obj': 4})])

        with self.assertRaises(TypeError):

            

Reported by Pylint.

Argument 'obj' passed by position and keyword in constructor call
Error

Line: 2025 Column: 13

                      a = self.A()

        res = []
        f = weakref.finalize(a, fin, 1, 2, func=3, obj=4)
        self.assertEqual(f.peek(), (a, fin, (1, 2), {'func': 3, 'obj': 4}))
        f()
        self.assertEqual(res, [((1, 2), {'func': 3, 'obj': 4})])

        with self.assertRaises(TypeError):

            

Reported by Pylint.

Unused argument 'ref'
Error

Line: 74 Column: 24

                  def setUp(self):
        self.cbcalled = 0

    def callback(self, ref):
        self.cbcalled += 1


@contextlib.contextmanager
def collect_in_thread(period=0.0001):

            

Reported by Pylint.

Unused argument 'object'
Error

Line: 154 Column: 22

                      # have one invocation of _weakref.c:cleanup_helper() active
        # for a particular object at a time.
        #
        def callback(object, self=self):
            self.ref()
        c = C()
        self.ref = weakref.ref(c, callback)
        ref1 = weakref.ref(c, callback)
        del c

            

Reported by Pylint.

Redefining built-in 'object'
Error

Line: 154 Column: 22

                      # have one invocation of _weakref.c:cleanup_helper() active
        # for a particular object at a time.
        #
        def callback(object, self=self):
            self.ref()
        c = C()
        self.ref = weakref.ref(c, callback)
        ref1 = weakref.ref(c, callback)
        del c

            

Reported by Pylint.

Attribute 'ref' defined outside __init__
Error

Line: 157 Column: 9

                      def callback(object, self=self):
            self.ref()
        c = C()
        self.ref = weakref.ref(c, callback)
        ref1 = weakref.ref(c, callback)
        del c

    def test_constructor_kwargs(self):
        c = C()

            

Reported by Pylint.