Skip to content

unittest assertAlmostEqual called with (int, float) now fails typecheck #8136

Closed
@0xjc

Description

@0xjc
import unittest


class MyTestCase(unittest.TestCase):
    def test_foo(self):
        self.assertAlmostEqual(1, 2.0)

results in error:

pyright 1.1.255
/tmp/test_pyright/aa.py
  /tmp/test_pyright/aa.py:6:35 - error: Argument of type "float" cannot be assigned to parameter "second" of type "_T@assertAlmostEqual" in function "assertAlmostEqual"
    Type "float" cannot be assigned to type "int"
      "float" is incompatible with "int" (reportGeneralTypeIssues)

It's related to this commit: 5add91d

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions