Conversation
… stub files Adds a new educational linter rule that validates correct IProxy usage in .pyi stub files and provides detailed explanations about WHY these transformations occur. Key features: - Validates @instance functions are typed as IProxy[T] variables in stub files - Ensures @injected functions use @overload with original return types (not IProxy[T]) - Provides educational error messages explaining the pinjected type transformation behavior - Helps users understand why stub files differ from source files The rule reads both .py and .pyi files to compare decorators and type annotations, ensuring stub files correctly represent the user-facing interface after pinjected's dependency injection transformations. Closes Linear issue ARC-383 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new educational linter rule PINJ041 that validates correct IProxy usage in .pyi stub files and provides detailed explanations about WHY these transformations occur.
Changes
Purpose
Many developers don't understand why:
@instancefunctions that returnTin.pyfiles are typed asIProxy[T]in.pyifiles@injectedfunctions that returnTshould still returnTin.pyifiles (notIProxy[T])This rule helps educate users about pinjected's type transformation behavior while ensuring stub files are correct.
How It Works
The rule:
Example Error Messages
For @instance:
For @injected:
Test Plan
[x] Unit tests pass (8 test cases covering all scenarios)
[x] Documentation created
[x] Rule registered and builds successfully
Also Found
Bug in PINJ014: Currently wraps @injected return types as IProxy[T] in stub files, which is incorrect according to documentation. Should be fixed separately.
Closes Linear issue ARC-383
🤖 Generated with Claude Code