Update type-concepts.md (#2230)

This commit is contained in:
Denis Eliseev 2021-08-26 20:33:12 +05:00 committed by GitHub
parent fa4194fd8b
commit 475a44273c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -296,4 +296,4 @@ def add_one(value: _StrOrFloat) -> _StrOrFloat:
return sum
```
Notice that the type of variable `sum` is reported with asterisks (`*`). This indicates that internally the type checker is tracking the type as conditional. In this particular example, it indicates that `sum` is a `str` type if the parameter `input` is a `str` but is a `float` if `input` is a `float`. By tracking these conditional types, the type checker can verify that the return type is consistent with the return type `_StrOrFloat`.
Notice that the type of variable `sum` is reported with asterisks (`*`). This indicates that internally the type checker is tracking the type as conditional. In this particular example, it indicates that `sum` is a `str` type if the parameter `value` is a `str` but is a `float` if `value` is a `float`. By tracking these conditional types, the type checker can verify that the return type is consistent with the return type `_StrOrFloat`.