Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 50762da

Browse files
author
Ricky Stewart
committed
Bug 1654103: Standardize on Black for Python code in mozilla-central. r=remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers,devtools-backward-compat-reviewers,jgilbert,preferences-reviewers,sylvestre,maja_zf,webcompat-reviewers,denschub,ntim,whimboo,sparky
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly. To produce this patch I did all of the following: 1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions. 2. Run ./mach lint --linter black --fix 3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks. 4. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023). # ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D94045
1 parent e70c58a commit 50762da

3,423 files changed

Lines changed: 164608 additions & 129074 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ycm_extra_conf.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,55 @@
1212
old_bytecode = sys.dont_write_bytecode
1313
sys.dont_write_bytecode = True
1414

15-
path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'mach'))
15+
path = os.path.abspath(os.path.join(os.path.dirname(__file__), "mach"))
1616

1717
# If mach is not here, we're on the objdir go to the srcdir.
1818
if not os.path.exists(path):
19-
with open(os.path.join(os.path.dirname(__file__), 'mozinfo.json')) as info:
19+
with open(os.path.join(os.path.dirname(__file__), "mozinfo.json")) as info:
2020
config = json.loads(info.read())
21-
path = os.path.join(config['topsrcdir'], 'mach')
21+
path = os.path.join(config["topsrcdir"], "mach")
2222

2323
sys.dont_write_bytecode = old_bytecode
2424

25+
2526
def _is_likely_cpp_header(filename):
26-
if not filename.endswith('.h'):
27+
if not filename.endswith(".h"):
2728
return False
2829

29-
if filename.endswith('Inlines.h') or filename.endswith('-inl.h'):
30+
if filename.endswith("Inlines.h") or filename.endswith("-inl.h"):
3031
return True
3132

32-
cpp_file = filename[:-1] + 'cpp'
33+
cpp_file = filename[:-1] + "cpp"
3334
return os.path.exists(cpp_file)
3435

3536

3637
def Settings(**kwargs):
37-
if kwargs[ 'language' ] == 'cfamily':
38-
return FlagsForFile(kwargs['filename'])
38+
if kwargs["language"] == "cfamily":
39+
return FlagsForFile(kwargs["filename"])
3940
# This is useful for generic language server protocols, like rust-analyzer,
4041
# to discover the right project root instead of guessing based on where the
4142
# closest Cargo.toml is.
4243
return {
43-
'project_directory': '.',
44+
"project_directory": ".",
4445
}
4546

4647

4748
def FlagsForFile(filename):
48-
output = subprocess.check_output([path, 'compileflags', filename])
49-
output = output.decode('utf-8')
49+
output = subprocess.check_output([path, "compileflags", filename])
50+
output = output.decode("utf-8")
5051

5152
flag_list = shlex.split(output)
5253

5354
# This flag is added by Fennec for android build and causes ycmd to fail to parse the file.
5455
# Removing this flag is a workaround until ycmd starts to handle this flag properly.
5556
# https://github.com/Valloric/YouCompleteMe/issues/1490
56-
final_flags = [x for x in flag_list if not x.startswith('-march=armv')]
57+
final_flags = [x for x in flag_list if not x.startswith("-march=armv")]
5758

5859
if _is_likely_cpp_header(filename):
5960
final_flags += ["-x", "c++"]
6061

61-
return {
62-
'flags': final_flags,
63-
'do_cache': True
64-
}
62+
return {"flags": final_flags, "do_cache": True}
63+
6564

66-
if __name__ == '__main__':
65+
if __name__ == "__main__":
6766
print(FlagsForFile(sys.argv[1]))

