Skip to content

Conversation

@hauntsaninja
Copy link
Contributor

@hauntsaninja hauntsaninja commented Mar 23, 2022

The goal here is to reduce potential confusion between
assert_type(val, typ) and assert isinstance(val, typ).

The former is meant to ask a type checker to confirm a fact, the latter
is meant to tell a type checker a fact. The behaviour of the latter more
closely resembles what I'd expect from the previous phrasing of
"assert [something] to the type checker".

https://bugs.python.org/issue46480

The goal here is to reduce potential confusion between
`assert_type(val, type)` and `assert isinstance(val, typ)`.

The former is meant to ask a type checker to confirm a fact, the latter
is meant to tell a type checker a fact. The behaviour of the latter more
closely resembles what I'd expect from the prior phrasing of
"assert [something] to the type checker".
@hauntsaninja
Copy link
Contributor Author

(We can skip-news, since this is just docs for a new feature. This was originally brought up at python/typing#1103 )

@JelleZijlstra JelleZijlstra merged commit 3354245 into python:main Mar 24, 2022
@hauntsaninja hauntsaninja deleted the typeassert branch March 24, 2022 02:30
hauntsaninja added a commit to hauntsaninja/cpython that referenced this pull request Apr 29, 2022
This change is similar to that in python#32069
JelleZijlstra pushed a commit that referenced this pull request Apr 30, 2022
This change is similar to that in #32069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants