Skip to content

Commit

Permalink
feat: integrate pyodide helper (#206)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Apr 27, 2024
1 parent b8fbb3b commit a44780c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 0 additions & 3 deletions docs/webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,9 @@ class App extends React.Component {
var families_checks;
try {
families_checks = pyodide.runPython(`
from pyodide.http import open_url
from repo_review.processor import process, md_as_html
from repo_review.ghpath import GHPath
GHPath.open_url = staticmethod(open_url)
package = GHPath(repo="${state.repo}", branch="${state.branch}")
result = process(package)
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ disallow_untyped_defs = true


[tool.pylint]
master.py-version = "3.10"
master.ignore-paths= ["src/repo_review/_version.py"]
py-version = "3.10"
ignore-paths = ["src/repo_review/_version.py"]
ignored-modules = ["pyodide"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
messages_control.disable = [
Expand All @@ -131,6 +132,7 @@ messages_control.disable = [
"no-member", # better handled by mypy, etc.
"used-before-assignment", # False positive on conditional import
"unnecessary-ellipsis", # Not correct for typing
"import-outside-toplevel", # better handled elsewhere
]


Expand Down
8 changes: 7 additions & 1 deletion src/repo_review/ghpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import dataclasses
import io
import json
import sys
import typing
from collections.abc import Iterator
from typing import Literal
Expand Down Expand Up @@ -47,7 +48,12 @@ class GHPath(Traversable):

@staticmethod
def open_url(url: str) -> io.StringIO:
"This method can be overridden for pyodide with pyodide.open_url"
"This method can be overridden manually for WASM. Supports pyodide currently."
if sys.platform == "emscripten":
import pyodide.http

return pyodide.http.open_url(url)

import urllib.request # pylint: disable=import-outside-toplevel

with urllib.request.urlopen(url) as response:
Expand Down

0 comments on commit a44780c

Please sign in to comment.