Skip to content

Commit e3ea946

Browse files
committed
rebase, tweak ruff settings for our needs
1 parent 77170f0 commit e3ea946

File tree

10 files changed

+30
-128
lines changed

10 files changed

+30
-128
lines changed

.github/auto-pr-tests/test_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import subprocess
1+
import difflib
22
import re
3+
import subprocess
34
from pathlib import Path
4-
import difflib
55

66

77
def normalize_ids(text: str) -> str:

builder/build_cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
# dependencies globally). Each book should have a `make.py` script that updates
88
# the submodules, import this shared module, and calls the main function here.
99

10-
from pathlib import Path
1110
import argparse
12-
import subprocess
13-
import requests
1411
import json
12+
import subprocess
1513
import time
14+
from pathlib import Path
15+
16+
import requests
1617

1718
# Automatically watch the following extra directories when --serve is used.
1819
EXTRA_WATCH_DIRS = ["exts", "themes"]

exts/coding_guidelines/fls_checks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class FLSValidationError(SphinxError):
2121
def check_fls(app, env):
2222
"""Main checking function for FLS validation"""
2323
# First make sure all guidelines have correctly formatted FLS IDs
24+
#
2425
check_fls_exists_and_valid_format(app, env)
2526
offline_mode = env.config.offline
2627

exts/coding_guidelines/std_role.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# SPDX-License-Identifier: MIT OR Apache-2.0
22
# SPDX-FileCopyrightText: The Coding Guidelines Subcommittee Contributors
33

4+
from urllib.parse import quote
5+
46
from docutils import nodes
57
from sphinx.roles import SphinxRole
6-
from urllib.parse import quote
78

89

910
class StdRefRole(SphinxRole):

exts/coding_guidelines/write_guidelines_ids.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
import json
77
import os
88
from collections import defaultdict
9+
910
import sphinx
1011
from sphinx_needs.data import SphinxNeedsData
12+
1113
from .common import logger
1214

1315

generate-guideline-templates.py

Lines changed: 0 additions & 105 deletions
This file was deleted.

generate_guideline_templates.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# SPDX-FileCopyrightText: The Coding Guidelines Subcommittee Contributors
44

55
import argparse
6-
import string
76
import random
7+
import string
88
from textwrap import dedent, indent
99

1010
# Configuration
@@ -118,11 +118,6 @@ def generate_id(prefix):
118118

119119
def generate_guideline_template():
120120
"""Generate a complete guideline template with all required sections."""
121-
# Generate IDs for all sections
122-
guideline_id = generate_id("gui")
123-
rationale_id = generate_id("rat")
124-
non_compliant_example_id = generate_id("non_compl_ex")
125-
compliant_example_id = generate_id("compl_ex")
126121

127122
template = guideline_rst_template(
128123
guideline_title="Title Here",

make.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-FileCopyrightText: The Coding Guidelines Subcommittee Contributors
44

55
import os
6+
67
from builder import build_cli
78

89
build_cli.main(os.path.abspath(os.path.dirname(__file__)))

pyproject.toml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@ builder = { workspace = true }
2222

2323
[tool.ruff]
2424
# line-length = 88
25+
2526
lint.select = [
26-
# "E",
27-
# "F",
28-
# "W",
29-
# "C",
30-
# "I",
31-
# "Q",
32-
# "B",
27+
"F", # Pyflakes rules
28+
"W", # PyCodeStyle warnings
29+
"E", # PyCodeStyle errors
30+
"I", # Sort Imports
31+
"TID", # Some good import practices
32+
"C4", # Catch incorrect use of comprehensions, dict, list, etc
3333
]
3434
# Remove or reduce ignores to catch more issues
35-
# ignore = []
35+
lint.ignore = [
36+
"E501", # Ignore long lines, bc we use them frequently while composing .rst templates
37+
"W293", # Ignore white spaces in blank lines
38+
"W291", # Ignore Trailing white lines
39+
"E402", # Ignore "Imports must be at the top of the file" enforcement bc `auto-pr-helper.py` needs it
40+
]
3641
# extend-ignore = []
3742

3843
[tool.ruff.lint.flake8-comprehensions]

scripts/auto-pr-helper.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import argparse
12
import json
3+
import os
24
import re
3-
import argparse
45
import sys
5-
import os
66
from textwrap import indent
7+
78
from m2r import convert
89

910
scriptpath = "../"
@@ -26,7 +27,7 @@ def extract_form_fields(issue_body: str) -> dict:
2627
This function parses issues json into a dict of important fields
2728
"""
2829

29-
fields = {v: "" for v in issue_header_map.values()}
30+
fields = dict.fromkeys(issue_header_map.values(), "")
3031

3132
lines = issue_body.splitlines()
3233
current_key = None

0 commit comments

Comments
 (0)