8000 Add additional pre-commit hooks (#245) · wolfmib/pyscript_tutorial@cc6d624 · GitHub
[go: up one dir, main page]

Skip to content

Commit cc6d624

Browse files
authored
Add additional pre-commit hooks (pyscript#245)
* Add and run end-of-file-fixer * Add and run trailing-whitespace * Add and run check-yaml * Add and run check-json * Add and run pretty-format-yaml * Fix comment indentation
1 parent 3347532 commit cc6d624

30 files changed

+172
-158
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
name: Build
22

33
on:
4-
push: # Only run on merges into master that modify files under pyscriptjs/
5-
branches: main
6-
paths:
7-
- pyscriptjs/**
8-
- .github/workflows/** # Test that workflows work when changed
4+
push: # Only run on merges into master that modify files under pyscriptjs/
5+
branches: main
6+
paths:
7+
- pyscriptjs/**
8+
- .github/workflows/** # Test that workflows work when changed
99

10-
pull_request: # Run on any PR that modifies files in pyscriptjs/
11-
paths:
12-
- pyscriptjs/**
13-
- .github/workflows/**
10+
pull_request: # Run on any PR that modifies files in pyscriptjs/
11+
paths:
12+
- pyscriptjs/**
13+
- .github/workflows/**
1414

1515
jobs:
16-
build:
17-
runs-on: ubuntu-latest # Will be self hosted soon
18-
defaults:
19-
run:
20-
working-directory: ./pyscriptjs
16+
build:
17+
runs-on: ubuntu-latest # Will be self hosted soon
18+
defaults:
19+
run:
20+
working-directory: ./pyscriptjs
2121

22-
steps:
23-
- name: Checkout
24-
uses: actions/checkout@v3
25-
- name: Install node
26-
uses: actions/setup-node@v3
27-
with:
28-
node-version: '12.x'
29-
- name: Cache node modules
30-
uses: actions/cache@v3
31-
env:
32-
cache-name: cache-node-modules
33-
with:
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
- name: Install node
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: 12.x
29+
- name: Cache node modules
30+
uses: actions/cache@v3
31+
env:
32+
cache-name: cache-node-modules
33+
with:
3434
# npm cache files are stored in `~/.npm` on Linux/macOS
35-
path: ~/.npm
36-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
37-
restore-keys: |
38-
${{ runner.os }}-build-${{ env.cache-name }}-
39-
${{ runner.os }}-build-
40-
${{ runner.os }}-
41-
- name: Install dependencies
42-
run: |
43-
npm install
44-
- name: Build pyscript
45-
run: |
46-
npm run build
35+
path: ~/.npm
36+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
37+
restore-keys: |
38+
${{ runner.os }}-build-${{ env.cache-name }}-
39+
${{ runner.os }}-build-
40+
${{ runner.os }}-
41+
- name: Install dependencies
42+
run: |
43+
npm install
44+
- name: Build pyscript
45+
run: |
46+
npm run build

.github/workflows/lint.yml

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
name: Lint
22

33
on:
4+
push: # Only run on merges into master that modify files under pyscriptjs/
5+
branches:
6+
- main
47

5-
push: # Only run on merges into master that modify files under pyscriptjs/
6-
branches:
7-
- main
8-
9-
pull_request: # Run on any PR that modifies files in pyscriptjs/
8+
pull_request: # Run on any PR that modifies files in pyscriptjs/
109

1110
jobs:
12-
build:
13-
runs-on: ubuntu-latest
14-
defaults:
15-
run:
16-
working-directory: ./pyscriptjs
17-
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v3
20-
- name: Install node
21-
uses: actions/setup-node@v3
22-
with:
23-
node-version: '12.x'
24-
- name: Cache node modules
25-
uses: actions/cache@v3
26-
env:
27-
cache-name: cache-node-modules
28-
with:
11+
build:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: ./pyscriptjs
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
- name: Install node
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: 12.x
23+
- name: Cache node modules
24+
uses: actions/cache@v3
25+
env:
26+
cache-name: cache-node-modules
27+
with:
2928
# npm cache files are stored in `~/.npm` on Linux/macOS
30-
path: ~/.npm
31-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
32-
restore-keys: |
33-
${{ runner.os }}-build-${{ env.cache-name }}-
34-
${{ runner.os }}-build-
35-
${{ runner.os }}-
36-
- name: Install dependencies
37-
run: |
38-
npm install
39-
- name: Run linter
40-
run: |
41-
npm run lint
29+
path: ~/.npm
30+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
31+
restore-keys: |
32+
${{ runner.os }}-build-${{ env.cache-name }}-
33+
${{ runner.os }}-build-
34+
${{ runner.os }}-
35+
- name: Install dependencies
36+
run: |
37+
npm install
38+
- name: Run linter
39+
run: |
40+
npm run lint

.pre-commit-config.yaml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
1+
# This is the configuration for pre-commit, a local framework for managing pre-commit hooks
2+
# Check out the docs at: https://pre-commit.com/
3+
14
default_stages: [commit]
25
repos:
3-
- repo: https://github.com/psf/black
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v4.2.0
8+
hooks:
9+
- id: end-of-file-fixer
10+
exclude: \.min\.js$
11+
- id: trailing-whitespace
12+
- id: check-json
13+
exclude: tsconfig.json
14+
- id: check-yaml
15+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
16+
rev: v2.3.0
17+
hooks:
18+
- id: pretty-format-yaml
19+
args: [--autofix, --indent, '4']
20+
- repo: https://github.com/psf/black
421
rev: 22.3.0
522
hooks:
6-
- id: black
7-
- repo: https://github.com/pycqa/isort
23+
- id: black
24+
- repo: https://github.com/pycqa/isort
825
rev: 5.10.1
926
hooks:
10-
- id: isort
27+
- id: isort
1128
name: isort (python)
1229
args: [--profile, black]

GETTING-STARTED.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ HTML head. You can also link to `.whl` files directly on disk like in our [toga
124124
</py-env>
125125
```
126126

127-
If your `.whl` is not a pure Python wheel, then open a PR or issue with [pyodide](https://github.com/pyodide/pyodide) to get it added [here](https://github.com/pyodide/pyodide/tree/main/packages).
127+
If your `.whl` is not a pure Python wheel, then open a PR or issue with [pyodide](https://github.com/pyodide/pyodide) to get it added [here](https://github.com/pyodide/pyodide/tree/main/packages).
128128
If there's enough popular demand the pyodide team will likely work on supporting your package, regardless things will likely move faster if you make the PR and consult with the team to get unblocked.
129129

130130
For example, NumPy and Matplotlib are available. Notice here we're using `<py-script output="plot">`
@@ -208,4 +208,3 @@ fig
208208
</body>
209209
</html>
210210
```
211-

pyscriptjs/.eslintrc.js

+1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ module.exports = {
4343
'@typescript-eslint/restrict-plus-operands': 'warn',
4444
'@typescript-eslint/no-empty-function': 'warn',
4545
},
46-
};
46+
};

pyscriptjs/.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ node_modules
33

44

55
# Ignore all HTML files
6-
*.html
6+
*.html

pyscriptjs/.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ module.exports = {
1010
svelteIndentScriptAndStyle: true,
1111
tabWidth: 4,
1212
trailingComma: 'all',
13-
}
13+
}

pyscriptjs/environment.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
channels:
2-
- defaults
3-
- conda-forge
2+
- defaults
3+
- conda-forge
44
dependencies:
5-
- python=3.9
6-
- pip=20.2.2
7-
- pytest=7
8-
- nodejs=16
9-
- black
10-
- isort
11-
- codespell
12-
- pre-commit
5+
- python=3.9
6+
- pip=20.2.2
7+
- pytest=7
8+
- nodejs=16
9+
- black
10+
- isort
11+
- codespell
12+
- pre-commit

pyscriptjs/examples/bokeh.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
Bokeh.set_log_level("info");
1313
</script>
1414
<link rel="stylesheet" href="../build/pyscript.css" />
15-
15+
1616
<script defer src="../build/pyscript.js"></script>
17-
17+
1818
</head>
1919
<body>
2020
<py-env>
@@ -23,7 +23,7 @@
2323
</py-env>
2424
<h1>Bokeh Example</h1>
2525
<div id="myplot"></div>
26-
26+
2727
<py-script id="main">
2828
import json
2929
import pyodide
@@ -43,6 +43,6 @@ <h1>Bokeh Example</h1>
4343

4444
Bokeh.embed.embed_item(JSON.parse(p_json))
4545
</py-script>
46-
46+
4747
</body>
4848
</html>

pyscriptjs/examples/bokeh_interactive.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
Bokeh.set_log_level("info");
1313
</script>
1414
<link rel="stylesheet" href="../build/pyscript.css" />
15-
15+
1616
<script defer src="../build/pyscript.js"></script>
17-
17+
1818
</head>
1919
<body>
2020
<py-env>
@@ -23,7 +23,7 @@
2323
</py-env>
2424
<h1>Bokeh Example</h1>
2525
<div id="myplot"></div>
26-
26+
2727
<py-script id="main">
2828
import asyncio
2929
import json
@@ -93,6 +93,6 @@ <h1>Bokeh Example</h1>
9393

9494
await show(row, 'myplot')
9595
</py-script>
96-
96+
9797
</body>
9898
</html>

pyscriptjs/examples/folium.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import folium
1717
import json
1818
import pandas as pd
19-
19+
2020
from pyodide.http import open_url
2121

2222
url = (

pyscriptjs/examples/handtrack/say_hello.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<link rel="icon" type="image/png" href="favicon.png" />
1010
<link rel="stylesheet" href="../../build/pyscript.css" />
11-
11+
1212
<script defer src="../../build/pyscript.js"></script>
1313
</head>
1414

@@ -40,7 +40,7 @@
4040
handTrack.stopVideo(video.element)
4141
isVideo = False
4242
update_note.write("Video stopped")
43-
43+
4444
async def start_video():
4545
global isVideo
4646
update_note.write("Inside sstart video")
@@ -61,9 +61,9 @@
6161
console.log("in RUN DETECTION: ");
6262
global model
6363
global isVideo
64-
64+
6565
console.log("...1")
66-
66+
6767
predictions = await model.detect(video.element)
6868
console.log("done...1")
6969
console.log("Predictions: ", predictions);

pyscriptjs/examples/hello_world.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<link rel="icon" type="image/png" href="favicon.png" />
1010
<link rel="stylesheet" href="../build/pyscript.css" />
11-
11+
1212
<script defer src="../build/pyscript.js"></script>
1313
</head>
1414

pyscriptjs/examples/mario/js/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
Surrogate.prototype = superclass.prototype;
1212
subclass.prototype = new Surrogate();
1313
}
14-
})()
14+
})()

pyscriptjs/examples/mario/play_mario.html

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

99
<link rel="icon" type="image/png" href="../favicon.png" />
1010
<link rel="stylesheet" href="../../build/pyscript.css" />
11-
11+
1212
<script defer src="../../build/pyscript.js"></script>
1313
</head>
1414

@@ -69,7 +69,7 @@
6969
handTrack.stopVideo(video.element)
7070
isVideo = False
7171
update_note.write("Video stopped")
72-
72+
7373
async def start_video():
7474
global isVideo
7575
update_note.write("Inside sstart video")
@@ -91,7 +91,7 @@
9191
global isVideo
9292
global last_position
9393
global direction
94-
94+
9595
predictions = await model.detect(video.element)
9696
model.renderPredictions(predictions, canvas.element, context, video.element);
9797

0 commit comments

Comments
 (0)
0