Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
0xjc opened this issue Jun 22, 2022 · 1 comment · Fixed by #8137
Closed

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

0xjc opened this issue Jun 22, 2022 · 1 comment · Fixed by #8137
Assignees
Labels
stubs: false positive Type checkers report false errors

Comments

@0xjc
Copy link

0xjc commented Jun 22, 2022

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

@AlexWaygood AlexWaygood self-assigned this Jun 22, 2022
@AlexWaygood
Copy link
Member

Thanks, I can reproduce on mypy as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants