classification
Title: Unnecessary Type casting in 'if condition'
Type: enhancement Stage: resolved
Components: asyncio Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, miss-islington, remi.lapeyre, wyz23x2, ys19991, yselivanov
Priority: normal Keywords: patch

Created on 2020-07-08 14:25 by ys19991, last changed 2020-11-28 11:49 by asvetlov. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21396 merged ys19991, 2020-07-08 14:32
PR 21518 closed wyz23x2, 2020-07-17 10:56
Messages (3)
msg373309 - (view) Author: Wansoo Kim (ys19991) * Date: 2020-07-08 14:25
Hello!

When using 'if syntax', casting condition to bool type is unnecessary. Rather, it only occurs overhead.

https://github.com/python/cpython/blob/b26a0db8ea2de3a8a8e4b40e69fc8642c7d7cb68/Lib/asyncio/futures.py#L118

If you look at the link above, the `val` has been cast to bool type. This works well without bool casting.

This issue is my first issue. So if you have a problem, please tell me!

Thanks You!
msg373826 - (view) Author: RĂ©mi Lapeyre (remi.lapeyre) * Date: 2020-07-17 11:29
Hi Wansoo, welcome to Python!


Changes that are purely cosmetic but do not change the underlying meaning of the code are usually refused as they create unwanted code churn. You will find some info about this and all the other aspects of contributing to Python in the Python Dev Guide: https://devguide.python.org/.


If you want to find an issue on which you could work, please have a look at the `easy` `easy (C)` and `newcomer_friendly` issues in the bug tracker. You can find them using the search function of https://bugs.python.org/
msg381995 - (view) Author: miss-islington (miss-islington) Date: 2020-11-28 11:37
New changeset 5b0194ed31376382da63ad5b10271a4acc4a80e8 by Wansoo Kim in branch 'master':
bpo-41241: Unnecessary Type casting in 'if condition' (GH-21396)
https://github.com/python/cpython/commit/5b0194ed31376382da63ad5b10271a4acc4a80e8
History
Date User Action Args
2020-11-28 11:49:15asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-11-28 11:37:26miss-islingtonsetnosy: + miss-islington
messages: + msg381995
2020-07-17 11:29:28remi.lapeyresetnosy: + remi.lapeyre
messages: + msg373826
2020-07-17 10:56:31wyz23x2setpull_requests: + pull_request20655
2020-07-17 10:56:18wyz23x2setpull_requests: - pull_request20654
2020-07-17 10:54:16wyz23x2setnosy: + wyz23x2
pull_requests: + pull_request20654
2020-07-08 14:32:58ys19991setkeywords: + patch
stage: patch review
pull_requests: + pull_request20544
2020-07-08 14:25:35ys19991create