Skip to content

[ez][BE] Apply lintrunner to non tutorials files #3468

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

Merged
merged 2 commits into from
Jul 17, 2025
Merged
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
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ body:
- type: textarea
attributes:
label: Add Link
description: |
description: |
**Add the link to the tutorial***
placeholder: |
Link to the tutorial on the website:
validations:
required: true
required: true
- type: textarea
attributes:
label: Describe the bug
description: |
**Add the bug description**
description: |
**Add the bug description**
placeholder: |
Provide a detailed description of the issue with code samples if relevant
```python
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ body:
- type: textarea
attributes:
label: Existing tutorials on this topic
description: |
description: |
**Add a list of existing tutorials on the same topic.**
placeholder: |
List tutorials that already explain this functionality if exist. On pytorch.org or elsewhere.
Expand Down
6 changes: 3 additions & 3 deletions .github/scripts/docathon-label-sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def main():
# if the issue has a docathon label, add all labels from the issue to the PR.
if not docathon_label_present:
print("The 'docathon-h1-2025' label is not present in the issue.")
return
return
pull_request_labels = pull_request.get_labels()
issue_label_names = [label.name for label in issue_labels]
labels_to_add = [label for label in issue_label_names if label not in pull_request_labels]
Expand All @@ -39,8 +39,8 @@ def main():
return
pull_request.add_to_labels(*labels_to_add)
print("Labels added to the pull request!")





if __name__ == "__main__":
main()
6 changes: 3 additions & 3 deletions .github/workflows/MonthlyLinkCheck.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Runs once a month and checks links in the repo to ensure they are valid
#Runs once a month and checks links in the repo to ensure they are valid
#If action fails, it creates an issue with the failing links and an "incorrect link" label
#If link is valid but failing, it can be added to the .lycheeignore file
#Action can also be run manually as needed.
Expand Down Expand Up @@ -34,8 +34,8 @@ jobs:
content-filepath: ./lychee/out.md
labels: 'incorrect link'
#token: ${{ secrets.CUSTOM_TOKEN }}


- name: Suggestions
if: failure()
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/StalePRs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
jobs:
stale:
if: ${{ github.repository == 'pytorch/tutorials' }}
runs-on: ubuntu-latest
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
Expand Down Expand Up @@ -154,4 +154,3 @@ jobs:
}
}
core.info(`Processed ${numProcessed} PRs total.`);
6 changes: 3 additions & 3 deletions .github/workflows/link_checkPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
issue_number: context.issue.number
});
return labels.data.some(label => label.name === 'skip-link-check');

- name: Check Links
if: steps.skip-label.outputs.result == 'false'
uses: lycheeverse/lychee-action@v1
with:
args: --accept=200,403,429 --base . --verbose --no-progress ${{ steps.changed-files.outputs.all_changed_files }}
token: ${{ secrets.CUSTOM_TOKEN }}
fail: true

- name: Skip Message
if: steps.skip-label.outputs.result == 'true'
run: echo "Link check was skipped due to the presence of the 'skip-link-check' label."
Expand All @@ -48,7 +48,7 @@ jobs:
- name: No Files to Check
if: steps.skip-label.outputs.result == 'false' && steps.changed-files.outputs.any_changed == 'true'
run: echo "No relevant files were changed in this PR that require link checking."

- name: Suggestions
if: failure()
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
script: |
let skipCheck = false;
let changedFiles = [];

if (context.eventName === 'pull_request') {
// Check for skip label
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
Expand All @@ -26,15 +26,15 @@ jobs:
issue_number: context.issue.number
});
skipCheck = labels.some(label => label.name === 'skip-spell-check');

if (!skipCheck) {
// Get changed files in PR
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});

changedFiles = files
.filter(file => file.filename.match(/\.(py|rst|md)$/))
.map(file => file.filename);
Expand All @@ -43,7 +43,7 @@ jobs:
// For push events, we'll still need to use git diff
// We'll handle this after checkout
}

core.setOutput('skip', skipCheck.toString());
core.setOutput('files', changedFiles.join('\n'));
core.setOutput('is-pr', (context.eventName === 'pull_request').toString());
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
else
FILES="${{ steps.push-files.outputs.files }}"
fi

if [ -z "$FILES" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "No relevant files changed (*.py, *.rst, *.md), skipping spell check"
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
else
mapfile -t FILES <<< "${{ steps.push-files.outputs.files }}"
fi

# Check each file individually
FINAL_EXIT_CODE=0
SPELLCHECK_LOG=""
Expand Down
4 changes: 2 additions & 2 deletions .jenkins/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ elif [[ "${JOB_TYPE}" == "manager" ]]; then
if [[ "$COMMIT_SOURCE" == "refs/heads/master" || "$COMMIT_SOURCE" == "refs/heads/main" ]]; then
git clone https://github.com/pytorch/tutorials.git -b gh-pages gh-pages
# Clean up directories that contain tutorials

for dir in beginner intermediate prototype recipes advanced distributed vision text audio; do
rm -rf "gh-pages/$dir"
done

cp -r docs/* gh-pages/
pushd gh-pages
# DANGER! DO NOT REMOVE THE `set +x` SETTING HERE!
Expand Down
4 changes: 2 additions & 2 deletions .jenkins/post_process_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
This post-processing script needs to run after the .ipynb files are
generated. The script removes extraneous ```{=html} syntax from the
admonitions and splits the cells that have video iframe into a
admonitions and splits the cells that have video iframe into a
separate code cell that can be run to load the video directly
in the notebook. This script is included in build.sh.
"""
Expand Down Expand Up @@ -36,7 +36,7 @@ def process_video_cell(notebook_path):
before_html_block = match.group(1)
code_block = match.group(2)

# Add a comment to run the cell to display the video
# Add a comment to run the cell to display the video
code_block = "# Run this cell to load the video\n" + code_block
# Create a new code cell
new_code_cell = nbf.v4.new_code_cell(source=code_block)
Expand Down
18 changes: 1 addition & 17 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ exclude_patterns = [
"_static/**/*", # Contains some files that should usually not be linted
# All files below this should be checked and either removed from the
# exclusion list by fixing them or have a reason to be excluded.
".github/ISSUE_TEMPLATE/bug-report.yml",
".github/ISSUE_TEMPLATE/feature-request.yml",
".github/scripts/docathon-label-sync.py",
".github/workflows/MonthlyLinkCheck.yml",
".github/workflows/StalePRs.yml",
".github/workflows/link_checkPR.yml",
".github/workflows/spelling.yml",
".jenkins/post_process_notebooks.py",
".lycheeignore",
"CONTRIBUTING.md",
"advanced_source/coding_ddpg.py",
"advanced_source/cpp_autograd.rst",
"advanced_source/cpp_custom_ops.rst",
Expand Down Expand Up @@ -60,7 +50,6 @@ exclude_patterns = [
"beginner_source/saving_loading_models.py",
"beginner_source/template_tutorial.py",
"beginner_source/transfer_learning_tutorial.py",
"docathon-leaderboard.md",
"intermediate_source/TCPStore_libuv_backend.rst",
"intermediate_source/ax_multiobjective_nas_tutorial.py",
"intermediate_source/compiled_autograd_tutorial.rst",
Expand Down Expand Up @@ -108,9 +97,6 @@ exclude_patterns = [
"recipes_source/torch_compiler_set_stance_tutorial.py",
"recipes_source/torch_export_aoti_python.py",
"recipes_source/xeon_run_cpu.rst",
"redirects.py",
"tutorial_submission_policy.md",
".jenkins/build.sh",
"advanced_source/cpp_export.rst",
"advanced_source/torch-script-parallelism.rst",
"advanced_source/torch_script_custom_classes.rst",
Expand Down Expand Up @@ -148,9 +134,9 @@ include_patterns = ['**']
exclude_patterns = [
"_static/**/*", # Contains some files that should usually not be linted
".lintrunner.toml", # Ironically needs to contain the tab character to find in other files
"Makefile", # Wants tabs for indentationo
# All files below this should be checked and either removed from the
# exclusion list by fixing them or have a reason to be excluded.
"Makefile",
"advanced_source/README.txt",
"advanced_source/cpp_frontend.rst",
"advanced_source/torch_script_custom_ops.rst",
Expand Down Expand Up @@ -202,8 +188,6 @@ exclude_patterns=[
"_static/**/*", # Contains some files that should usually not be linted
# All files below this should be checked and either removed from the
# exclusion list by fixing them or have a reason to be excluded.
".github/workflows/StalePRs.yml",
"CONTRIBUTING.md",
"advanced_source/extend_dispatcher.rst",
"advanced_source/neural_style_tutorial.py",
"advanced_source/sharding.rst",
Expand Down
2 changes: 1 addition & 1 deletion .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ https://pytorch.org/tutorials/beginner/colab/n
# Ignore local host link from intermediate_source/tensorboard_tutorial.rst
http://localhost:6006

# Ignore local host link from advanced_source/cpp_frontend.rst
# Ignore local host link from advanced_source/cpp_frontend.rst
https://www.uber.com/blog/deep-neuroevolution/
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Write for a global audience with an instructive and directive voice.

- PyTorch has a global audience; use clear, easy to understand
language. Avoid idioms or other figures of speech.
- To keep your instructions concise, use
- To keep your instructions concise, use
[active voice](https://writing.wisc.edu/handbook/style/ccs_activevoice/) as much as possible.
- For a short guide on the essentials of writing style,
[The Elements of Style](https://www.gutenberg.org/files/37134/37134-h/37134-h.htm)
Expand Down Expand Up @@ -260,7 +260,7 @@ For Python files, our CI system runs your code during each build.

In order for your tutorial to appear on the website, and through tag
search, you need to include it in `index.rst`, or for recipes, in
`recipes_index.rst`.
`recipes_index.rst`.

1. Open the relevant file
[`index.rst`](https://github.com/pytorch/tutorials/blob/main/index.rst)
Expand Down Expand Up @@ -366,4 +366,3 @@ build. You can see an example Netlify preview at the following URL:
## Do not merge the PR yourself ##

Please **DO NOT MERGE** your own PR; the tutorial won't be published. In order to avoid potential build breaks with the tutorials site, only certain maintainers can authorize publishing.

Loading
Loading