Skip to content

Commit 536bbb2

Browse files
committed
Add ruff config
1 parent d0a0d69 commit 536bbb2

9 files changed

+78
-27
lines changed

.github/scripts/email_failures.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#! /usr/bin/env python3
22

33
import argparse
4-
import requests
54
import smtplib
5+
66
from collections import defaultdict
77
from email.mime.text import MIMEText
88

9+
import requests
10+
911

1012
def send_email(subject, body, sender, recipient, password, server, port):
1113
msg = MIMEText(body)

.github/scripts/validate_json.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

7-
from collections import defaultdict
8-
from jsonschema import Draft7Validator
9-
from pathlib import Path
107
import argparse
118
import json
129
import os
1310
import sys
1411

12+
from collections import defaultdict
13+
from pathlib import Path
14+
15+
from jsonschema import Draft7Validator
16+
1517

1618
def main():
1719
parser = argparse.ArgumentParser()

l10n/android_l10n.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

7-
from collections import defaultdict, Counter
8-
from custom_html_parser import MyHTMLParser
9-
from moz.l10n.paths import L10nConfigPaths, get_android_locale
107
import argparse
118
import json
129
import os
1310
import re
1411
import sys
1512

13+
from collections import Counter, defaultdict
14+
15+
from custom_html_parser import MyHTMLParser
16+
from moz.l10n.paths import L10nConfigPaths, get_android_locale
17+
18+
1619
try:
1720
from compare_locales import parser
1821
except ImportError as e:

l10n/fluent_l10n.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

7-
from collections import defaultdict, Counter
8-
from custom_html_parser import MyHTMLParser
9-
from fluent.syntax import ast, parse, visitor
10-
from fluent.syntax.serializer import FluentSerializer
11-
from moz.l10n.paths import L10nConfigPaths
12-
from pathlib import Path
137
import argparse
148
import json
159
import os
1610
import re
1711
import sys
1812

13+
from collections import Counter, defaultdict
14+
from pathlib import Path
15+
16+
from custom_html_parser import MyHTMLParser
17+
from fluent.syntax import ast, parse, visitor
18+
from fluent.syntax.serializer import FluentSerializer
19+
from moz.l10n.paths import L10nConfigPaths
20+
21+
1922
try:
2023
from compare_locales import parser
2124
except ImportError as e:
@@ -261,7 +264,7 @@ def visit_Term(self, node):
261264
def visit_SelectExpression(self, node):
262265
# Store the variable used in the selectExpression
263266
if (
264-
type(node.selector) == ast.VariableReference
267+
isinstance(node.selector, ast.VariableReference)
265268
and node.selector.id.name not in self.select_vars
266269
and self.is_message
267270
):

l10n/gettext_l10n.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

7-
from collections import defaultdict
8-
from custom_html_parser import MyHTMLParser
9-
from pathlib import Path
107
import argparse
11-
import json
128
import hashlib
9+
import json
1310
import os
14-
import polib
1511
import re
1612
import sys
1713

14+
from collections import defaultdict
15+
from pathlib import Path
16+
17+
import polib
18+
19+
from custom_html_parser import MyHTMLParser
20+
1821

1922
def ignoreString(exceptions, locale, errorcode, string_id):
2023
"""Check if a string should be ignored"""

l10n/webext_l10n.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

7-
from collections import defaultdict
8-
from glob import glob
97
import argparse
108
import json
119
import os
1210
import re
1311
import sys
1412

13+
from collections import defaultdict
14+
from glob import glob
15+
1516

1617
def parseJsonFiles(base_path, messages, locale):
1718
"""

l10n/xliff_l10n.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

7-
from collections import defaultdict
8-
from custom_html_parser import MyHTMLParser
9-
from glob import glob
10-
from lxml import etree
117
import argparse
128
import html
139
import json
1410
import os
1511
import re
1612
import sys
1713

14+
from collections import defaultdict
15+
from glob import glob
16+
17+
from custom_html_parser import MyHTMLParser
18+
from lxml import etree
19+
1820

1921
def main():
2022
NS = {"x": "urn:oasis:names:tc:xliff:document:1.2"}

reference/webextension/webext_reference.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

7-
from collections import defaultdict
8-
from pathlib import Path
97
import argparse
108
import json
119
import os
1210
import re
1311
import sys
1412

13+
from collections import defaultdict
14+
from pathlib import Path
15+
1516

1617
def main():
1718
parser = argparse.ArgumentParser()

ruff.toml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
line-length = 88
2+
indent-width = 4
3+
4+
# Assume Python 3.11
5+
target-version = "py311"
6+
7+
[lint]
8+
ignore = [
9+
"E501", # Line too long
10+
]
11+
select = [
12+
"E", # pycodestyle errors
13+
"F", # pyflakes
14+
"I", # isort
15+
"W", # pycodestyle warnings
16+
]
17+
18+
[lint.isort]
19+
combine-as-imports = true
20+
lines-after-imports = 2
21+
lines-between-types = 1
22+
section-order = ["future", "standard-library", "third-party", "django", "first-party", "local-folder"]
23+
24+
[lint.isort.sections]
25+
"django" = ["django"]
26+
27+
[format]
28+
quote-style = "double"
29+
indent-style = "space"
30+
skip-magic-trailing-comma = false
31+
line-ending = "lf"
32+
33+
docstring-code-format = false
34+
docstring-code-line-length = "dynamic"

0 commit comments

Comments
 (0)