Refactor this redundant 'await' on a non-promise
时间: 2024-04-11 22:33:24
浏览: 158
To refactor the redundant 'await' on a non-promise, you can simply remove the 'await' keyword. The 'await' keyword is used to wait for the result of a promise, but if you are not dealing with a promise, using 'await' is unnecessary and can be safely removed.
Here's an example:
```python
# Before refactoring
result = await some_function()
# After refactoring
result = some_function()
By removing the 'await' keyword, you are indicating that you are not expecting a promise to be returned, and the code will continue execution without waiting for a result.
相关问题
Refactor+this+method+to+reduce
"Refactor this method to reduce its Cognitive Complexity from 31 to 15 allowed"是Sonar进行代码扫描时的提示。在这个提示中,Cognitive Complexity指的是代码的认知复杂度。通