accessible/android/moz.build

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,39 @@
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-
EXPORTS.mozilla.a11y += ['AccessibleWrap.h',
8-
'HyperTextAccessibleWrap.h',
9-
'SessionAccessibility.h',
10-
'TraversalRule.h',
7+
EXPORTS.mozilla.a11y += [
8+
"AccessibleWrap.h",
9+
"HyperTextAccessibleWrap.h",
10+
"SessionAccessibility.h",
11+
"TraversalRule.h",
1112
]
1213

1314
SOURCES += [
14-
'AccessibleWrap.cpp',
15-
'DocAccessibleWrap.cpp',
16-
'Platform.cpp',
17-
'ProxyAccessibleWrap.cpp',
18-
'RootAccessibleWrap.cpp',
19-
'SessionAccessibility.cpp',
20-
'TraversalRule.cpp',
15+
"AccessibleWrap.cpp",
16+
"DocAccessibleWrap.cpp",
17+
"Platform.cpp",
18+
"ProxyAccessibleWrap.cpp",
19+
"RootAccessibleWrap.cpp",
20+
"SessionAccessibility.cpp",
21+
"TraversalRule.cpp",
2122
]
2223

2324
LOCAL_INCLUDES += [
24-
'/accessible/base',
25-
'/accessible/generic',
26-
'/accessible/html',
27-
'/accessible/ipc',
28-
'/accessible/ipc/other',
29-
'/accessible/xpcom',
30-
'/accessible/xul',
31-
'/dom/base',
32-
'/widget',
33-
'/widget/android',
25+
"/accessible/base",
26+
"/accessible/generic",
27+
"/accessible/html",
28+
"/accessible/ipc",
29+
"/accessible/ipc/other",
30+
"/accessible/xpcom",
31+
"/accessible/xul",
32+
"/dom/base",
33+
"/widget",
34+
"/widget/android",
3435
]
3536

36-
FINAL_LIBRARY = 'xul'
37+
FINAL_LIBRARY = "xul"
3738

38-
include('/ipc/chromium/chromium-config.mozbuild')
39+
include("/ipc/chromium/chromium-config.mozbuild")
3940

40-
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
41-
CXXFLAGS += ['-Wno-error=shadow']
41+
if CONFIG["CC_TYPE"] in ("clang", "gcc"):
42+
CXXFLAGS += ["-Wno-error=shadow"]

accessible/aom/moz.build

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

77
EXPORTS.mozilla.dom += [
8-
'AccessibleNode.h',
8+
"AccessibleNode.h",
99
]
1010

1111
UNIFIED_SOURCES += [
12-
'AccessibleNode.cpp',
12+
"AccessibleNode.cpp",
1313
]
1414

1515
LOCAL_INCLUDES += [
16-
'/accessible/base',
17-
'/accessible/generic',
16+
"/accessible/base",
17+
"/accessible/generic",
1818
]
1919

20-
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
20+
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
2121
LOCAL_INCLUDES += [
22-
'/accessible/atk',
22+
"/accessible/atk",
2323
]
24-
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
24+
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
2525
LOCAL_INCLUDES += [
26-
'/accessible/windows/ia2',
27-
'/accessible/windows/msaa',
26+
"/accessible/windows/ia2",
27+
"/accessible/windows/msaa",
2828
]
29-
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
29+
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
3030
LOCAL_INCLUDES += [
31-
'/accessible/mac',
31+
"/accessible/mac",
3232
]
33-
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
33+
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
3434
LOCAL_INCLUDES += [
35-
'/accessible/android',
35+
"/accessible/android",
3636
]
3737
else:
3838
LOCAL_INCLUDES += [
39-
'/accessible/other',
39+
"/accessible/other",
4040
]
4141

42-
include('/ipc/chromium/chromium-config.mozbuild')
42+
include("/ipc/chromium/chromium-config.mozbuild")
4343

44-
FINAL_LIBRARY = 'xul'
44+
FINAL_LIBRARY = "xul"

accessible/atk/moz.build

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,61 @@
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

77
EXPORTS.mozilla.a11y += [
8-
'AccessibleWrap.h',
9-
'HyperTextAccessibleWrap.h',
8+
"AccessibleWrap.h",
9+
"HyperTextAccessibleWrap.h",
1010
]
1111

1212
SOURCES += [
13-
'AccessibleWrap.cpp',
14-
'ApplicationAccessibleWrap.cpp',
15-
'AtkSocketAccessible.cpp',
16-
'DocAccessibleWrap.cpp',
17-
'DOMtoATK.cpp',
18-
'nsMaiHyperlink.cpp',
19-
'nsMaiInterfaceAction.cpp',
20-
'nsMaiInterfaceComponent.cpp',
21-
'nsMaiInterfaceDocument.cpp',
22-
'nsMaiInterfaceEditableText.cpp',
23-
'nsMaiInterfaceHyperlinkImpl.cpp',
24-
'nsMaiInterfaceHypertext.cpp',
25-
'nsMaiInterfaceImage.cpp',
26-
'nsMaiInterfaceSelection.cpp',
27-
'nsMaiInterfaceTable.cpp',
28-
'nsMaiInterfaceTableCell.cpp',
29-
'nsMaiInterfaceText.cpp',
30-
'nsMaiInterfaceValue.cpp',
31-
'Platform.cpp',
32-
'RootAccessibleWrap.cpp',
33-
'UtilInterface.cpp',
13+
"AccessibleWrap.cpp",
14+
"ApplicationAccessibleWrap.cpp",
15+
"AtkSocketAccessible.cpp",
16+
"DocAccessibleWrap.cpp",
17+
"DOMtoATK.cpp",
18+
"nsMaiHyperlink.cpp",
19+
"nsMaiInterfaceAction.cpp",
20+
"nsMaiInterfaceComponent.cpp",
21+
"nsMaiInterfaceDocument.cpp",
22+
"nsMaiInterfaceEditableText.cpp",
23+
"nsMaiInterfaceHyperlinkImpl.cpp",
24+
"nsMaiInterfaceHypertext.cpp",
25+
"nsMaiInterfaceImage.cpp",
26+
"nsMaiInterfaceSelection.cpp",
27+
"nsMaiInterfaceTable.cpp",
28+
"nsMaiInterfaceTableCell.cpp",
29+
"nsMaiInterfaceText.cpp",
30+
"nsMaiInterfaceValue.cpp",
31+
"Platform.cpp",
32+
"RootAccessibleWrap.cpp",
33+
"UtilInterface.cpp",
3434
]
3535

3636
LOCAL_INCLUDES += [
37-
'/accessible/base',
38-
'/accessible/generic',
39-
'/accessible/html',
40-
'/accessible/ipc',
41-
'/accessible/ipc/other',
42-
'/accessible/xpcom',
43-
'/accessible/xul',
44-
'/other-licenses/atk-1.0',
37+
"/accessible/base",
38+
"/accessible/generic",
39+
"/accessible/html",
40+
"/accessible/ipc",
41+
"/accessible/ipc/other",
42+
"/accessible/xpcom",
43+
"/accessible/xul",
44+
"/other-licenses/atk-1.0",
4545
]
4646

47-
FINAL_LIBRARY = 'xul'
47+
FINAL_LIBRARY = "xul"
4848

49-
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
50-
CFLAGS += CONFIG['TK_CFLAGS']
51-
CXXFLAGS += CONFIG['TK_CFLAGS']
49+
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
50+
CFLAGS += CONFIG["TK_CFLAGS"]
51+
CXXFLAGS += CONFIG["TK_CFLAGS"]
5252

53-
if CONFIG['MOZ_ENABLE_DBUS']:
54-
CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
53+
if CONFIG["MOZ_ENABLE_DBUS"]:
54+
CXXFLAGS += CONFIG["MOZ_DBUS_CFLAGS"]
5555

56-
include('/ipc/chromium/chromium-config.mozbuild')
56+
include("/ipc/chromium/chromium-config.mozbuild")
5757

58-
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
58+
if CONFIG["CC_TYPE"] in ("clang", "gcc"):
5959
# Used in G_DEFINE_TYPE_EXTENDED macro, probably fixed in newer glib /
6060
# gobject headers. See bug 1243331 comment 3.
6161
CXXFLAGS += [
62-
'-Wno-error=unused-function',
63-
'-Wno-error=shadow',
64-
'-Wno-unused-local-typedefs',
62+
"-Wno-error=unused-function",
63+
"-Wno-error=shadow",
64+
"-Wno-unused-local-typedefs",
6565
]

0 commit comments

Comments
 (0)