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

gh-102033: Fix syntax error in Tools/c-analyzer #102066

Merged
merged 7 commits into from
Mar 22, 2023

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Feb 20, 2023

The easiest way to format strings with {} meaningful chars is via %.

Automerge-Triggered-By: GH:ericsnowcurrently

@hauntsaninja
Copy link
Contributor

hauntsaninja commented Feb 20, 2023

Hmm, larger question than this PR, but if this has had a syntax error for the last three years, is it still useful?

@sobolevn
Copy link
Member Author

sobolevn commented Feb 20, 2023

@hauntsaninja good idea! I went trough all files in c-analyzer and:

  • Removed empty ones
  • Removed ones that are unused (like _dparse, _alt, _state_machine)
  • Removed unused imports
  • Removed unused variables

I double checked that:

  • It does not affect semantics
  • It does not affect runtime

To test that everyting is still working I've triggered 3dc3bd9 with a partial revert of #101657 to test the warning.

However, right now Lib/test/test_check_c_globals.py is disabled :(

@sobolevn
Copy link
Member Author

Any idea - why patchcheck fails?

@hauntsaninja
Copy link
Contributor

hauntsaninja commented Feb 20, 2023

@sobolevn It wants you to apply this diff:

diff --git a/Tools/c-analyzer/cpython/_capi.py b/Tools/c-analyzer/cpython/_capi.py
index 5584677dae..dc453cb828 100644
--- a/Tools/c-analyzer/cpython/_capi.py
+++ b/Tools/c-analyzer/cpython/_capi.py
@@ -611,7 +611,7 @@ def _render_item_full(item, groupby, verbose):
     yield f'  {"filename:":10} {item.relfile}'
     for extra in ('kind', 'level'):
         #if groupby != extra:
-            yield f'  {extra+":":10} {getattr(item, extra)}'
+        yield f'  {extra+":":10} {getattr(item, extra)}'
     if verbose:
         print('  ---------------------------------------')
         for lno, line in enumerate(item.text, item.lno):

@sobolevn
Copy link
Member Author

Thank you!

@ericsnowcurrently
Copy link
Member

I'm hesitant to do any significant cleanup on this tool before we've re-enabled the CI check for globals. Would you mind if we tabled this until then?

@sobolevn
Copy link
Member Author

Sure, seems reasonable!

@sobolevn
Copy link
Member Author

Since #102506 was merged, I think we can return to this PR.

Re-running the CI.

@sobolevn
Copy link
Member Author

@ericsnowcurrently the CI passed with your new changes. What are the next steps?

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

LGTM

This change is almost entirely deleting unused code. I don't expect that any of that code is important to keep at this point. Thanks for doing this!

@sobolevn
Copy link
Member Author

Thanks everyone!

Is there anything else I need to do? :)
If not, can someone please click "merge"?

@ericsnowcurrently
Copy link
Member

Thanks again, @sobolevn!

Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
)

The easiest way to format strings with `{}` meaningful chars is via `%`.
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
)

The easiest way to format strings with `{}` meaningful chars is via `%`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants