File .deepsource.toml
not found in the default branch of the repository root. Please refer to the docs.
elif
/ else
block after continue
PYL-R1724 664 total_limit = tiers[-1].range_end
665 subscription_id = sub.subscription_id
666 metric_usage = metric.get_current_usage(sub)
667 if metric_usage is None: 668 continue
669 elif metric_usage == {}:
670 unique_tup_dict = {
462 )
463 matching_plans = list(filter(lambda x: x[1] & item_ids, lotus_plans))
464 # if no plans match any of the items, don't transfer
465 if len(matching_plans) == 0:466 continue
467 # great, in this case we transfer the subscription
468 elif len(matching_plans) == 1:
The use of else
or elif
becomes redundant and can be dropped if the last statement under the leading if
/ elif
block is a continue
statement.
In the case of an elif
after continue
, it can be written as a separate if
block.
For else
blocks after continue
, the statements can be shifted out of else
. Please refer to the examples below for reference.
Refactoring the code this way can improve code-readability and make it easier to maintain.
def classify_number(x):
for num in range(x):
if x % 2 == 0:
continue
else:
print(f"{num} is Odd}")
def classify_number(x):
for num in range(x):
if x % 2 == 0:
continue
print(f"{num} is Odd}")