Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unreachable code #1008

Merged
merged 1 commit into from
Aug 9, 2021
Merged

Remove unreachable code #1008

merged 1 commit into from
Aug 9, 2021

Conversation

mdickinson
Copy link
Member

This PR removes unreachable code from the find_toolkit function.

This PR removes unreachable code from the `find_toolkit` function.
@mdickinson
Copy link
Member Author

Incidentally, Pylance seems to think it's obvious that this code is unreachable. I'm not so convinced - I think this may be a bug in Pylance - it's not clear to me that it's possible to determine that the code is unreachable by simple static analysis. Consider:

import contextlib


@contextlib.contextmanager
def suppress():
    try:
        yield
    except BaseException:
        pass


def f():
    with suppress():
        return 1 / 0
    return 2


print(f())

If I put this code in a script, Pylance similarly claims that the return 2 is unreachable. But executing the script prints 2.

However, in this particular case, the provisional_toolkit context manager will re-raise any exception that occurs within the with block, so the raise TraitError line can't be reached.

@rahulporuri rahulporuri self-requested a review July 30, 2021 03:09
@rahulporuri
Copy link
Contributor

Thanks for the PR. Merging now.

@rahulporuri rahulporuri merged commit 35b57df into master Aug 9, 2021
@rahulporuri rahulporuri deleted the remove-unreachable-code branch August 9, 2021 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants