示例#1
0
 def test_invalid_types(self) -> None:
     mpc = self.get_mypychecker('invalid_types.py')
     errors = list(mpc.run())
     self.assertEqual(
         errors,
         self.errors(
             T484(5, 0, vars=('Missing return statement', )),
             T484(
                 10,
                 4,
                 vars=
                 ('Incompatible return value type (got "int", expected "str")',
                  ),
             ),
             T484(
                 10,
                 11,
                 vars=(
                     'Unsupported operand types for + ("int" and "str")', ),
             ), T400(13, 0, vars=("unused 'type: ignore' comment", ))),
     )
示例#2
0
 def test_clash(self) -> None:
     mpc = self.get_mypychecker('clash/london_calling.py')
     errors = list(mpc.run())
     self.assertEqual(
         errors,
         self.errors(
             T484(
                 6,
                 4,
                 vars=('Incompatible return value type (got "UserDict", '
                       'expected Counter[Any])', ),
             ),
             T484(
                 6,
                 11,
                 vars=("Cannot instantiate abstract class 'UserDict' with "
                       "abstract attributes '__delitem__', '__getitem__', "
                       "'__iter__', '__len__' and '__setitem__'", ),
             ),
         ),
     )
示例#3
0
 def test_clash(self) -> None:
     """We set MYPYPATH to prioritize typeshed over local modules."""
     mpc = self.get_mypychecker('clash/london_calling.py')
     errors = list(mpc.run())
     self.assertEqual(
         errors,
         self.errors(
             T484(
                 6,
                 4,
                 vars=(
                     'Incompatible return value type '
                     '(got "UserDict[<nothing>, <nothing>]", '
                     'expected "Counter[Any]")',
                 ),
             ),
         ),
     )