-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Auto-assign Copilot to next- issues generated from weekly run, and add fix-pyright skill #46726
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
Open
JennyPng
wants to merge
23
commits into
Azure:main
Choose a base branch
from
JennyPng:automate-fixing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
dd90f35
initial vnext changes, pyright skill
JennyPng ba0ea81
improvements
JennyPng 9752d60
retrigger copilot when version changes
JennyPng 665014a
fix pylance complaints
JennyPng 4f27619
skill fix
JennyPng 83937fb
test fix
JennyPng 98447a2
black
JennyPng 6451a18
Merge branch 'main' into automate-fixing
JennyPng d6882c2
minor
JennyPng 22ac03c
dont comment, graphql fix
JennyPng b152b77
test fix
JennyPng 8b8f165
doc update
JennyPng 97c03d7
minor doc update
JennyPng cc13536
dynamically get bot id, and other stuff
JennyPng 83757f2
always dynamically get bot id
JennyPng ede5d76
call get node id once
JennyPng a5bc5b0
add label only if copilot actually got assigned
JennyPng a258046
black
JennyPng 195a382
Apply suggestions from code review
JennyPng eea1409
address copilot comments
JennyPng c8865e8
minor skill updates
JennyPng 7c22761
Minor black skill update
JennyPng 6b572fa
minor comment updates
JennyPng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,199 @@ | ||
| --- | ||
| name: fix-pyright | ||
| description: Automatically fix pyright type checking issues in any Azure SDK for Python package following Azure SDK Python patterns. | ||
| --- | ||
|
|
||
| # Fix Pyright Issues Skill | ||
|
|
||
| This skill automatically fixes pyright type checking errors in any Azure SDK for Python package by analyzing existing code patterns and applying fixes with 100% confidence. | ||
|
|
||
| ## Overview | ||
|
|
||
| Intelligently fixes pyright issues by: | ||
| 1. Getting the package path or GitHub issue URL from the user | ||
| 2. Reading and analyzing the issue details (if issue URL provided) | ||
| 3. Setting up or using existing virtual environment | ||
| 4. Installing required dependencies | ||
| 5. Running pyright on the package | ||
| 6. Analyzing the pyright output to identify type errors | ||
| 7. Searching codebase for existing type annotation patterns | ||
| 8. Applying fixes only with 100% confidence | ||
| 9. Re-running pyright to verify fixes | ||
| 10. Creating a pull request | ||
| 11. Providing a summary of what was fixed | ||
|
|
||
| ## Running Pyright | ||
|
|
||
| **Prerequisites:** | ||
| - Use a Python 3.10 virtual environment | ||
| - Ensure `azpysdk` is installed in the venv | ||
|
|
||
| **Command:** | ||
| ```powershell | ||
| cd <package-path> | ||
| # 1. activate venv | ||
| # 2. install dev_requirements.txt | ||
| azpysdk --isolate pyright . | ||
|
JennyPng marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| > **Note:** `azpysdk pyright` runs with a pinned version of pyright at the package level only. To focus on specific files, run the full check and filter the output by file path. | ||
|
|
||
| **Using Latest Pyright:** | ||
| ```powershell | ||
| azpysdk --isolate next-pyright . | ||
| ``` | ||
|
|
||
| > Use `azpysdk next-pyright` to run with the latest version of pyright. This is useful for catching issues that may be flagged by newer pyright versions. | ||
|
|
||
| ## Reference Documentation | ||
|
|
||
| - [Official Pyright Documentation](https://microsoft.github.io/pyright/) | ||
| - [Pyright Configuration](https://microsoft.github.io/pyright/#/configuration) | ||
| - [Pyright Error Codes](https://microsoft.github.io/pyright/#/configuration?id=type-check-diagnostics-settings) | ||
| - [Azure SDK Python Type Checking Guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/static_type_checking_cheat_sheet.md) | ||
|
|
||
| ## Fixing Strategy | ||
|
|
||
| ### Step 0: Get Package and Issue Details | ||
|
|
||
| **Check if user provided in their request:** | ||
| - GitHub issue URL (look for `https://github.com/Azure/azure-sdk-for-python/issues/...` in user's message) | ||
| - Package path or name (e.g. `sdk/storage/azure-storage-blob` or `azure-storage-blob`) | ||
| - Virtual environment path (look for phrases like "using venv", "use env", "virtual environment at", or just the venv name) | ||
|
|
||
| **If both GitHub issue URL and package path are missing:** | ||
| Ask: "Please provide either the GitHub issue URL or the package path (e.g. sdk/storage/azure-storage-blob) for the pyright type checking problems you want to fix." | ||
|
|
||
| **If a GitHub issue URL is provided:** | ||
| Read the issue to understand which package and files/modules are affected, and the specific error codes to fix. | ||
|
|
||
| **If only a package path is provided:** | ||
| Run pyright checks directly on the package. | ||
|
|
||
| **If virtual environment is missing:** | ||
| Ask: "Do you have an existing virtual environment path, or should I create 'env' with Python 3.10?" | ||
|
|
||
| ### Step 1: CRITICAL - Activate Python 3.10 Virtual Environment FIRST | ||
|
|
||
|
|
||
| **⚠️ IMPORTANT: ALL subsequent commands MUST run within the activated Python 3.10+ virtual environment. Never run commands outside the venv.** | ||
|
|
||
| ### Step 2: Install Dependencies (within activated venv) | ||
|
|
||
| ```powershell | ||
| # Navigate to the package directory (within activated venv) | ||
| cd <package-path> | ||
|
|
||
| # Install dev dependencies from dev_requirements.txt (within activated venv) | ||
| pip install -r dev_requirements.txt | ||
|
|
||
| # Install the package in editable mode (within activated venv) | ||
| pip install -e . | ||
| ``` | ||
|
|
||
| ### Step 3: Identify Target Files (within activated venv) | ||
|
|
||
| Based on the GitHub issue details, determine which files to check: | ||
|
|
||
| **Option A - Run pyright on the package and filter output:** | ||
| ```powershell | ||
| # Ensure you're in the package directory (within activated venv) | ||
| cd <package-path> | ||
|
|
||
| # Run pyright on the full package, then filter output for files from the issue | ||
| azpysdk --isolate next-pyright . | ||
| # Review output for errors in the specific files/modules mentioned in the issue | ||
| ``` | ||
|
|
||
| **Option B - Check modified files (if no specific target):** | ||
| ```powershell | ||
| git diff --name-only HEAD | Select-String "<package-path>" | ||
| git diff --cached --name-only | Select-String "<package-path>" | ||
| ``` | ||
|
|
||
| ### Step 4: Run Pyright (within activated venv) | ||
|
|
||
| **⚠️ Ensure virtual environment is still activated before running:** | ||
|
|
||
| ```powershell | ||
| # Navigate to the package directory | ||
| cd <package-path> | ||
|
|
||
| # Run pyright on the package (within activated venv) | ||
| azpysdk --isolate pyright . | ||
| # Filter output for the specific files/modules from the issue | ||
| ``` | ||
|
|
||
| ### Step 5: Analyze Type Errors | ||
|
|
||
| Parse the pyright output to identify: | ||
| - Error type and rule (e.g., reportGeneralClassIssues, reportMissingTypeArgument, reportAttributeAccessIssue) | ||
| - File path and line number | ||
| - Specific error description | ||
| - Expected vs actual types | ||
| - **Cross-reference with the GitHub issue** (if provided) to ensure you're fixing the right problems | ||
|
|
||
| ### Step 6: Search for Existing Type Annotation Patterns | ||
|
|
||
| Before fixing, search the codebase for how similar types are annotated: | ||
| ```powershell | ||
| # Example: Search for similar function signatures | ||
| grep -r "def similar_function" <package-path>/ -A 5 | ||
|
|
||
| # Search for type imports | ||
| grep -r "from typing import" <package-path>/ | ||
| ``` | ||
|
|
||
| Use the existing type annotation patterns to ensure consistency. | ||
|
|
||
| ### Step 7: Apply Fixes (ONLY if 100% confident) | ||
|
|
||
| **ALLOWED ACTIONS:** | ||
| ✅ Fix type errors with 100% confidence | ||
| ✅ Use existing type annotation patterns as reference | ||
| ✅ Follow Azure SDK Python type checking guidelines | ||
| ✅ Add missing type hints | ||
| ✅ Fix incorrect type annotations | ||
| ✅ Add proper type narrowing (isinstance checks, assertions) | ||
| ✅ Make minimal, targeted changes | ||
|
|
||
| **FORBIDDEN ACTIONS:** | ||
| ❌ Fix errors without complete confidence | ||
| ❌ Create new files for solutions | ||
| ❌ Import non-existent types or modules | ||
| ❌ Add new dependencies or imports outside typing module | ||
| ❌ Use `# type: ignore` or `# pyright: ignore` without clear justification | ||
| ❌ Change code logic to avoid type errors | ||
| ❌ Delete code without clear justification | ||
|
|
||
| ### Step 8: Verify Fixes | ||
|
|
||
| Re-run pyright to ensure: | ||
| - The type error is resolved | ||
| - No new errors were introduced | ||
| - The code still functions correctly | ||
|
|
||
| ### Step 9: Summary | ||
|
|
||
| Provide a summary: | ||
| - GitHub issue being addressed | ||
| - Number of type errors fixed | ||
| - Number of errors remaining | ||
| - Types of fixes applied (e.g., added type hints, fixed return types, added type narrowing) | ||
| - Any errors that need manual review | ||
|
|
||
| ### Step 10: Create Pull Request | ||
|
|
||
| > **⚠️ REQUIRED when a GitHub issue URL was provided:** You MUST create a pull request after validating fixes. This is not optional. | ||
|
|
||
| Create a pull request with a descriptive title and body referencing the issue. Include what was fixed and confirm all pyright checks pass. The PR title should follow the format: "fix(<package-name>): Resolve pyright type errors (#<issue-number>)". | ||
|
|
||
| ## Notes | ||
|
|
||
| - Always read the existing code to understand type annotation patterns before making changes | ||
| - Prefer following existing patterns over adding new complex types | ||
| - Use Python 3.10+ compatible type hints (use `Optional[X]` instead of `X | None`) | ||
| - If unsure about a fix, mark it for manual review | ||
| - Some errors may require architectural changes - don't force fixes | ||
| - Test the code after fixing to ensure functionality is preserved | ||
| - Avoid using `# pyright: ignore` unless absolutely necessary and document why | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.