Skip to content

Commit 649156a

Browse files
Update prettier line length to 120 (from 180). (#10054)
As discussed with the team, we're going to try out a line length of 120. This change also removes all "prettier-ignore" directives.
1 parent faf4955 commit 649156a

File tree

896 files changed

+28970
-7212
lines changed

Some content is hidden

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

896 files changed

+28970
-7212
lines changed

.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
singleQuote: true,
3-
printWidth: 180,
3+
printWidth: 120,
44
tabWidth: 4,
55
overrides: [
66
{

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"typescript.preferences.quoteStyle": "single",
4242
"javascript.preferences.quoteStyle": "single",
4343
"typescriptHero.imports.stringQuoteStyle": "'",
44-
"prettier.printWidth": 180,
44+
"prettier.printWidth": 120,
4545
"prettier.singleQuote": true,
4646
"editor.codeActionsOnSave": {
4747
"source.fixAll.eslint": true,
@@ -54,7 +54,8 @@
5454
"python.linting.flake8Enabled": true,
5555
"cucumberautocomplete.skipDocStringsFormat": true,
5656
"python.linting.flake8Args": [
57-
"--max-line-length=120"
57+
// Match what black does.
58+
"--max-line-length=88"
5859
],
5960
"typescript.preferences.importModuleSpecifier": "relative"
6061
}

build/ci/performance/checkPerformanceResults.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ const path = require('path');
77
const constants = require('../../constants');
88

99
const xmlFile = path.join(constants.ExtensionRootDir, 'test-results.xml');
10-
const performanceResultsFile = path.join(constants.ExtensionRootDir, 'build', 'ci', 'performance', 'performance-results.json');
10+
const performanceResultsFile = path.join(
11+
constants.ExtensionRootDir,
12+
'build',
13+
'ci',
14+
'performance',
15+
'performance-results.json'
16+
);
1117
const errorMargin = 0.01;
1218
let failedTests = '';
1319

@@ -40,12 +46,29 @@ fs.readFile(xmlFile, 'utf8', (xmlFileError, xmlData) => {
4046

4147
// compare the average result to the base JSON
4248
if (testcase && avg > parseFloat(testcase.time) + errorMargin) {
43-
failedTests += 'Performance is slow in: ' + testcase.name + ', Benchmark time: ' + testcase.time + ', Average test time: ' + avg + '\n';
49+
failedTests +=
50+
'Performance is slow in: ' +
51+
testcase.name +
52+
', Benchmark time: ' +
53+
testcase.time +
54+
', Average test time: ' +
55+
avg +
56+
'\n';
4457
}
4558
} else {
4659
// compare the average result to the base JSON
47-
if (suite.testcase.name === result.name && avg > parseFloat(suite.testcase.time) + errorMargin) {
48-
failedTests += 'Performance is slow in: ' + testcase.name + ', Benchmark time: ' + testcase.time + ', Average test time: ' + avg + '\n';
60+
if (
61+
suite.testcase.name === result.name &&
62+
avg > parseFloat(suite.testcase.time) + errorMargin
63+
) {
64+
failedTests +=
65+
'Performance is slow in: ' +
66+
testcase.name +
67+
', Benchmark time: ' +
68+
testcase.time +
69+
', Average test time: ' +
70+
avg +
71+
'\n';
4972
}
5073
}
5174
}

build/ci/postInstall.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ var constants_1 = require('../constants');
1414
* The solution is to modify the type definition file after `npm install`.
1515
*/
1616
function fixJupyterLabDTSFiles() {
17-
var relativePath = path.join('node_modules', '@jupyterlab', 'services', 'node_modules', '@jupyterlab', 'coreutils', 'lib', 'settingregistry.d.ts');
17+
var relativePath = path.join(
18+
'node_modules',
19+
'@jupyterlab',
20+
'services',
21+
'node_modules',
22+
'@jupyterlab',
23+
'coreutils',
24+
'lib',
25+
'settingregistry.d.ts'
26+
);
1827
var filePath = path.join(constants_1.ExtensionRootDir, relativePath);
1928
if (!fs.existsSync(filePath)) {
2029
throw new Error("Type Definition file from JupyterLab not found '" + filePath + "' (pvsc post install script)");

build/webpack/loaders/fixNodeFetch.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
const path = require('path');
77
const constants = require('../../constants');
88

9-
const nodeFetchIndexFile = path.join(constants.ExtensionRootDir, 'node_modules', '@jupyterlab', 'services', 'node_modules', 'node-fetch', 'lib', 'index.js');
9+
const nodeFetchIndexFile = path.join(
10+
constants.ExtensionRootDir,
11+
'node_modules',
12+
'@jupyterlab',
13+
'services',
14+
'node_modules',
15+
'node-fetch',
16+
'lib',
17+
'index.js'
18+
);
1019
// On windows replace `\` with `\\`, else we get an error in webpack (Module parse failed: Octal literal in strict mode).
1120
const nodeFetchFile = constants.isWindows ? nodeFetchIndexFile.replace(/\\/g, '\\\\') : nodeFetchIndexFile;
1221

build/webpack/plugins/less-plugin-base64.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ class Base64Visitor {
3232
visitUrl(URLNode, visitArgs) {
3333
// Return two new nodes in the call. One that has the mime type and other with the node. The data-uri
3434
// evaluator will transform this into a base64 string
35-
return new less.tree.Call('data-uri', [new Base64MimeTypeNode(), URLNode.value], URLNode.index || 0, URLNode.currentFileInfo);
35+
return new less.tree.Call(
36+
'data-uri',
37+
[new Base64MimeTypeNode(), URLNode.value],
38+
URLNode.index || 0,
39+
URLNode.currentFileInfo
40+
);
3641
}
3742
}
3843
/*

build/webpack/webpack.datascience-ui.config.builder.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ function buildConfiguration(isNotebook) {
129129
// `module.resource` contains the absolute path of the file on disk.
130130
// Look for `node_modules/monaco...`.
131131
const path = require('path');
132-
return module.resource && module.resource.includes(`${path.sep}node_modules${path.sep}@nteract`);
132+
return (
133+
module.resource &&
134+
module.resource.includes(`${path.sep}node_modules${path.sep}@nteract`)
135+
);
133136
}
134137
},
135138
// Bundling `plotly` with nteract isn't the best option, as this plotly alone is 6mb.
@@ -142,7 +145,9 @@ function buildConfiguration(isNotebook) {
142145
// `module.resource` contains the absolute path of the file on disk.
143146
// Look for `node_modules/monaco...`.
144147
const path = require('path');
145-
return module.resource && module.resource.includes(`${path.sep}node_modules${path.sep}plotly`);
148+
return (
149+
module.resource && module.resource.includes(`${path.sep}node_modules${path.sep}plotly`)
150+
);
146151
}
147152
},
148153
// Monaco is a monster. For SSH again, we pull this into a seprate bundle.
@@ -157,7 +162,9 @@ function buildConfiguration(isNotebook) {
157162
// `module.resource` contains the absolute path of the file on disk.
158163
// Look for `node_modules/monaco...`.
159164
const path = require('path');
160-
return module.resource && module.resource.includes(`${path.sep}node_modules${path.sep}monaco`);
165+
return (
166+
module.resource && module.resource.includes(`${path.sep}node_modules${path.sep}monaco`)
167+
);
161168
}
162169
}
163170
}

build/webpack/webpack.extension.dependencies.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ const config = {
4343
// 'find' the calling extension.
4444
new copyWebpackPlugin([{ from: './package.json', to: '.' }]),
4545
// onigasm requires our onigasm.wasm to be in node_modules
46-
new copyWebpackPlugin([{ from: './node_modules/onigasm/lib/onigasm.wasm', to: './node_modules/onigasm/lib/onigasm.wasm' }])
46+
new copyWebpackPlugin([
47+
{ from: './node_modules/onigasm/lib/onigasm.wasm', to: './node_modules/onigasm/lib/onigasm.wasm' }
48+
])
4749
],
4850
resolve: {
4951
alias: {

pythonFiles/testing_tools/adapter/__main__.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@
2222

2323

2424
def parse_args(
25-
argv=sys.argv[1:], prog=sys.argv[0],
25+
# the args to parse
26+
argv=sys.argv[1:],
27+
# the program name
28+
prog=sys.argv[0],
2629
):
2730
"""
2831
Return the subcommand & tool to run, along with its args.
2932
3033
This defines the standard CLI for the different testing frameworks.
3134
"""
3235
parser = argparse.ArgumentParser(
33-
description="Run Python testing operations.", prog=prog,
36+
description="Run Python testing operations.",
37+
prog=prog,
38+
# ...
3439
)
3540
cmdsubs = parser.add_subparsers(dest="cmd")
3641

@@ -72,7 +77,15 @@ def parse_args(
7277
return tool, cmd, ns, toolargs
7378

7479

75-
def main(toolname, cmdname, subargs, toolargs, _tools=TOOLS, _reporters=REPORTERS):
80+
def main(
81+
toolname,
82+
cmdname,
83+
subargs,
84+
toolargs,
85+
# internal args (for testing):
86+
_tools=TOOLS,
87+
_reporters=REPORTERS,
88+
):
7689
try:
7790
tool = _tools[toolname]
7891
except KeyError:

pythonFiles/testing_tools/adapter/discovery.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323

2424

2525
def fix_nodeid(
26-
nodeid, kind, rootdir=None, _fix_fileid=fix_fileid, # *,
26+
nodeid,
27+
kind,
28+
rootdir=None,
29+
# *,
30+
_fix_fileid=fix_fileid,
2731
):
2832
if not nodeid:
2933
raise ValueError("missing nodeid")
@@ -58,7 +62,9 @@ def __getitem__(self, index):
5862
@property
5963
def parents(self):
6064
return sorted(
61-
self._parents.values(), key=lambda p: (NORMCASE(p.root or p.name), p.id),
65+
self._parents.values(),
66+
# Sort by (name, id).
67+
key=lambda p: (NORMCASE(p.root or p.name), p.id),
6268
)
6369

6470
def reset(self):
@@ -73,12 +79,18 @@ def add_test(self, test, parents):
7379
# provided test and parents (from the test collector) are
7480
# properly generated. However, we play it safe here.
7581
test = test._replace(
76-
id=fix_nodeid(test.id, "test", test.path.root), parentid=parentid,
82+
# Clean up the ID.
83+
id=fix_nodeid(test.id, "test", test.path.root),
84+
parentid=parentid,
7785
)
7886
self._tests.append(test)
7987

8088
def _ensure_parent(
81-
self, path, parents, _dirname=DIRNAME, # *,
89+
self,
90+
path,
91+
parents,
92+
# *,
93+
_dirname=DIRNAME,
8294
):
8395
rootdir = path.root
8496
relpath = path.relfile

pythonFiles/testing_tools/adapter/pytest/_discovery.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212

1313

1414
def discover(
15-
pytestargs=None, hidestdio=False, _pytest_main=pytest.main, _plugin=None, **_ignored
15+
pytestargs=None,
16+
hidestdio=False,
17+
# *,
18+
_pytest_main=pytest.main,
19+
_plugin=None,
20+
**_ignored
1621
):
1722
"""Return the results of test discovery."""
1823
if _plugin is None:
@@ -29,7 +34,7 @@ def discover(
2934
pass
3035
elif ec != 0:
3136
print(
32-
("equivalent command: {} -m pytest {}").format(
37+
"equivalent command: {} -m pytest {}".format(
3338
sys.executable, util.shlex_unsplit(pytestargs)
3439
)
3540
)
@@ -39,7 +44,7 @@ def discover(
3944
raise Exception("pytest discovery failed (exit code {})".format(ec))
4045
if not _plugin._started:
4146
print(
42-
("equivalent command: {} -m pytest {}").format(
47+
"equivalent command: {} -m pytest {}".format(
4348
sys.executable, util.shlex_unsplit(pytestargs)
4449
)
4550
)

0 commit comments

Comments
 (0)