Skip to content
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

Add missing type annotations to the primitives.pyi fixture #15871

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Aug 14, 2023

This fixes some weird test failures I was seeing locally when trying to run just the tests in check-enum.test (invoked via pytest mypy/test/testcheck.py::TypeCheckSuite::check-enum.test):

> pytest mypy/test/testcheck.py::TypeCheckSuite::check-enum.test
=================================================================== test session starts ===================================================================
platform win32 -- Python 3.11.2, pytest-7.4.0, pluggy-1.2.0
rootdir: C:\Users\alexw\coding\mypy
configfile: pyproject.toml
plugins: cov-4.1.0, xdist-3.3.1
4 workers [99 items]
............................................................F...F.......F..........................                                                  [100%]
======================================================================== FAILURES =========================================================================
________________________________________________________ testEnumReachabilityWithChainingDisjoint _________________________________________________________
[gw2] win32 -- Python 3.11.2 C:\Users\alexw\coding\mypy\venv\Scripts\python.exe
data: C:\Users\alexw\coding\mypy\test-data\unit\check-enum.test:1174:
Failed: Unexpected type checker output (C:\Users\alexw\coding\mypy\test-data\unit\check-enum.test, line 1174)
------------------------------------------------------------------ Captured stderr call -------------------------------------------------------------------
Expected:
  main:16: note: Revealed type is "Literal[__main__.Foo.A]" (diff)
  main:17: note: Revealed type is "Literal[__main__.Foo.B]" (diff)
  main:21: note: Revealed type is "__main__.Foo" (diff)
  main:22: note: Revealed type is "__main__.Foo" (diff)
  ...
Actual:
  tmp/builtins.pyi:15: error: Function is missing a type annotation for one or more arguments (diff)
  tmp/builtins.pyi:33: error: Function is missing a type annotation for one or more arguments (diff)
  main:16: note: Revealed type is "Literal[__main__.Foo.A]" (diff)
  main:17: note: Revealed type is "Literal[__main__.Foo.B]" (diff)
  main:21: note: Revealed type is "__main__.Foo" (diff)
  main:22: note: Revealed type is "__main__.Foo" (diff)
  ...

Alignment of first line difference:
  E: main:16: note: Revealed type is "Literal[__main__.Foo.A]"...
  A: tmp/builtins.pyi:15: error: Function is missing a type annotation for on...
     ^
_____________________________________________________ testEnumReachabilityWithChainingDirectConflict ______________________________________________________
[gw2] win32 -- Python 3.11.2 C:\Users\alexw\coding\mypy\venv\Scripts\python.exe
data: C:\Users\alexw\coding\mypy\test-data\unit\check-enum.test:1215:
Failed: Unexpected type checker output (C:\Users\alexw\coding\mypy\test-data\unit\check-enum.test, line 1215)
------------------------------------------------------------------ Captured stderr call -------------------------------------------------------------------
Expected:
  main:12: error: Statement is unreachable      (diff)
  main:14: note: Revealed type is "__main__.Foo" (diff)
  main:15: note: Revealed type is "__main__.Foo" (diff)
  main:20: error: Statement is unreachable      (diff)
  ...
Actual:
  tmp/builtins.pyi:15: error: Function is missing a type annotation for one or more arguments (diff)
  tmp/builtins.pyi:33: error: Function is missing a type annotation for one or more arguments (diff)
  main:12: error: Statement is unreachable      (diff)
  main:14: note: Revealed type is "__main__.Foo" (diff)
  main:15: note: Revealed type is "__main__.Foo" (diff)
  main:20: error: Statement is unreachable      (diff)
  ...

Alignment of first line difference:
  E: main:12: error: Statement is unreachable...
  A: tmp/builtins.pyi:15: error: Function is missing a type annotation for on...
     ^
______________________________________________________ testEnumReachabilityWithChainingBigDisjoints _______________________________________________________
[gw2] win32 -- Python 3.11.2 C:\Users\alexw\coding\mypy\venv\Scripts\python.exe
data: C:\Users\alexw\coding\mypy\test-data\unit\check-enum.test:1250:
Failed: Unexpected type checker output (C:\Users\alexw\coding\mypy\test-data\unit\check-enum.test, line 1250)
------------------------------------------------------------------ Captured stderr call -------------------------------------------------------------------
Expected:
  main:20: note: Revealed type is "Literal[__main__.Foo.A]" (diff)
  main:21: note: Revealed type is "Literal[__main__.Foo.A]" (diff)
  main:22: note: Revealed type is "Literal[__main__.Foo.A]" (diff)
  main:24: note: Revealed type is "Literal[__main__.Foo.B]" (diff)
  ...
Actual:
  tmp/builtins.pyi:15: error: Function is missing a type annotation for one or more arguments (diff)
  tmp/builtins.pyi:33: error: Function is missing a type annotation for one or more arguments (diff)
  main:20: note: Revealed type is "Literal[__main__.Foo.A]" (diff)
  main:21: note: Revealed type is "Literal[__main__.Foo.A]" (diff)
  main:22: note: Revealed type is "Literal[__main__.Foo.A]" (diff)
  main:24: note: Revealed type is "Literal[__main__.Foo.B]" (diff)
  ...

Alignment of first line difference:
  E: main:20: note: Revealed type is "Literal[__main__.Foo.A]"...
  A: tmp/builtins.pyi:15: error: Function is missing a type annotation for on...
     ^
================================================================= short test summary info =================================================================
FAILED mypy/test/testcheck.py::TypeCheckSuite::check-enum.test::testEnumReachabilityWithChainingDisjoint
FAILED mypy/test/testcheck.py::TypeCheckSuite::check-enum.test::testEnumReachabilityWithChainingDirectConflict
FAILED mypy/test/testcheck.py::TypeCheckSuite::check-enum.test::testEnumReachabilityWithChainingBigDisjoints
============================================================== 3 failed, 96 passed in 3.85s ===============================================================

I've no idea why this was happening for me locally but not in CI (possibly because I'm invoking the test in a slightly different way??). But, this fixes it -- and it seems like the correct thing to do anyway.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest mypy/test/testcheck.py::TypeCheckSuite::check-enum.test works fine for me, any chance you have a stray mypy config file in the repo or in one of the global locations?

@hauntsaninja hauntsaninja merged commit a1fcad5 into python:master Aug 14, 2023
@AlexWaygood AlexWaygood deleted the fix-enum-fixtures branch August 14, 2023 20:58
@AlexWaygood
Copy link
Member Author

any chance you have a stray mypy config file in the repo or in one of the global locations?

Lol, yep, that was it. I added loads of random mypy config files everywhere I could think of a few weeks ago to investigate whether python/typeshed#2852 could be closed. Turns out I forgot to delete them again 🤦

Still at least it caught a few missing type annotations in fixtures, I guess? 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants