Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 2, 2026

Implements Python code analysis library for Hielements with three check categories: import verification, return type validation, and call tracking between scopes.

Implementation

  • New library: crates/hielements-core/src/stdlib/python.rs (460 lines)

    • Selectors: module_selector, function_selector, class_selector
    • Import checks: imports, no_import
    • Return type checks: returns_type, function_returns_type
    • Call checks: calls, calls_function, calls_scope
  • Pattern matching: Regex with word boundaries (\b) prevents false positives (e.g., 'os' won't match 'osmesa')

  • Type support: Handles async functions and generic type annotations (List[T], Dict[K,V])

  • Limitations: Text-based analysis; patterns in comments/strings will match

Usage

import python

element api_service:
    scope api = python.module_selector('api.orders')
    scope utils = python.module_selector('utils')
    
    # Verify imports
    check python.imports(api, 'typing')
    check python.no_import(api, 'deprecated')
    
    # Verify return types
    check python.function_returns_type(api, 'create_order', 'Order')
    
    # Verify cross-module calls
    check python.calls_scope(api, utils)
    check python.calls_function(api, 'logger', 'info')

Testing

  • 10 unit tests covering all selectors and checks
  • Verified with real Python modules in /tmp/python_demo
  • Example file: examples/python_example.hie
Original prompt

Let's work on the implementation of checks for the python language. The first checks are:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits January 2, 2026 07:38
Co-authored-by: ercasta <1530425+ercasta@users.noreply.github.com>
…reference

Co-authored-by: ercasta <1530425+ercasta@users.noreply.github.com>
…alse positives

Co-authored-by: ercasta <1530425+ercasta@users.noreply.github.com>
Co-authored-by: ercasta <1530425+ercasta@users.noreply.github.com>
Co-authored-by: ercasta <1530425+ercasta@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement initial checks for Python language Add Python language library with import, return type, and call checks Jan 2, 2026
Copilot AI requested a review from ercasta January 2, 2026 07:54
@ercasta ercasta marked this pull request as ready for review January 2, 2026 08:04
@ercasta ercasta merged commit 5cb38c1 into main Jan 2, 2026
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