10000 Add changelog for 1.16 by JukkaL · Pull Request #19138 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Add changelog for 1.16 #19138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 29, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Document Any-related type checking improvements
  • Loading branch information
JukkaL committed May 23, 2025
commit b065c73a25a55f14e3046e73c7db5beff36e69cc
29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,34 @@ This was contributed by Jukka Lehtosalo (PR [18727](https://github.com/python/my

Mypy can now detect additional errors in code that uses `Any` types or has missing function annotations.

* `dict.get`
When calling `dict.get(x, None)` on an object of type `dict[str, Any]`, this
now results in an optional type (in the past it was `Any`):

```python
def f(d: dict[str, Any]) -> int:
# Error: Return value has type "Any | None" but expected "int"
return d.get("x", None)
```

Type narrowing using assignments can result in more precise types in
the presence of `Any` types:

```python
def foo(): ...

def bar(n: int) -> None:
x = foo()
# Type of 'x' is 'Any' here
if n > 5:
x = str(n)
# Type of 'x' is 'str' here
```

When using `--check-untyped-defs`, unannotated overrides are now
checked more strictly against superclass definitions.

Related PRs:

* Use union types instead of join in binder (Ivan Levkivskyi, PR [18538](https://github.com/python/mypy/pull/18538))
* Check superclass compatibility of untyped methods if `--check-untyped-defs` is set (Stanislav Terliakov, PR [18970](https://github.com/python/mypy/pull/18970))

Expand Down
0