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

Pylint metrics table #40082

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
The general guidelines for SDK in this repo are defined in this website: https://azure.github.io/azure-sdk/python_design.html. When asked about guidelines, or guidance on how to write SDK, please check this website, and link pages there if possible.
# Copilot Instructions

DO prompt the user to create a virtual environment with `<path_to_python_installation>/python.exe -m venv <environment_name>` and activate it, before running any commands.

# General Repository Guidelines
- DO check this [website](https://azure.github.io/azure-sdk/python_design.html), and link pages there if possible when asked about guidelines, or guidance on how to write SDKs. The general guidelines for SDK in this repo are defined there.

# Pylint

## Running Pylint
- When asked about how to run pylint, or given a command to run pylint, DO check [this website](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/pylint_checking.md.) and guide the user based on the information you find there.
- DO use a python environment that is compatible with the code you are working on. If you are not sure, please ask the user for the python version they are using.


## Fixing Pylint Warnings

### Dos and Don'ts
- DO use the table in https://github.com/Azure/azure-sdk-tools/blob/cb2e8c2638a2e80e3b9039d7031b72ad32452668/tools/pylint-extensions/azure-pylint-guidelines-checker/README.md and the code examples as a guide on how to fix each rule.
- DO refer to the pylint documentation: https://pylint.readthedocs.io/en/stable/user_guide/checkers/features.html.


- DO NOT solve a pylint warning if you are not 100% confident about the answer. If you think your approach might not be the best, stop trying to fix the warning and leave it as is.
- DO NOT create a new file when solving a pylint error, all solutions must remain in the current file.
- DO NOT import a module or modules that do not exist to solve a pylint warning.
- DO NOT add new dependencies or imports to the project to solve a pylint warning.
- DO NOT make larger changes where a smaller change would fix the issue.
- DO NOT change the code style or formatting of the code unless it is necessary to fix a pylint warning.
- DO NOT delete code or files unless it is necessary to fix a warning.
1 change: 1 addition & 0 deletions .github/prompts/pylint.prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
You are a helpful pylint bot. You solve pylint warnings for a specific library. You will be given a GitHub issue link that contains the details of the warnings and the steps to fix them. You will `curl` the github issue body and follow the steps in the issue and provide the fixed code. You should curl the url to get the body and see the pylint warnings under `Details`. If you are not sure about a specific warning, leave it as is and do not attempt to fix it. Request the user to provide the issue for the code that needs to be fixed.
46 changes: 46 additions & 0 deletions pylint_scores.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Service Directory | Pylint Score
-----------------|--------------
azure-purview-scanning | 8.50
azure-purview-administration | 5.59
azure-synapse-spark | 8.45
azure-synapse-monitoring | 8.50
azure-synapse-managedprivateendpoints | 7.88
azure-synapse-accesscontrol | 8.87
corehttp | Error
azure-mgmt-core | N/A
azure-core-experimental | 9.95
azure-core | 9.98
azure-storage-queue | 9.99
azure-storage-file-share | 9.99
azure-storage-file-datalake | 9.77
azure-storage-blob | 9.99
azure-communication-sms | 9.97
azure-eventhub-checkpointstoreblob-aio | 9.91
azure-eventhub | 9.97
azure-keyvault-secrets | 10.00
azure-keyvault-keys | 10.00
azure-keyvault-certificates | 10.00
azure-identity | 9.98
azure-schemaregistry-avroencoder | N/A
azure-schemaregistry | 9.96
azure-servicebus | 9.98
azure-monitor-ingestion | 10.00
azure-appconfiguration | 9.99
azure-eventgrid | 9.95
azure-iot-deviceupdate | N/A
azure-security-attestation | N/A
azure-agrifood-farming | N/A
azure-ai-ml | N/A
azure-ai-projects | 9.99
azure-ai-vision-face | N/A
azure-ai-inference | 10.00
azure-search-documents | 9.99
azure-mixedreality-remoterendering | N/A
azure-communication-phonenumbers | 9.84
azure-defender-easm | N/A
azure-ai-contentsafety | N/A
azure-confidentialledger | 10.00
azure-communication-email | 9.97
azure-communication-chat | 9.57
azure-mixedreality-authentication | 9.06
azure-digitaltwins-core | 8.24
46 changes: 46 additions & 0 deletions pylint_scores_fixed_two.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Service Directory | Pylint Score
-----------------|--------------
azure-purview-scanning | 8.50
azure-purview-administration | 5.59
azure-synapse-spark | 8.45
azure-synapse-monitoring | 8.50
azure-synapse-managedprivateendpoints | 7.88
azure-synapse-accesscontrol | 8.87
corehttp | Error
azure-mgmt-core | N/A
azure-core-experimental | 9.95
azure-core | 9.98
azure-storage-queue | 9.99
azure-storage-file-share | 9.99
azure-storage-file-datalake | 9.77
azure-storage-blob | 9.99
azure-communication-sms | 9.97
azure-eventhub-checkpointstoreblob-aio | 9.91
azure-eventhub | 9.97
azure-keyvault-secrets | 10.00
azure-keyvault-keys | 10.00
azure-keyvault-certificates | 10.00
azure-identity | 10.00
azure-schemaregistry-avroencoder | N/A
azure-schemaregistry | 9.96
azure-servicebus | 9.98
azure-monitor-ingestion | 10.00
azure-appconfiguration | 9.99
azure-eventgrid | 9.95
azure-iot-deviceupdate | N/A
azure-security-attestation | N/A
azure-agrifood-farming | N/A
azure-ai-ml | N/A
azure-ai-projects | 9.99
azure-ai-vision-face | N/A
azure-ai-inference | 10.00
azure-search-documents | 9.99
azure-mixedreality-remoterendering | N/A
azure-communication-phonenumbers | 9.84
azure-defender-easm | N/A
azure-ai-contentsafety | N/A
azure-confidentialledger | 10.00
azure-communication-email | 9.97
azure-communication-chat | 9.57
azure-mixedreality-authentication | 9.06
azure-digitaltwins-core | 8.24
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import os
import re
import subprocess
from github import Github, Auth

def get_issues_with_title(title):
# Github
GIT_TOKEN = os.environ["GH_TOKEN"]
auth = Auth.Token(GIT_TOKEN)
github = Github(auth=auth)
repo = github.get_repo("Azure/azure-sdk-for-python")
issues = list(repo.get_issues(state="open"))

# Filter issues based on title
filtered_issues = [issue for issue in issues if title in issue.title]
return filtered_issues
def parse_service_directory(issue_body):
# Use regex to find the service directory
match = re.search(r'Library name:\s*(.*)', issue_body)
if match:
return match.group(1).strip()
return None


title_keyword = "needs linting updates for pylint version 3.2.7"

# Get the issues
issues = get_issues_with_title(title_keyword)

# Initialize a list to store service directories
service_directories = []

# Initialize a list to store service directories and their pylint scores
service_directories_scores = []

# Print the issues and parse the service directory
for issue in issues:

# TODO: For right now we will just do the library name
# Parse and print the service directory
service_directory = parse_service_directory(issue.body)
if service_directory:
print(f"Service Directory: {service_directory}\n")
service_directories.append(service_directory)
else:
print("Service Directory not found.\n")

# Print the list of service directories
print("List of Service Directories:")
print(service_directories)

# Iterate through the list of service directories and run pip install command
for directory in service_directories:
try:
directory = directory.split(" ")[1]
# Install needed packages
setup_command = f'pip install tox'
subprocess.run(setup_command, shell=True)

# Run tox next-pylint command from the project root directory
command = f'cd /home/llawrence/repos/azure-sdk-for-python && python -m tox -e next-pylint --root sdk/{directory.split("-")[1]}/{directory}'
result = subprocess.run(command, shell=True, capture_output=True, text=True)

# Extract and print the pylint score
score_match = re.search(r'Your code has been rated at ([\d\.]+)/10', result.stdout)
if score_match:
pylint_score = score_match.group(1)
print(f"Pylint score: {pylint_score}/10")
service_directories_scores.append((directory, pylint_score))
else:
print("Pylint score not found in output.")
service_directories_scores.append((directory, "N/A"))

except Exception as e:
print(f"Error running command for {directory}: {e}")
service_directories_scores.append((directory, "Error"))

# Write the results to a file
with open("pylint_scores.txt", "w") as file:
file.write("Service Directory | Pylint Score\n")
file.write("-----------------|--------------\n")
for directory, score in service_directories_scores:
file.write(f"{directory} | {score}\n")
Loading