Skip to content

Add pre-commit config #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "weekly"
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ jobs:
run: |
sudo apt-get install pandoc
python -m pip install -U pip
python -m pip install -r requirements.txt
python -m pip install git+https://github.com/astropy/nbcollection
python -m pip install -r requirements-dev.txt

- name: Execute the notebooks
run: |
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ jobs:
run: |
sudo apt-get install pandoc
python -m pip install -U pip
python -m pip install -r requirements.txt
python -m pip install gitpython
python -m pip install git+https://github.com/astropy/nbcollection
python -m pip install -r requirements-dev.txt

# Run all tutorials if the label is present
- name: Run all tutorials
Expand Down
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: '.*\.fits$'
- id: end-of-file-fixer
exclude_types: [csv]
exclude: '.*\.fits$'
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/kynan/nbstripout
rev: 0.5.0
hooks:
- id: nbstripout
args: ["--extra-keys='metadata.kernelspec metadata.language_info.version metadata.toc'"]
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ MODIFIED := $(shell python .github/get_modified_tutorials.py --main-branch $(TUT
FLAGS = --flatten --build-path=. -v
CONVERTFLAGS = --make-index --preprocessors=nbconvert.preprocessors.ExtractOutputPreprocessor --index-template=templates/index.tpl

init:
python -m pip install -U -r requirements-dev.txt
pre-commit install

build: envcheck execute convert
buildall: envcheck executeall convertall

Expand All @@ -27,4 +31,4 @@ convertall:
clean:
rm -rf _build

.PHONY: all clean execute convert executeall convertall build buildall
.PHONY: init all clean execute convert executeall convertall build buildall
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r requirements.txt
gitpython
git+https://github.com/astropy/nbcollection
pre-commit
2 changes: 1 addition & 1 deletion templates/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
{% endfor %}
</ul>
</body>
</html>
</html>
21 changes: 1 addition & 20 deletions tutorials/FITS-cubes/FITS-cubes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -825,11 +825,6 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand All @@ -839,21 +834,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
12 changes: 2 additions & 10 deletions tutorials/FITS-header/FITS-header.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"hdu_number = 0 # HDU means header data unit\n",
Expand Down Expand Up @@ -244,11 +242,6 @@
"name": "",
"published": true
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand All @@ -258,8 +251,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
8 changes: 1 addition & 7 deletions tutorials/FITS-images/FITS-images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,6 @@
"name": "",
"published": true
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand All @@ -465,8 +460,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
40 changes: 9 additions & 31 deletions tutorials/FITS-tables/FITS-tables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
Expand All @@ -52,9 +50,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from astropy.utils.data import download_file"
Expand Down Expand Up @@ -96,9 +92,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"hdu_list = fits.open(event_filename, memmap=True)"
Expand Down Expand Up @@ -146,9 +140,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"evt_data = Table(hdu_list[1].data)"
Expand Down Expand Up @@ -293,9 +285,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"hdu_list.close()"
Expand All @@ -318,9 +308,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
},
Expand All @@ -334,9 +322,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
},
Expand All @@ -350,9 +336,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
Expand All @@ -366,11 +350,6 @@
"name": "",
"published": true
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand All @@ -380,8 +359,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
Loading