Neil Girdhar
Neil Girdhar
Linking: * A motivating example: https://github.com/python/mypy/issues/8881. MyPy relaxed some type safety to support this, but with intersection and `Not`, it may be possible to keep the type safety. * Relevant...
Added #14293 for PEP 681 so that we can track it 😄
Sounds great. Here's another use case that could use a better error: ```python import numpy as np from flax.experimental import nnx from jax import float0, jvp from jax.random import normal...
Also, accidentally passing `Rngs` for a `dict[str, RngStream]` parameter leads to a terrible error: ```python File "/home/neil/src/cmm/cmm/basic_module/noisy_mlp.py", line 38, in noise_callback + (normal(rngs['inference'](), layer_value.shape, layer_value.dtype) ^^^^^^^^^^^^^^^^^^^ File "/home/neil/src/flax/flax/experimental/nnx/nnx/rnglib.py", line 148,...
Even with a custom implementation, the return type will be invisible to type checkers and linters whereas `__getitem__` has the correct annotation. Also, if anyone inherits from `Rngs`, then this...
@jclsn Per your comment: https://github.com/neovim/neovim/issues/27583
@gvanrossum I believe this issue is about silencing MyPy in particular. Unfortunately `type: ignore[code]` doesn't help because Pyright ignores all of the text after `type: ignore` and treats the directive...
In case anyone's interested, I opened a Python-ideas [thread](https://discuss.python.org/t/add-comments-parsing-flag-to-ast-parse/23461/3) and corresponding CPython [issue](https://github.com/python/cpython/issues/101494) for expanding `ast.parse` (as proposed by @jab and @hauntsaninja) to facilitate `mypy: ignore` directives.
@russelldavis I don't think `NotNone` solves the general problem, which seems to be constraining a TypeVar that's bound to a Union.