rustworkx icon indicating copy to clipboard operation
rustworkx copied to clipboard

Specify `Any` for `PyGraph` and `PyDiGraph` type annotations for pyright compatibility

Open IvanIsCoding opened this issue 1 year ago • 1 comments

Closes #1242

This is a pretty annoying PR but it avoids pyright from infering the types as Unknown. Although we will only keep mypy in the CI, pyright is the base for pylance which ships with VSCode. And we got VSCode issues in the past (#832), so I think it's worth supporting.

IvanIsCoding avatar Jul 11 '24 03:07 IvanIsCoding

Pull Request Test Coverage Report for Build 12661348679

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.825%

Totals Coverage Status
Change from base Build 12653809774: 0.0%
Covered Lines: 18360
Relevant Lines: 19160

💛 - Coveralls

coveralls avatar Jul 11 '24 03:07 coveralls

Now that we are doing a major release, I might use the suggestion from https://github.com/Qiskit/rustworkx/issues/1242#issuecomment-2231841772 to fix it in a more proper way using TypeVar

IvanIsCoding avatar Nov 16 '24 18:11 IvanIsCoding

I tested with pyright, I don't want to add it to the Nox file as of now because of the Node.js aspect but it worked. Now we get:

0 errors, 0 warnings, 0 informations 

Instead of the original error. If I use the wheel from PyPI it fails with the same error message from the Issue so I am confident the fix work. It also has a much smaller diff than the original solution so that is a win

IvanIsCoding avatar Nov 17 '24 14:11 IvanIsCoding