Skip to content

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

Closed

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

Activity

  1. self-assigned this
    on Jun 22, 2022
  2. AlexWaygood commented on Jun 22, 2022

    @AlexWaygood
    Member

    Thanks, I can reproduce on mypy as well.

  3. added
    stubs: false positive
    on Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

stubs: false positive

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions