pyre-check
typing
Our great sponsors
- ONLYOFFICE ONLYOFFICE Docs — document collaboration in your environment
- SonarLint - Clean code begins in your IDE with SonarLint
- InfluxDB - Access the most powerful time series database as a service
- CodiumAI - TestGPT | Generating meaningful tests for busy devs
pyre-check | typing | |
---|---|---|
19 | 38 | |
6,353 | 1,405 | |
1.1% | 1.4% | |
9.9 | 2.7 | |
7 days ago | 2 months ago | |
OCaml | Python | |
MIT License | GNU General Public License v3.0 or later |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
pyre-check
- Writing Python like it's Rust
-
Buck2, a large scale build tool written in Rust by Meta, is now available
Internally we use Pyre for Python type checking: https://github.com/facebook/pyre-check
- Are there any sectors that use Haskell as a main programming language?
-
It is becoming difficult for me to be productive in Python
Before type hinting, work had intense rules and linters enforcing docstrings with types. Now, type hints and automatic pyre runs take care of all the heavy lifting.
-
Ruby 3.2’s YJIT is Production-Ready
Python now has an optional type system and if you add one of them such as mypy or pyre to your CI process and you can configure GitHub to refuse the pull request until types are added you can make it somewhat strongly typed.
If you have a preexisting codebase I believe the way you can convert it is to add the types that you know on commits and eventually you will have enough types that adding the missing ones should be easy. For the missing ones Any is a good choice.
https://pyre-check.org and https://github.com/python/mypy are popular.
-
Is there any other mainstream language (especially strongly typed compiled) whose type system is as powerful (or at least close) as Typescript? It's difficult to like other languages type system after using Typescript.
So to find things in a similar space, you need to look for languages with these sorts of constraints - so things like Sorbet for Ruby or pyright/pyre and you'll see similar and new ideas
-
Statically typed Python
Facebook/Instagram uses Pyre which is a typechecker for Python.
-
OCaml at Bloomberg 'we use OCaml to write DSLs and production services –'
I'd be curious if the pyre-check compilation is any faster for you either by removing the inlining optimization flag (the `-Oclassic` here https://github.com/facebook/pyre-check/blame/36243764ab81a82...) or whether there's a way to compile pyre-check to bytecode instead of the native compilation step (which unfortunately it looks like there's no easy way to modify pyre-check's build config to do so).
I must be doing something wrong.
-
Write better Python - with some help!
Some other good alternatives for type checking are Pyright (which is seen in VSCode via Microsofts PyLance plugin) and Pyre.
typing
- Writing Python like it’s Rust
-
Type Hinting - Constrain metaclass of typing.Type
but looking at relevant issues on GitHub it seems this has been shot down repeatedly. python/typing#18, python/typing#213
-
What type hint should I use for "some container type" in general but explicitly exclude the str type?
See https://github.com/python/typing/issues/256 for a discussion.
-
I use attrs instead of pydantic
Mypy allows that because initial versions of PEP-484 allowed that. This has changed; here's the current wording on the PEP:
> This is no longer the recommended behavior. Type checkers should move towards requiring the optional type to be made explicit.
-
Can I walk through the entire hierarchy of object types?
Dunno, other, larger projects than the one I'm working on seem to run up against this from time to time. (rasa_core, to pick one example from near the top of a Google search; also Telethon, Blender, TensorFlow, Pandas. Guido also filed a bug on the typing module in an early version of Python 3.5 because of unexpected implications of this particular issue, so the problem isn't exactly purely theoretical.) That's aside from the wish for conceptual purity in the call signatures of classes and their subclasses, which is not always and automatically a bad wish to have; and the notion that a language that prides itself on its introspective faculties might want to make introspection of classes from the top of a class hierarchy possible, at least in theory? Perhaps to facility learning about the language and/or visualizing large class hierarchies easily, for instance?
-
Principles of Programming Languages - Robert Harper
How do you define Python? If you include PEP 484 in your definition, surely it must be 'statically typed', otherwise there would be no need for these terms.
-
Type4Py: Machine Learning-based Type Auto-completion for Python
Since Python 3.5 (PEP-484), developers can add type annotations to their code. Python's optional static typing improves code comprehension, code completion, program analysis, and more. However, retrofitting type annotations can be a laborious and time-consuming task.
-
Why Generics? What is the point of it?
You might be interested in looking at PEP 484 (Type Hints https://www.python.org/dev/peps/pep-0484/) and PEP 483 (The Theory of Type Hints https://www.python.org/dev/peps/pep-0483/).
-
Pyre: A performant type-checker for Python 3
> Similarly where a language with first-class support for types might have `type Foo`, Python makes you write `T = TypeVar("T"); class Foo(Generic[T])` or something like that, and it gets more confusing when you only want one of the methods to be generic and I can never remember whether that `T` takes on a single type across all uses or which scope I need to define it in, etc.
I don't know about you but I find PEP 484 very clear here: https://www.python.org/dev/peps/pep-0484/#scoping-rules-for-...
> The problems for which I'm less optimistic tend to revolve around shoehorning typing into existing Python syntax--e.g., to get a callback that takes kwargs you have to define a protocol with a `__call__` method that takes kwargs because you can't express it with `typing.Callable`
You might be interested in the discussion over here then -> https://github.com/python/typing/issues/769#issuecomment-741...
What are some alternatives?
mypy - Optional static typing for Python
pyright - Static Type Checker for Python
pytype - A static type analyzer for Python code
typeshed - Collection of library stubs for Python, with static types
flake8
fp-ts - Functional programming in TypeScript
mashumaro - Fast and well tested serialization library on top of dataclasses
Telethon - Pure Python 3 MTProto API Telegram client library, for bots too!
mamba - The Fast Cross-Platform Package Manager
psst - Fast and multi-platform Spotify client with native GUI
algoneer - The Algoneer Python library.