Skip to content

Commit f3dc902

Browse files
author
Hood Chatham
authored
Apply lints suggested by lgtm.com (pyodide#1398)
1 parent f011af9 commit f3dc902

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

conftest.py

-2
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,6 @@ def run_web_server(q, log_filepath, build_dir):
409409
sys.stdout = log_fh
410410
sys.stderr = log_fh
411411

412-
test_prefix = "/src/tests/"
413-
414412
class Handler(http.server.SimpleHTTPRequestHandler):
415413
def log_message(self, format_, *args):
416414
print(

lgtm.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
queries:
2+
- exclude: py/import-and-import-from
3+
4+
extraction:
5+
cpp:
6+
prepare:
7+
packages:
8+
- python3-yaml

pyodide_build/mkpkg.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ def _extract_sdist(pypi_metadata: Dict[str, Any]) -> Dict:
3636
)
3737

3838

39-
def _get_metadata(package: str) -> Tuple[Dict, Dict]:
39+
def _get_metadata(package: str, version: Optional[str] = None) -> Tuple[Dict, Dict]:
4040
"""Download metadata for a package from PyPi"""
41-
url = f"https://pypi.org/pypi/{package}/json"
41+
version = ("/" + version) if version is not None else ""
42+
url = f"https://pypi.org/pypi/{package}{version}/json"
4243

4344
with urllib.request.urlopen(url) as fd:
4445
pypi_metadata = json.load(fd)
@@ -55,13 +56,7 @@ def make_package(package: str, version: Optional[str] = None):
5556
"""
5657
import yaml
5758

58-
version = ("/" + version) if version is not None else ""
59-
url = f"https://pypi.org/pypi/{package}{version}/json"
60-
61-
with urllib.request.urlopen(url) as fd:
62-
json_content = json.load(fd)
63-
64-
sdist_metadata, pypi_metadata = _get_metadata(package)
59+
sdist_metadata, pypi_metadata = _get_metadata(package, version)
6560
url = sdist_metadata["url"]
6661
sha256 = sdist_metadata["digests"]["sha256"]
6762
version = pypi_metadata["info"]["version"]
@@ -141,8 +136,9 @@ def make_parser(parser):
141136
def main(args):
142137
package = args.package[0]
143138
if args.update:
144-
return update_package(package)
145-
return make_package(package, args.version)
139+
update_package(package)
140+
return
141+
make_package(package, args.version)
146142

147143

148144
if __name__ == "__main__":

pyodide_build/pywasmcross.py

-2
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ def handle_command(line, args, dryrun=False):
273273
optflag = arg
274274
break
275275

276-
lapack_dir = None
277-
278276
used_libs = set()
279277

280278
# Go through and adjust arguments

src/pyodide-py/pyodide/webloop.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
from asyncio import tasks, futures
32
import time
43
import contextvars
54

@@ -136,7 +135,7 @@ def call_later(
136135

137136
if delay < 0:
138137
raise ValueError("Can't schedule in the past")
139-
h = asyncio.Handle(callback, args, self, context=context)
138+
h = asyncio.Handle(callback, args, self, context=context) # type: ignore
140139
setTimeout(create_once_callable(h._run), delay * 1000)
141140
return h
142141

@@ -177,7 +176,7 @@ def create_future(self):
177176
178177
Copied from ``BaseEventLoop.create_future``
179178
"""
180-
return futures.Future(loop=self)
179+
return asyncio.futures.Future(loop=self)
181180

182181
def create_task(self, coro, *, name=None):
183182
"""Schedule a coroutine object.
@@ -188,15 +187,15 @@ def create_task(self, coro, *, name=None):
188187
"""
189188
self._check_closed()
190189
if self._task_factory is None:
191-
task = tasks.Task(coro, loop=self, name=name)
190+
task = asyncio.tasks.Task(coro, loop=self, name=name)
192191
if task._source_traceback:
193192
# Added comment:
194193
# this only happens if get_debug() returns True.
195194
# In that case, remove create_task from _source_traceback.
196195
del task._source_traceback[-1]
197196
else:
198197
task = self._task_factory(self, coro)
199-
tasks._set_task_name(task, name)
198+
asyncio.tasks._set_task_name(task, name)
200199

201200
return task
202201

src/pyodide.js

+18-17
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ globalThis.languagePluginLoader = (async () => {
5454
} else if (self.importScripts) { // webworker
5555
loadScript = async (url) => { // This is async only for consistency
5656
self.importScripts(url);
57-
}
57+
};
5858
} else {
5959
throw new Error("Cannot determine runtime environment");
6060
}
@@ -97,7 +97,7 @@ globalThis.languagePluginLoader = (async () => {
9797
}
9898
}
9999
if (sharedLibsOnly) {
100-
onlySharedLibs = new Map();
100+
let onlySharedLibs = new Map();
101101
for (let c of toLoad) {
102102
if (c[0] in sharedLibraries) {
103103
onlySharedLibs.set(c[0], toLoad.get(c[0]));
@@ -129,7 +129,8 @@ globalThis.languagePluginLoader = (async () => {
129129
if (toLoad.size === 0) {
130130
return Promise.resolve('No new packages to load');
131131
} else {
132-
messageCallback(`Loading ${[...toLoad.keys()].join(', ')}`)
132+
let packageNames = Array.from(toLoad.keys()).join(', ');
133+
messageCallback(`Loading ${packageNames}`);
133134
}
134135

135136
// If running in main browser thread, try to catch errors thrown when
@@ -170,9 +171,11 @@ globalThis.languagePluginLoader = (async () => {
170171
messageCallback(`${pkg} already loaded from ${loaded}`);
171172
continue;
172173
} else {
173-
errorCallback(`URI mismatch, attempting to load package ${pkg} from ${
174-
uri} while it is already loaded from ${
175-
loaded}. To override a dependency, load the custom package first.`);
174+
errorCallback(
175+
`URI mismatch, attempting to load package ${pkg} from ${uri} ` +
176+
`while it is already loaded from ${
177+
loaded}. To override a dependency, ` +
178+
`load the custom package first.`);
176179
continue;
177180
}
178181
}
@@ -225,8 +228,8 @@ globalThis.languagePluginLoader = (async () => {
225228

226229
let resolveMsg;
227230
if (packageList.length > 0) {
228-
let package_names = packageList.join(', ');
229-
resolveMsg = `Loaded ${packageList}`;
231+
let packageNames = packageList.join(', ');
232+
resolveMsg = `Loaded ${packageNames}`;
230233
} else {
231234
resolveMsg = 'No packages loaded';
232235
}
@@ -268,18 +271,17 @@ globalThis.languagePluginLoader = (async () => {
268271
* messages (optional)
269272
* @returns {Promise} Resolves to ``undefined`` when loading is complete
270273
*/
271-
Module.loadPackage =
272-
async function(names, messageCallback, errorCallback) {
274+
Module.loadPackage = async function(names, messageCallback, errorCallback) {
273275
if (!Array.isArray(names)) {
274276
names = [ names ];
275277
}
276278
// get shared library packages and load those first
277279
// otherwise bad things happen with linking them in firefox.
278-
sharedLibraryNames = [];
280+
let sharedLibraryNames = [];
279281
try {
280-
sharedLibraryPackagesToLoad =
282+
let sharedLibraryPackagesToLoad =
281283
recursiveDependencies(names, messageCallback, errorCallback, true);
282-
for (pkg of sharedLibraryPackagesToLoad) {
284+
for (let pkg of sharedLibraryPackagesToLoad) {
283285
sharedLibraryNames.push(pkg[0]);
284286
}
285287
} catch (e) {
@@ -332,7 +334,7 @@ globalThis.languagePluginLoader = (async () => {
332334
errorCallback || console.error));
333335
loadPackageChain = loadPackageChain.then(() => promise.catch(() => {}));
334336
await promise;
335-
}
337+
};
336338

337339
////////////////////////////////////////////////////////////
338340
// Fix Python recursion limit
@@ -425,7 +427,7 @@ globalThis.languagePluginLoader = (async () => {
425427
continue;
426428
}
427429
if (typeof (value) === "function") {
428-
Module.public_api[key] = function() { throw Error(fatal_error_msg); }
430+
Module.public_api[key] = function() { throw Error(fatal_error_msg); };
429431
}
430432
}
431433
} catch (_) {
@@ -658,12 +660,11 @@ globalThis.languagePluginLoader = (async () => {
658660
let QUOTE = 3;
659661
let QUOTE_ESCAPE = 4;
660662
let paren_depth = 0;
661-
let arg_start = 0;
662663
let arg_is_obj_dest = false;
663664
let quote_start = undefined;
664665
let state = START_ARG;
665666
// clang-format off
666-
for (i = idx; i < funcstr.length; i++) {
667+
for (let i = idx; i < funcstr.length; i++) {
667668
let x = funcstr[i];
668669
if(state === QUOTE){
669670
switch(x){

0 commit comments

Comments
 (0)