Commits
master
Name already in use
Commits on Aug 12, 2023
-
Apply TypeVar defaults to functions (PEP 696) (#15387)
Use TypeVar defaults to resolve fallback return type of functions. **Note**: Defaults for TypeVarTuples don't yet work, probably a result of the limited support for `Unpack` / `TypeVarTuple`. Ref: #14851
-
Support __bool__ with Literal in --warn-unreachable (#15645)
This adds support for `Literal` as return type of `__bool__` in the reachability analysis. Fixes #7008
-
Source commit: python/typeshed@fe2ebd6 Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
Commits on Aug 10, 2023
-
Improve error code disabling documentation (#15841)
Provide a concrete example of what file level comments would look like. Sort text into sections a little better.
-
The oldest CAPI version we support right now is 3.7 (#15839)
Looks like `capi_version < 3.7` is not supported, so I changed the lowest version to be `3.7`. Based on the discord discussion.
-
Document new import error codes (#15840)
See #14740 My PR was pretty old and predates the nice check to ensure error codes are documented.
-
Use error subcodes to differentiate import errors (#14740)
Resolves #9789 Users could use `--disable-error-code=import-untyped` to only ignore errors about libraries not having stubs, but continue to get errors about e.g. typos in an import name. The error subcode mechanism is new from #14570. Note that users will now get a different error code depending on whether or not a package is installed, and may not know that they can use the parent error code to ignore the issue regardless. I think this is okay, in general type checking results can change if you run them in two different environments. Note also that with `--warn-unused-ignore` / `--strict` mypy will complain about not having the most specific error code
Commits on Aug 9, 2023
-
New type inference: add support for upper bounds and values (#15813)
This is a third PR in series following #15287 and #15754. This one is quite simple: I just add basic support for polymorphic inference involving type variables with upper bounds and values. A complete support would be quite complicated, and it will be a corner case to already rare situation. Finally, it is written in a way that is easy to tune in the future. I also use this PR to add some unit tests for all three PRs so far, other two PRs only added integration tests (and I clean up existing unit tests as well).
-
Revert "Reconsider constraints involving parameter specifications (#1… (
#15832) …5272)" This reverts commit 2aaeda4. <!-- If this pull request fixes an issue, add "Fixes #NNN" with the issue number. --> (Explain how this PR changes mypy.) <!-- Checklist: - Read the [Contributing Guidelines](https://github.com/python/mypy/blob/master/CONTRIBUTING.md) - Add tests for all changed behaviour. - If you can't add a test, please explain why and how you verified your changes work. - Make sure CI passes. - Please do not force push to the PR once it has been reviewed. -->
Commits on Aug 4, 2023
-
Update black pre-commit mirror link (#15815)
The black pre-commit mirror is now hosted at: https://github.com/psf/black-pre-commit-mirror
Commits on Aug 3, 2023
-
New type inference: complete transitive closure (#15754)
This is a first follow-up for #15287 (I like how my PR titles sound like research paper titles, LOL) This PR completes the new type inference foundations by switching to a complete and well founded algorithm [1] for transitive closure (that replaces more ad hoc initial algorithm that covered 80% of cases and was good for experimenting with new inference scheme). In particular the algorithm in this PR covers two important edge cases (see tests). Some comments: * I don't intend to switch the default for `--new-type-inference`, I just want to see the effect of the switch on `mypy_primer`, I will switch back to false before merging * This flag is still not ready to be publicly announced, I am going to make another 2-3 PRs from the list in #15287 before making this public. * I am not adding yet the unit tests as discussed in previous PR. This PR is already quite big, and the next one (support for upper bounds and values) should be much smaller. I am going to add unit tests only for `transitive_closure()` which is the core of new logic. * While working on this I fixed couple bugs exposed in `TypeVarTuple` support: one is rare technical corner case, another one is serious, template and actual where swapped during constraint inference, effectively causing outer/return context to be completely ignored for instances. * It is better to review the PR with "ignore whitespace" option turned on (there is big chunk in solve.py that is just change of indentation). * There is one questionable design choice I am making in this PR, I am adding `extra_tvars` as an attribute of `Constraint` class, while it logically should not be attributed to any individual constraint, but rather to the full list of constrains. However, doing this properly would require changing the return type of `infer_constrains()` and all related functions, which would be a really big refactoring. [1] Definition 7.1 in https://inria.hal.science/inria-00073205/document --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Commits on Aug 2, 2023
Commits on Aug 1, 2023
Commits on Jul 30, 2023
Commits on Jul 29, 2023
-
-
Better
tox
configuration (#15777)It solves two problems: 1. `fix_annotate` and `async_matrix` were removed in #15728 2. It is better to reuse stuff like `runtests.py` not to rewrite the same command we already have --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
-
Raise
RuntimeError
with better error messages (#15778)While working on #15776 I've noticed that some `RuntimeError` do not have enough metadata to understand what is going on. CI: https://github.com/python/mypy/actions/runs/5700479199/job/15450345887 This PR adds more context to error messages.
-
Remove the Python 37 environment from the
tox.ini
(#15693)Remove the Python 37 environment from the `tox.ini` since Python 3.7 is now end of life. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
-
[stubtest] Test
NamedTuple
definitions with default fields (#15774)This is a test case for #15680 from `stubtest`'s point of view.
-
Correctly narrow types for
tuple[type[X], ...]
(#15691)`flatten_types` forgot about the second way we represent `tuple` inside. Closes #15443 --------- Co-authored-by: Ilya Priven <ilya.konstantinov@gmail.com>
Commits on Jul 28, 2023
Commits on Jul 26, 2023
-
-
Don't flag intentionally empty generators unreachable (#15722)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Commits on Jul 22, 2023
Commits on Jul 21, 2023
-
Raise errors on unbound TypeVars with values (#15732)
Completes a `TODO` item :) Refs #15724 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>