Skip to content

Commit 065d2eb

Browse files
author
Ricky Stewart
committedOct 23, 2020
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. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat. 5. 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 aec3b02 commit 065d2eb

File tree

3,432 files changed

+164855
-129257
lines changed

Some content is hidden

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

3,432 files changed

+164855
-129257
lines changed
 

‎.ycm_extra_conf.py

+16-17
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

+26-25
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"]

0 commit comments

Comments
 (0)
Failed to load comments.