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

While Loops: handle exiting a loop from within a conditional block #494

Merged
merged 6 commits into from
Mar 8, 2022

Conversation

nbdaaron
Copy link
Contributor

@nbdaaron nbdaaron commented Mar 8, 2022

The existing logic doesn't recognize that you can break out of loops inside of an if statement, since it only checks for LEAVES_LOOP in the main scope.

Copy link
Contributor

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch!

This should also get an entry in docs/changelog.md.

pyanalyze/stacked_scopes.py Show resolved Hide resolved
pyanalyze/test_name_check_visitor.py Outdated Show resolved Hide resolved
@JelleZijlstra
Copy link
Contributor

The self-check is still failing on 3.6 because the StackedScopes.loop_scope annotation will also need to be changed.

I'm going to look into why we don't catch this on 3.7+.

@nbdaaron
Copy link
Contributor Author

nbdaaron commented Mar 8, 2022

I can update that. does the type for the base Scope class not need to be changed?

@JelleZijlstra
Copy link
Contributor

does the type for the base Scope class not need to be changed

Yes I think so. That's another thing that pyanalyze should catch by itself.

@JelleZijlstra JelleZijlstra merged commit 650e884 into quora:master Mar 8, 2022
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.

None yet

2 participants