-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently mypy doesn't interpret things other than classes as being compatible with `Type[T]` (they literally have to be instances of `type`). This makes it hard to properly type the `decode` methods or `Decoder` constructors, as passing type-like-things (e.g. `Union[int, str]`) will error under mypy. `pyright` doesn't have this limitation. For now we add a fallback `overload` to these methods that infers the decoder type as `Decoder[Any]`. This means that `mypy` will no longer error, but will require an explicit annotation to infer the type of the output of `decode`. If/once the `TypeForm` PEP lands, this hack can be removed. Until then `pyright` support for these annotations will be much better than `mypy` support.
- Loading branch information
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters