master
Commits on May 30, 2022
Commits on May 29, 2022
Commits on May 28, 2022
-
stubtest: revert to allow mixed stubs and inline types, add test (#12896
) Reverts #12889 Co-authored-by: hauntsaninja <>
-
stubtest: do not treat py files as source for mypy definitions (#12889)
Authored by @KotlinIsland Co-authored-by: KotlinIsland <kotlinisland@users.noreply.github.com>
-
stubtest: add error summary, other output nits (#12855)
Co-authored-by: KotlinIsland <kotlinisland@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: hauntsaninja <>
Commits on May 27, 2022
-
Put filelock around PEP 561 tests (fixes #12615) (#12857)
Fixes #12615. As discussed in the linked issue, this PR would put a filesystem-based lock around the pip install steps of the suite of PEP561 testcases, to address race conditions. It introduces a test-dependency on tox-dev/py-filelock. I used 3.0.0 as a lower bound, simply because that's what the tox version mentioned in tox.ini specifies as its lower bound. However from the release history it seems that Python 3.6 support was dropped in 3.4.2, hence the second line in the requirements. I ended up just adding the location of the lock file to .gitignore -- I guess it would be possible to try and remove it after the suite has run, e.g. with atexit.register, but I didn't want to make this complicated.
-
[mypyc] Replace integer floor division by a power of two with a shift (…
…#12870) In a microbenchmark right shift was a bit faster.
Commits on May 26, 2022
Commits on May 25, 2022
-
[mypyc] Clean up support for debugging mypyc runtests (#12849)
Add a --mypyc-debug option to pytest that compiles a test normally and then runs the resulting binary in the debugger specified. The support for debugging runtests was already somewhat there. This just cleans it up and adds a pytest option to use it.
-
Disallow assignments to awaited coroutines that do not return (#12853)
Resolves #12837 Co-authored-by: hauntsaninja <>
-
[mypyc] Use PyObject_CallNoArgs and PyObject_CallOneArg (#12862)
Use PyObject_CallNoArgs and PyObject_CallOneArg to replace PyObject_CallFunctionObjArgs in lib-rt, since the new API costs less memory according to python/cpython#13890 (comment) Also remove the macro in pythonsupport.h since the two API are already covered by pythoncapi_compat.h.
Commits on May 23, 2022
-
Friendlier errors for PEP 612 (#12832)
Co-authored-by: hauntsaninja <>
-
-
[mypyc] Generate smaller code for casts (#12839)
Merge a cast op followed by a branch that does an error check and adds a traceback entry. Since casts are very common, this reduces the size of the generated code a fair amount. Old code generated for a cast: ``` if (likely(PyUnicode_Check(cpy_r_x))) cpy_r_r0 = cpy_r_x; else { CPy_TypeError("str", cpy_r_x); cpy_r_r0 = NULL; } if (unlikely(cpy_r_r0 == NULL)) { CPy_AddTraceback("t/t.py", "foo", 2, CPyStatic_globals); goto CPyL2; } ``` New code: ``` if (likely(PyUnicode_Check(cpy_r_x))) cpy_r_r0 = cpy_r_x; else { CPy_TypeErrorTraceback("t/t.py", "foo", 2, CPyStatic_globals, "str", cpy_r_x); goto CPyL2; } ```
-
[mypyc] Fix Python 3.11 C API errors (#12850)
Closes mypyc/mypyc#931 Closes mypyc/mypyc#923 Related CPython modification: python/cpython#89874 python/cpython#31530
-
[mypyc] Borrow even more things (#12817)
Borrow operands of tagged integer operations to reduce the number of incref/decref operations (when it's safe to do so). Borrow the results in list get item operations, similar to what we've been doing with get attribute operations.
-
Use async def in pythoneval tests (#12834)
Co-authored-by: hauntsaninja <>
-
stubtest: add --version (#12852)
Suggested in #12825 Co-authored-by: hauntsaninja <>
Commits on May 22, 2022
-
[mypyc] Remove unnecessary max call for python version (#12848)
We don't support running on Python 3.5 or lower anymore, so the max call is unnecessary because the current version will always be greater than or equal to (3, 6).
Commits on May 21, 2022
-
Run Python 3.11 tests in CI (#12833)
Co-authored-by: hauntsaninja <>
Commits on May 20, 2022
-
FindModuleCache: optionally leverage BuildSourceSet (#12616)
Given a large codebase with folder hierarchy of the form ``` foo/ company/ __init__.py foo/ bar/ company/ __init__.py bar/ baz/ company/ __init__.py baz/ ... ``` with >100 toplevel folders, the time spent in load_graph is dominated by find_module because this operation is itself O(n) where n is the number of input files, which ends up being O(n**2) because it is called for every import statement in the codebase and the way find_module work, it will always scan through each and every one of those toplevel directories for each and every import statement of company.* Introduce a fast path that leverages the fact that for imports within the code being typechecked, we already have a mapping of module import path to file path in BuildSourceSet Gated behind a command line flag (--fast-module-lookup) to assuage concerns about subtle issues in module lookup being introduced by this fast path.
-
checkexpr: cache type of container literals when possible (#12707)
When a container (list, set, tuple, or dict) literal expression is used as an argument to an overloaded function it will get repeatedly typechecked. This becomes particularly problematic when the expression is somewhat large, as seen in #9427 To avoid repeated work, add a new cache in ExprChecker, mapping the AST node to the resolved type of the expression. Right now the cache is only used in the fast path, although it could conceivably be leveraged for the slow path as well in a follow-up commit. To further reduce duplicate work, when the fast-path doesn't work, we use the cache to make a note of that, to avoid repeatedly attempting to take the fast path. Fixes #9427
-
Make pybind11 test fixture fully self-contained (#12722)
Co-authored-by: Keller Fabian Rudolf (CC-AD/EYC3) <FabianRudolf.Keller@de.bosch.com>
-
speedup typechecking of nested if expressions (#12700)
Deeply nested if/else expressions have a worst-case exponential behavior. This will for instance manifest when returning literal values which cause repeated analysis of conditional branches with subtly different type context for each literal. This can be optimized by observing that a simple literal context will yield the same analysis as its fallback type, and likewise, two literals of the same fallback type will yield the same analysis. In those case we can avoid the repeated analysis and prevent the worst-case exponential behavior. Fixes #9591
-
Fix crash on type alias definition inside dataclass declaration (#12792)
Skip processing a type alias node and generate an error. Fixes #12544.
Commits on May 19, 2022
-
Avoid crashing on invalid python executables (#12812)
When an invalid python executable is passed to mypy, show an error message instead of crashing.
-
Skip tests that depend on lxml if not installed (#12813)
Detect if lxml is importable in the test suite, if it is not, then skip the report tests which depend on it. This is useful for enabling CI on new Python versions that may not have lxml wheels yet. Closes #11662.
-
[mypyc] Borrow operands of several primitives (#12810)
Borrow an operand such as `x.y` (attribute of a native class) in various contexts when it's safe to do so. This reduces the number of incref/decref operations we need to perform. This continues work started in #12805. These cases now support borrowing (for some subexpressions, in some contexts): * `x.y is None` * Cast source value * `len(x.y)` (if the operand is a list) * `isinstance(x.y, C)` * `x.y[a.b]` * `x.y.z = 1`