mypy
mypy copied to clipboard
Optional static typing for Python
This PR extends `get_expr_length` to work with ListComprehension and GeneratorExpression. All of the `get_expr_length` PRs are entirely independent and can be reviewed/merged in any order.
During the rtuple boxing stage, if any of the values are a known Literal type we can skip the struct access and just load the static literal. I had already...
This PR modifies the `any` and `all` call specializers to use our for loop helpers in cases where they can be used. This is only marginally helpful now but will...
This PR adds a `ForFilter` helper class for `for` loops over `builtins.filter` which allows mypyc to maintain control of the function calling, so it can call native functions and use...
This PR is pretty simple, I just extended get_expr_length to work for a few more obvious cases: - `builtins.enumerate` - `builtins.map` - `builtins.zip` - `builtins.range` - `builtins.list` - `builtins.tuple` -...
It should be possible to "constant fold" a LOC such as: ```python requests.get(some_url, headers={"k0": "v0", "k1": "v1"}) ``` We can't simply create a dictionary constant since dicts are mutable and...
This PR makes all static values defined in CPyStatic immortal, since we know they will never be deallocated
This behavior makes sense, as discussed in https://github.com/python/mypy/pull/19911#issuecomment-3326748471, but we should document it explicitly. I manually inspected the generated html to make sure it looked right.
Due to the way I wrote this feature, foolishly generalizing too narrowly from the CONTRIBUTING.md example, you actually could only run testcheck files this way. Luckily, the fix is as...
As I was adapting the mypy codebase to include some new stubs, I realized that the requirements.txt files tell you to run `pip-compile --output-file=test-requirements.txt --strip-extras --allow-unsafe test-requirements.in`, and thus have...