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

Do not enter local scopes in python #1982

Merged
merged 7 commits into from
Jan 29, 2025
Merged

Do not enter local scopes in python #1982

merged 7 commits into from
Jan 29, 2025

Conversation

KuechA
Copy link
Contributor

@KuechA KuechA commented Jan 24, 2025

Python function declarations somehow enter a LocalScope which doesn't make sense. This feature is no longer needed by the graph and was there for legacy reasons. Also lead to incorrect lookups of variables. After this PR, python does no longer enter these LocalScopes . Since the feature was error-prone and only used in a single place (no not at all any more), it's removed completely.

Fixes #1978

@oxisto oxisto added the python label Jan 24, 2025
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.04%. Comparing base (54c921a) to head (233d9b3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...fer/aisec/cpg/frontends/python/StatementHandler.kt 50.00% 0 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (50.00%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
Files with missing lines Coverage Δ
...fer/aisec/cpg/frontends/python/StatementHandler.kt 84.06% <50.00%> (-0.32%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@oxisto oxisto left a comment

Choose a reason for hiding this comment

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

Whoop Whoop. I adjusted the "failing" tests, they still were under the assumption that the local scope exists. This was bugging me for so long and we could finally got rid of the local scopes - also thanks to the EOG rework of @konradweiss

I will leave this unmerged until @maximiliankaul has a chance to look at it.

Copy link
Contributor

@maximiliankaul maximiliankaul left a comment

Choose a reason for hiding this comment

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

LGTM. I have identified some issues not related to this PR, which will be handled in a separate issue.

@oxisto oxisto merged commit 167a54d into main Jan 29, 2025
3 of 4 checks passed
@oxisto oxisto deleted the ak/python-no-local-scope branch January 29, 2025 15:18
oxisto added a commit that referenced this pull request Jan 29, 2025
* Do not enter local scopes in python

* Revert wronge change

* Fixed testGlobal

* Fixed testVarsAndFields

* Fixed testNonLocal

---------

Co-authored-by: Christian Banse <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PythonAddDeclarationsPass ignores ParameterDeclarations and does not resolve symbols to them
3 participants