python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.27k stars 2.79k forks source link

Some cleanup in partial plugin #17423

Closed ilevkivskyi closed 3 months ago

ilevkivskyi commented 3 months ago

Fixes https://github.com/python/mypy/issues/17405

Apart from fixing the crash I fix two obvious bugs I noticed while making this PR.

cc @hauntsaninja

github-actions[bot] commented 3 months ago

Diff from mypy_primer, showing the effect of this PR on open source code:

jax (https://github.com/google/jax)
- jax/_src/nn/functions.py:585: error: Argument 1 to "custom_jvp" has incompatible type "Callable[[Array | Any | Any | Any | bool | int | float | complex, int | tuple[int, ...] | None, Array | Any | Any | Any | bool | int | float | complex | None, Array | Any | Any | Any | bool | int | float | complex | None], Array]"; expected "Callable[..., Never]"  [arg-type]
- jax/_src/scipy/special.py:1059: error: Argument 1 to "custom_jvp" has incompatible type "Callable[[Array | Any | Any | Any | bool | int | float | complex, int], Array]"; expected "Callable[..., Never]"  [arg-type]
- jax/experimental/rnn.py:245: error: Argument 1 to "custom_vjp" has incompatible type "Callable[[Array, Array, Array, Array, Array, int, int, int, float, bool, str | Precision | tuple[str, str] | tuple[Precision, Precision] | None], tuple[Array, Array, Array]]"; expected "Callable[..., Never]"  [arg-type]
+ jax/_src/scipy/stats/norm.py:161: error: Redundant cast to "Array"  [redundant-cast]
- jax/_src/cudnn/fused_attention_stablehlo.py:1000: error: Need type annotation for "output"  [var-annotated]
- jax/experimental/pallas/ops/tpu/flash_attention.py:1579: error: Need type annotation for "res"  [var-annotated]

pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/gdblib/events.py:160: error: Need type annotation for "before_prompt"  [var-annotated]
ilevkivskyi commented 3 months ago

Yes, I also have https://github.com/python/mypy/pull/17424, and maybe one more.