Type checker errors #4

Closed
opened 2021-03-31 19:01:47 +00:00 by adsharma · 8 comments
adsharma commented 2021-03-31 19:01:47 +00:00 (Migrated from github.com)
https://paste.ubuntu.com/p/nYFVm6ZYCx/ I used pyright
mwhittaker commented 2021-03-31 19:38:46 +00:00 (Migrated from github.com)

Thanks so much for doing this @adsharma! I've been using mypy for type checking, and I've never heard of pyright before, so I'm happy to learn about something new! It looks like the majority of the errors reported by pyright involve it not understanding certain operators that have been overloaded? I'm not sure if pyright is misconfigured or maybe I'm misunderstanding something. I did find a couple of bugs in the report though, which I fixed in 457f5d1703.

Thanks so much for doing this @adsharma! I've been using mypy for type checking, and I've never heard of pyright before, so I'm happy to learn about something new! It looks like the majority of the errors reported by pyright involve it not understanding certain operators that have been overloaded? I'm not sure if pyright is misconfigured or maybe I'm misunderstanding something. I did find a couple of bugs in the report though, which I fixed in 457f5d17032fb4d6bda7989e651aad450c4a66a6.
adsharma commented 2021-03-31 20:41:06 +00:00 (Migrated from github.com)

Thanks. The reason why I use pyright is that it's fast enough to be integrated into an IDE (vscode) and can do incremental type checking. There is another type checker https://pyre-check.org/, which is written in Ocaml and I've used more of it in the past than pyright, but pyre isn't as well integrated into vscode.

Let me see if I can filter out the noise from the report so we can see the actual issues it may be reporting (and that mypy may have missed).

Thanks. The reason why I use pyright is that it's fast enough to be integrated into an IDE (vscode) and can do incremental type checking. There is another type checker https://pyre-check.org/, which is written in Ocaml and I've used more of it in the past than pyright, but pyre isn't as well integrated into vscode. Let me see if I can filter out the noise from the report so we can see the actual issues it may be reporting (and that mypy may have missed).
adsharma commented 2021-03-31 21:23:31 +00:00 (Migrated from github.com)

I suspect the problem is in correct usage of variance in generics:

https://mypy.readthedocs.io/en/latest/generics.html#variance-of-generics

I don't know if this is a pyright limitation or expr.py needs a fix.

https://paste.ubuntu.com/p/2sGVcdHYCk/

silences many errors (335 -> 92), but shouldn't really be necessary.

I also tried:

T = TypeVar('T', covariance=True)

Probably best to distill it down to a minimal example and file an issue against pyright for further discussion.

I suspect the problem is in correct usage of variance in generics: https://mypy.readthedocs.io/en/latest/generics.html#variance-of-generics I don't know if this is a pyright limitation or expr.py needs a fix. https://paste.ubuntu.com/p/2sGVcdHYCk/ silences many errors (335 -> 92), but shouldn't really be necessary. I also tried: ``` T = TypeVar('T', covariance=True) ``` Probably best to distill it down to a minimal example and file an issue against pyright for further discussion.
adsharma commented 2021-04-01 20:33:21 +00:00 (Migrated from github.com)

Turns out to be a bug in pyright, to be fixed in the next version. We should rerun it once it's fixed for a less noisy output and see if it reports anything else significant.

Turns out to be a bug in pyright, to be fixed in the next version. We should rerun it once it's fixed for a less noisy output and see if it reports anything else significant.
mwhittaker commented 2021-04-05 16:20:56 +00:00 (Migrated from github.com)

Wow, thanks so so much for looking into this. Yes, let's definitely rerun after the bug is fixed.

Wow, thanks so so much for looking into this. Yes, let's definitely rerun after the bug is fixed.
adsharma commented 2021-04-05 16:35:59 +00:00 (Migrated from github.com)

The pyright bug is fixed in 1.1.128. Here's what it looks like:

$ pyright 2>&1 | pastebinit
https://paste.ubuntu.com/p/vYjnJRZrmJ/
$ mypy . 2>&1 | pastebinit
https://paste.ubuntu.com/p/vxSD5G3HTq/

Argument 2 to "sum" has incompatible type "timedelta"; expected "float"

This seems to be a mypy bug to me. pyright doesn't have the issue.
Also, # type: ignore is another way to silence type checker errors at a line level vs function level.
pyright doesn't understand no_type_check.

The pyright bug is fixed in 1.1.128. Here's what it looks like: $ pyright 2>&1 | pastebinit https://paste.ubuntu.com/p/vYjnJRZrmJ/ $ mypy . 2>&1 | pastebinit https://paste.ubuntu.com/p/vxSD5G3HTq/ > Argument 2 to "sum" has incompatible type "timedelta"; expected "float" This seems to be a mypy bug to me. pyright doesn't have the issue. Also, `# type: ignore` is another way to silence type checker errors at a line level vs function level. pyright doesn't understand `no_type_check`.
adsharma commented 2021-04-05 17:59:31 +00:00 (Migrated from github.com)

Updated pull request has 0 type errors on pyright and doesn't introduce any more type errors for mypy vs baseline.

Updated pull request has 0 type errors on pyright and doesn't introduce any more type errors for mypy vs baseline.
adsharma commented 2021-04-05 18:00:05 +00:00 (Migrated from github.com)
https://github.com/mwhittaker/quoracle/pull/6
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/quoracle#4
No description provided.