question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Forbid to use `continue` in `finally`

See original GitHub issue

Rule request

Thesis

This code is now allowed:

for some in range(10):
    try:
        func(some)
    finally:
        continue

Why would you do that? Putting any control statements in finally is a terrible practice. We should not allow it.

It was added in python3.8: https://www.python.org/downloads/release/python-381/

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
sobolevncommented, Feb 15, 2020

Sure! Feel free to ask for help.

0reactions
sobolevncommented, Feb 25, 2020

We can combine them into one: continue and break

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is `continue` not allowed in a `finally` clause in Python?
The use of continue in a finally-clause is forbidden because its interpretation would have been problematic.
Read more >
PEP 601 – Forbid return/break/continue breaking out of finally
The use of return , break and continue within a finally suite leads to behaviour which is not at all obvious.
Read more >
Why continue statement cannot be used inside finally block?
This post explores why continue statement cannot be present inside finally block. Now for our understanding let's assume that we can write continue...
Read more >
Warn about continue/return/break in finally block #99 - GitHub
I reported this issue originally to pyflakes but they decided that is it not an error, and hence it should better be flagged...
Read more >
ERR04-J. Do not complete abruptly from a finally block
Never use return , break , continue , or throw statements within a finally block. When program execution enters a try block that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found