Skip to content

Commit 79299f9

Browse files
authored
Merge pull request #531 from adrn/pre-commit
Add pre-commit config
2 parents 675e10f + 0df1210 commit 79299f9

28 files changed

+74
-318
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ updates:
33
- package-ecosystem: "github-actions"
44
directory: "/"
55
schedule:
6-
interval: "weekly"
6+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ jobs:
2525
run: |
2626
sudo apt-get install pandoc
2727
python -m pip install -U pip
28-
python -m pip install -r requirements.txt
29-
python -m pip install git+https://github.com/astropy/nbcollection
28+
python -m pip install -r requirements-dev.txt
3029
3130
- name: Execute the notebooks
3231
run: |

.github/workflows/prs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ jobs:
2929
run: |
3030
sudo apt-get install pandoc
3131
python -m pip install -U pip
32-
python -m pip install -r requirements.txt
33-
python -m pip install gitpython
34-
python -m pip install git+https://github.com/astropy/nbcollection
32+
python -m pip install -r requirements-dev.txt
3533
3634
# Run all tutorials if the label is present
3735
- name: Run all tutorials

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
exclude: '.*\.fits$'
9+
- id: end-of-file-fixer
10+
exclude_types: [csv]
11+
exclude: '.*\.fits$'
12+
- id: check-yaml
13+
- id: check-added-large-files
14+
- repo: https://github.com/kynan/nbstripout
15+
rev: 0.5.0
16+
hooks:
17+
- id: nbstripout
18+
args: ["--extra-keys='metadata.kernelspec metadata.language_info.version metadata.toc'"]

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ MODIFIED := $(shell python .github/get_modified_tutorials.py --main-branch $(TUT
66
FLAGS = --flatten --build-path=. -v
77
CONVERTFLAGS = --make-index --preprocessors=nbconvert.preprocessors.ExtractOutputPreprocessor --index-template=templates/index.tpl
88

9+
init:
10+
python -m pip install -U -r requirements-dev.txt
11+
pre-commit install
12+
913
build: envcheck execute convert
1014
buildall: envcheck executeall convertall
1115

@@ -27,4 +31,4 @@ convertall:
2731
clean:
2832
rm -rf _build
2933

30-
.PHONY: all clean execute convert executeall convertall build buildall
34+
.PHONY: init all clean execute convert executeall convertall build buildall

requirements-dev.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-r requirements.txt
2+
gitpython
3+
git+https://github.com/astropy/nbcollection
4+
pre-commit

templates/index.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
{% endfor %}
1212
</ul>
1313
</body>
14-
</html>
14+
</html>

tutorials/FITS-cubes/FITS-cubes.ipynb

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,6 @@
825825
}
826826
],
827827
"metadata": {
828-
"kernelspec": {
829-
"display_name": "Python 3",
830-
"language": "python",
831-
"name": "python3"
832-
},
833828
"language_info": {
834829
"codemirror_mode": {
835830
"name": "ipython",
@@ -839,21 +834,7 @@
839834
"mimetype": "text/x-python",
840835
"name": "python",
841836
"nbconvert_exporter": "python",
842-
"pygments_lexer": "ipython3",
843-
"version": "3.8.3"
844-
},
845-
"toc": {
846-
"base_numbering": 1,
847-
"nav_menu": {},
848-
"number_sections": true,
849-
"sideBar": true,
850-
"skip_h1_title": false,
851-
"title_cell": "Table of Contents",
852-
"title_sidebar": "Contents",
853-
"toc_cell": false,
854-
"toc_position": {},
855-
"toc_section_display": true,
856-
"toc_window_display": false
837+
"pygments_lexer": "ipython3"
857838
}
858839
},
859840
"nbformat": 4,

tutorials/FITS-header/FITS-header.ipynb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@
6464
{
6565
"cell_type": "code",
6666
"execution_count": null,
67-
"metadata": {
68-
"scrolled": true
69-
},
67+
"metadata": {},
7068
"outputs": [],
7169
"source": [
7270
"hdu_number = 0 # HDU means header data unit\n",
@@ -244,11 +242,6 @@
244242
"name": "",
245243
"published": true
246244
},
247-
"kernelspec": {
248-
"display_name": "Python 3",
249-
"language": "python",
250-
"name": "python3"
251-
},
252245
"language_info": {
253246
"codemirror_mode": {
254247
"name": "ipython",
@@ -258,8 +251,7 @@
258251
"mimetype": "text/x-python",
259252
"name": "python",
260253
"nbconvert_exporter": "python",
261-
"pygments_lexer": "ipython3",
262-
"version": "3.6.7"
254+
"pygments_lexer": "ipython3"
263255
}
264256
},
265257
"nbformat": 4,

tutorials/FITS-images/FITS-images.ipynb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,6 @@
451451
"name": "",
452452
"published": true
453453
},
454-
"kernelspec": {
455-
"display_name": "Python 3",
456-
"language": "python",
457-
"name": "python3"
458-
},
459454
"language_info": {
460455
"codemirror_mode": {
461456
"name": "ipython",
@@ -465,8 +460,7 @@
465460
"mimetype": "text/x-python",
466461
"name": "python",
467462
"nbconvert_exporter": "python",
468-
"pygments_lexer": "ipython3",
469-
"version": "3.6.7"
463+
"pygments_lexer": "ipython3"
470464
}
471465
},
472466
"nbformat": 4,

tutorials/FITS-tables/FITS-tables.ipynb

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
{
2828
"cell_type": "code",
2929
"execution_count": null,
30-
"metadata": {
31-
"collapsed": true
32-
},
30+
"metadata": {},
3331
"outputs": [],
3432
"source": [
3533
"import numpy as np\n",
@@ -52,9 +50,7 @@
5250
{
5351
"cell_type": "code",
5452
"execution_count": null,
55-
"metadata": {
56-
"collapsed": true
57-
},
53+
"metadata": {},
5854
"outputs": [],
5955
"source": [
6056
"from astropy.utils.data import download_file"
@@ -96,9 +92,7 @@
9692
{
9793
"cell_type": "code",
9894
"execution_count": null,
99-
"metadata": {
100-
"collapsed": true
101-
},
95+
"metadata": {},
10296
"outputs": [],
10397
"source": [
10498
"hdu_list = fits.open(event_filename, memmap=True)"
@@ -146,9 +140,7 @@
146140
{
147141
"cell_type": "code",
148142
"execution_count": null,
149-
"metadata": {
150-
"collapsed": true
151-
},
143+
"metadata": {},
152144
"outputs": [],
153145
"source": [
154146
"evt_data = Table(hdu_list[1].data)"
@@ -293,9 +285,7 @@
293285
{
294286
"cell_type": "code",
295287
"execution_count": null,
296-
"metadata": {
297-
"collapsed": true
298-
},
288+
"metadata": {},
299289
"outputs": [],
300290
"source": [
301291
"hdu_list.close()"
@@ -318,9 +308,7 @@
318308
{
319309
"cell_type": "code",
320310
"execution_count": null,
321-
"metadata": {
322-
"collapsed": true
323-
},
311+
"metadata": {},
324312
"outputs": [],
325313
"source": []
326314
},
@@ -334,9 +322,7 @@
334322
{
335323
"cell_type": "code",
336324
"execution_count": null,
337-
"metadata": {
338-
"collapsed": true
339-
},
325+
"metadata": {},
340326
"outputs": [],
341327
"source": []
342328
},
@@ -350,9 +336,7 @@
350336
{
351337
"cell_type": "code",
352338
"execution_count": null,
353-
"metadata": {
354-
"collapsed": true
355-
},
339+
"metadata": {},
356340
"outputs": [],
357341
"source": []
358342
}
@@ -366,11 +350,6 @@
366350
"name": "",
367351
"published": true
368352
},
369-
"kernelspec": {
370-
"display_name": "Python 3",
371-
"language": "python",
372-
"name": "python3"
373-
},
374353
"language_info": {
375354
"codemirror_mode": {
376355
"name": "ipython",
@@ -380,8 +359,7 @@
380359
"mimetype": "text/x-python",
381360
"name": "python",
382361
"nbconvert_exporter": "python",
383-
"pygments_lexer": "ipython3",
384-
"version": "3.6.9"
362+
"pygments_lexer": "ipython3"
385363
}
386364
},
387365
"nbformat": 4,

0 commit comments

Comments
 (0)