3 ms·
> Python barely has more type support than Ruby That's not true. mypy and Pyright (the main type checkers) are very ahead of Ruby's Sorbet, and Python actually
by maleldil 2y ago
> Python barely has more type support than Ruby
That's not true. mypy and Pyright (the main type checkers) are very ahead of Ruby's Sorbet, and Python actually has proper ergonomic syntax to work with types, which Ruby doesn't. It's also seeing constant development to bring more powerful typing and syntax.
Also, typing has become part of the Python culture, which means most of the big libraries have type hints. It doesn't seem like that is the case with Ruby, where type hints aren't as prevalent. Even the core maintainers don't like the idea and want to keep it as dynamic as possible.
- jshen 2y agoI've had the hardest time getting mypy to work well in vscode. Trying pyright with neovim now, curious how it goes.
- teaearlgraycold 2y agopyright just requires the Microsoft Python extension. In my experience once you have that it works instantly.
- psychoslave 2y agoI don't know Pyright, but is it still Python? It's probably fair to bring it as Sorbet is mentioned, if course. But you can't use Sorbet using a pure ruby interpreter, if I'm getting it correctly, and I guess it's the same for Pyright. It's that so?
- thenipper 2y agoMypy/pyright aren’t interpreters. They’re basically just linters that you run against Python code to see any typing issues. I don’t mean that dismissively,they’re great tools.
- maleldil 2y agoPyright and mypy are typecheckers, completely orthogonal to the interpreter. They work like linters that statically perform type checking. By default, Python's type hints are ignored at runtime (i.e. you can do `x: str = 2`, and the runtime doesn't care), but there are tools to perform runtime checks (e.g. beartype) and libraries that make use of types as metadata (e.g. dataclasses, Pydantic, FastAPI).
- ReleaseCandidat 2y agoInstead of Pyright use Based Pyright for anything that isn't Code, and in Code (not Codium) you can use Pylance instead. https://github.com/DetachHead/basedpyright https://github.com/DetachHead/basedpyright