Skip to content

Conversation

@charles-turner-1
Copy link
Collaborator

Replace AST with libcst, should let us do some smarter syntax tree traversal in order to catch chained calls, etc properly

@codecov
Copy link

codecov bot commented Aug 1, 2025

Codecov Report

❌ Patch coverage is 97.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.62%. Comparing base (1cb3750) to head (21d7c58).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/access_py_telemetry/ast.py 97.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
+ Coverage   95.15%   96.62%   +1.46%     
==========================================
  Files           7        7              
  Lines         475      504      +29     
==========================================
+ Hits          452      487      +35     
+ Misses         23       17       -6     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@charles-turner-1 charles-turner-1 changed the title Port to libsct Port to libcst Aug 1, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces the standard AST (Abstract Syntax Tree) with libcst (Concrete Syntax Tree) to enable more sophisticated syntax tree traversal and better handling of chained method calls. The change allows for catching complex patterns like method chaining that were previously difficult or impossible to analyze.

Key changes:

  • Migration from Python's built-in ast module to libcst for all syntax tree operations
  • Introduction of a ChainSimplifier transformer to handle method chaining scenarios
  • Enhanced argument extraction with better support for various data types and user namespace resolution

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
tests/test_ast.py Updated all test cases to use libcst, added comprehensive tests for chain simplification and chained function calls
src/access_py_telemetry/ast.py Complete rewrite using libcst with new ChainSimplifier class and enhanced CallListener visitor
pyproject.toml Added libcst dependency and updated mypy configuration
.pre-commit-config.yaml Updated mypy arguments to accommodate new code patterns
Comments suppressed due to low confidence (1)

tests/test_ast.py:399

  • The expected value has changed from ["some_item"] to ["'some_item'"] (with quotes), but there's no explanation for this behavior change. This suggests the string handling in argument extraction may have changed semantics, which should be documented or tested explicitly.
            ("mock", "MyClass.__getitem__", ["'some_item'"], {}),

@@ -1,10 +1,12 @@
# mypy: disable-error-code=has-type
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The mypy disable comment uses 'has-type' but this should be 'type-arg' or another valid mypy error code. 'has-type' is not a recognized mypy error code.

Suggested change
# mypy: disable-error-code=has-type

Copilot uses AI. Check for mistakes.
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