python / python/mypy

Certain tests can't deal with symlinks on Windows

オープン
#19,956 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

I'm running the tests in a directory that I got to using a symlink. It is now complaining that the output isn't right on some tests, since apparently the absolute path is reported instead of the symlinky one it expects. I'm running from a venv, and also on windows 10. (The symlink is a symlinkd, which I mention because windows sadly has like 4 different types of symlink. But I doubt it's relevant.) I tried to replicate this on WSL2 (Ubuntu) but couldn't.

Here are the test failures of uv run runtests.py pytest-fast:

================================================================================================================= FAILURES =================================================================================================================
_______________________________________________________________________________________________________ testNamedTupleAdditionalArgs _______________________________________________________________________________________________________
[gw3] win32 -- Python 3.9.22 C:\Users\wyatt\files\tmp\mypy\.venv\Scripts\python.exe
data: C:\Users\wyatt\files\tmp\mypy\test-data\unit\check-namedtuple.test:118:
Failed: Unexpected type checker output (C:\Users\wyatt\files\tmp\mypy\test-data\unit\check-namedtuple.test, line 118)
----------------------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------------------
Expected:
  main:4: error: Boolean literal expected as the "rename" argument to namedtuple()
  main:5: error: Boolean literal expected as the "rename" argument to namedtuple()
  main:5: error: Argument "rename" to "namedtuple" has incompatible type "str"; expected "int"
  main:6: error: Unexpected keyword argument "unrecognized_arg" for "namedtuple"
  C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/collections.pyi:3: note: "namedtuple" defined here (diff)
  main:7: error: Too many positional arguments for "namedtuple"
Actual:
  main:4: error: Boolean literal expected as the "rename" argument to namedtuple()
  main:5: error: Boolean literal expected as the "rename" argument to namedtuple()
  main:5: error: Argument "rename" to "namedtuple" has incompatible type "str"; expected "int"
  main:6: error: Unexpected keyword argument "unrecognized_arg" for "namedtuple"
  C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/collections.pyi:3: note: "namedtuple" defined here (diff)
  main:7: error: Too many positional arguments for "namedtuple"

Alignment of first line difference:
  E: C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/collections.pyi:3:...
  A: C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/collection...
                                  ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)
______________________________________________________________________________________________ testImportBringsAnotherFileWithBlockingError1 _______________________________________________________________________________________________
[gw3] win32 -- Python 3.9.22 C:\Users\wyatt\files\tmp\mypy\.venv\Scripts\python.exe
data: C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test:400:
Failed: Invalid output (C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test, line 400)
----------------------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------------------
Expected:
  ==
  C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax (diff)
  ==
  a.py:1: error: "int" not callable
Actual:
  ==
  C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax (diff)
  ==
  a.py:1: error: "int" not callable

Alignment of first line difference:
  E: C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker.pyi:2: err...
  A: C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker.py...
                                  ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)
_______________________________________________________________________________________ testImportBringsAnotherFileWithSemanticAnalysisBlockingError _______________________________________________________________________________________
[gw3] win32 -- Python 3.9.22 C:\Users\wyatt\files\tmp\mypy\.venv\Scripts\python.exe
data: C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test:420:
Failed: Invalid output (C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test, line 420)
----------------------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------------------
Expected:
  ==
  C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker2.pyi:2: error: "continue" outside loop (diff)
  ==
  a.py:1: error: "int" not callable
Actual:
  ==
  C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker2.pyi:2: error: "continue" outside loop (diff)
  ==
  a.py:1: error: "int" not callable

Alignment of first line difference:
  E: C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker2.pyi:2: er...
  A: C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker2.p...
                                  ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)
_________________________________________________________________________________________ testFixingBlockingErrorBringsInAnotherModuleWithBlocker __________________________________________________________________________________________
[gw3] win32 -- Python 3.9.22 C:\Users\wyatt\files\tmp\mypy\.venv\Scripts\python.exe
data: C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test:474:
Failed: Invalid output (C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test, line 474)
----------------------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------------------
Expected:
  ==
  a.py:1: error: Invalid syntax
  ==
  C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax (diff)
  ==
  a.py:2: error: "int" not callable
Actual:
  ==
  a.py:1: error: Invalid syntax
  ==
  C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax (diff)
  ==
  a.py:2: error: "int" not callable

Alignment of first line difference:
  E: C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker.pyi:2: err...
  A: C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker.py...
                                  ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)
________________________________________________________________________________________________ testAddFileWhichImportsLibModuleWithErrors ________________________________________________________________________________________________
[gw3] win32 -- Python 3.9.22 C:\Users\wyatt\files\tmp\mypy\.venv\Scripts\python.exe
data: C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-modules.test:754:
Failed: Invalid output (C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-modules.test, line 754)
----------------------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------------------
Expected:
  main:2: error: Cannot find implementation or library stub for module named "a"
  main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
  ==
  a.py:3: error: Name "z" is not defined
  C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/broken.pyi:2: error: Name "y" is not defined (diff)
Actual:
  main:2: error: Cannot find implementation or library stub for module named "a"
  main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
  ==
  a.py:3: error: Name "z" is not defined
  C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/broken.pyi:2: error: Name "y" is not defined (diff)

Alignment of first line difference:
  E: C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/broken.pyi:2: erro...
  A: C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/broken.pyi...
                                  ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)
___________________________________________________________________________________________ testImportBringsAnotherFileWithBlockingError1_cached ___________________________________________________________________________________________
[gw2] win32 -- Python 3.9.22 C:\Users\wyatt\files\tmp\mypy\.venv\Scripts\python.exe
data: C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test:400:
Failed: Invalid output (C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test, line 400)
----------------------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------------------
Expected:
  ==
  C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax (diff)
  ==
  a.py:1: error: "int" not callable
Actual:
  ==
  C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax (diff)
  ==
  a.py:1: error: "int" not callable

Alignment of first line difference:
  E: C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker.pyi:2: err...
  A: C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker.py...
                                  ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)
___________________________________________________________________________________ testImportBringsAnotherFileWithSemanticAnalysisBlockingError_cached ____________________________________________________________________________________
[gw2] win32 -- Python 3.9.22 C:\Users\wyatt\files\tmp\mypy\.venv\Scripts\python.exe
data: C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test:420:
Failed: Invalid output (C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test, line 420)
----------------------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------------------
Expected:
  ==
  C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker2.pyi:2: error: "continue" outside loop (diff)
  ==
  a.py:1: error: "int" not callable
Actual:
  ==
  C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker2.pyi:2: error: "continue" outside loop (diff)
  ==
  a.py:1: error: "int" not callable

Alignment of first line difference:
  E: C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker2.pyi:2: er...
  A: C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker2.p...
                                  ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)
______________________________________________________________________________________ testFixingBlockingErrorBringsInAnotherModuleWithBlocker_cached ______________________________________________________________________________________
[gw2] win32 -- Python 3.9.22 C:\Users\wyatt\files\tmp\mypy\.venv\Scripts\python.exe
data: C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test:474:
Failed: Invalid output (C:\Users\wyatt\files\tmp\mypy\test-data\unit\fine-grained-blockers.test, line 474)
----------------------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------------------
Expected:
  ==
  a.py:1: error: Invalid syntax
  ==
  C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax (diff)
  ==
  a.py:2: error: "int" not callable
Actual:
  ==
  a.py:1: error: Invalid syntax
  ==
  C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax (diff)
  ==
  a.py:2: error: "int" not callable

Alignment of first line difference:
  E: C:/Users/wyatt/files/tmp/mypy/test-data/unit/lib-stub/blocker.pyi:2: err...
  A: C:/Users/wyatt/files/tmp/mypy_symlink/test-data/unit/lib-stub/blocker.py...
                                  ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)
========================================================================================================= short test summary info ==========================================================================================================
FAILED mypy/test/testcheck.py::TypeCheckSuite::check-namedtuple.test::testNamedTupleAdditionalArgs
FAILED mypy/test/testfinegrained.py::FineGrainedSuite::fine-grained-blockers.test::testImportBringsAnotherFileWithBlockingError1
FAILED mypy/test/testfinegrained.py::FineGrainedSuite::fine-grained-blockers.test::testImportBringsAnotherFileWithSemanticAnalysisBlockingError
FAILED mypy/test/testfinegrained.py::FineGrainedSuite::fine-grained-blockers.test::testFixingBlockingErrorBringsInAnotherModuleWithBlocker
FAILED mypy/test/testfinegrained.py::FineGrainedSuite::fine-grained-modules.test::testAddFileWhichImportsLibModuleWithErrors
FAILED mypy/test/testfinegrainedcache.py::FineGrainedCacheSuite::fine-grained-blockers.test::testImportBringsAnotherFileWithBlockingError1_cached
FAILED mypy/test/testfinegrainedcache.py::FineGrainedCacheSuite::fine-grained-blockers.test::testImportBringsAnotherFileWithSemanticAnalysisBlockingError_cached
FAILED mypy/test/testfinegrainedcache.py::FineGrainedCacheSuite::fine-grained-blockers.test::testFixingBlockingErrorBringsInAnotherModuleWithBlocker_cached
8 failed, 11353 passed, 301 skipped, 8 xfailed in 418.89s (0:06:58)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

runtests.py pytest-fast と、test-data/unit/check-namedtuple.testfine-grained-blockers.testfine-grained-modules.test で失敗しているケースから始めます。Windows のシンボリックリンク経由でテストを実行したときにパスがどのように表現されるかを調査し、その後、期待されるパスと実際のパスが一致した状態で、一覧にあるテストが通ることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
testing
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。