Skip to content

Commit 1c68964

Browse files
authored
Add precommit and run on all files (#1541)
* Add precommit * Use pre-commit * Run precommit * Add EOL
1 parent 951cd74 commit 1c68964

File tree

94 files changed

+365
-322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+365
-322
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
ignore =
2+
ignore =
33
# E*** / W*** pycodestyle codes
44
# whitespace before ','
55
E203,

.github/ISSUE_TEMPLATE/jira_service_desk.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Please file issues in Jira Service Desk
2+
name: Please file issues in Jira Service Desk
33
about: https://sagebionetworks.jira.com/servicedesk/customer/portal/5/group/8/create/87
44
title: ''
55
labels: ''
@@ -10,4 +10,4 @@ assignees: ''
1010
**Describe the bug**
1111
Please file issues or requests for help with schematic in [Jira Service Desk](https://sagebionetworks.jira.com/servicedesk/customer/portal/5/group/8/create/87).
1212

13-
These issues are not monitored.
13+
These issues are not monitored.

.github/workflows/api_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
| python3 - --version ${{ env.POETRY_VERSION }};
4444
poetry config virtualenvs.create true;
4545
poetry config virtualenvs.in-project true;
46-
46+
4747
#----------------------------------------------
4848
# install dependencies and root project
4949
#----------------------------------------------

.github/workflows/docker_build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
- name: Checkout repository
2626
uses: actions/checkout@v4
27-
27+
2828
- name: Set env variable for version tag
2929
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
3030

@@ -54,4 +54,3 @@ jobs:
5454
labels: ${{ steps.meta.outputs.labels }}
5555
build-args: |
5656
TAG=${{ env.RELEASE_VERSION }}
57-

.github/workflows/pdoc.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ permissions:
1212
contents: read
1313

1414
concurrency:
15-
# cancel the current running workflow from the same branch, PR when a new workflow is triggered
15+
# cancel the current running workflow from the same branch, PR when a new workflow is triggered
1616
# when the trigger is not a PR but a push, it will use the commit sha to generate the concurrency group
1717
# {{ github.workflow }}: the workflow name is used to generate the concurrency group. This allows you to have more than one workflows
18-
# {{ github.ref_type }}: the type of Git ref object created in the repository. Can be either branch or tag
19-
# {{ github.event.pull_request.number}}: get PR number
20-
# {{ github.sha }}: full commit sha
18+
# {{ github.ref_type }}: the type of Git ref object created in the repository. Can be either branch or tag
19+
# {{ github.event.pull_request.number}}: get PR number
20+
# {{ github.sha }}: full commit sha
2121
# credit: https://github.com/Sage-Bionetworks-Workflows/sagetasks/blob/main/.github/workflows/ci.yml
2222
group: >-
2323
${{ github.workflow }}-${{ github.ref_type }}-
@@ -32,7 +32,7 @@ jobs:
3232

3333
steps:
3434
#----------------------------------------------
35-
# check-out repo and set-up python
35+
# check-out repo and set-up python
3636
#----------------------------------------------
3737
- name: Check out repository
3838
uses: actions/checkout@v4
@@ -41,16 +41,16 @@ jobs:
4141
uses: actions/setup-python@v5
4242
with:
4343
python-version: ${{ env.PYTHON_VERSION }}
44-
44+
4545
#----------------------------------------------
46-
# install & configure poetry
46+
# install & configure poetry
4747
#----------------------------------------------
4848
- name: Install Poetry
4949
run: |
5050
curl -sSL https://install.python-poetry.org \
5151
| python3 - --version ${{ env.POETRY_VERSION }};
52-
poetry config virtualenvs.create true;
53-
poetry config virtualenvs.in-project true;
52+
poetry config virtualenvs.create true;
53+
poetry config virtualenvs.in-project true;
5454
5555
#----------------------------------------------
5656
# install dependencies and root project

.github/workflows/publish.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
python-version: ${{ env.PYTHON_VERSION }}
1919
- id: build-package
20-
run: |
20+
run: |
2121
python3 -m pip install --upgrade pip
2222
python3 -m pip install setuptools
2323
python3 -m pip install wheel
@@ -35,7 +35,7 @@ jobs:
3535
3636
echo "sdist-release-url=${RELEASE_URL_PREFIX}${SDIST_PACKAGE_NAME}" >> $GITHUB_OUTPUT
3737
echo "bdist-release-url=${RELEASE_URL_PREFIX}${BDIST_PACKAGE_NAME}" >> $GITHUB_OUTPUT
38-
38+
3939
- name: upload-sdist-artifact
4040
uses: actions/upload-artifact@v4
4141
with:
@@ -90,4 +90,3 @@ jobs:
9090
# Post to the `fair-data-tools` slack channel
9191
channel-id: 'C01ANC02U59'
9292
slack-message: "A new version of Schematic has been released. Check out the new version: ${{ github.ref_name }}"
93-

.github/workflows/scan_repo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
branches:
77
- develop
88
pull_request:
9-
workflow_dispatch:
9+
workflow_dispatch:
1010

1111
jobs:
1212
trivy:

.github/workflows/test.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ jobs:
8787
#----------------------------------------------
8888
# check formatting
8989
#----------------------------------------------
90-
- name: Code formatting with black
91-
run: |
92-
# ran only on certain files for now
93-
# add here when checked
94-
poetry run black schematic tests schematic_api --check
90+
- uses: pre-commit/action@v3.0.1
9591

9692
#----------------------------------------------
9793
# type checking/enforcement
@@ -121,7 +117,7 @@ jobs:
121117
SYNAPSE_ACCESS_TOKEN: ${{ secrets.SYNAPSE_ACCESS_TOKEN }}
122118
SERVICE_ACCOUNT_CREDS: ${{ secrets.SERVICE_ACCOUNT_CREDS }}
123119
run: >
124-
poetry run pytest --durations=0 --cov-append --cov-report=term --cov-report=html:htmlcov
120+
poetry run pytest --durations=0 --cov-append --cov-report=term --cov-report=html:htmlcov
125121
--cov-report=xml:coverage.xml --cov=schematic/ --reruns 4 -n 8 tests/unit;
126122
127123
#----------------------------------------------
@@ -151,7 +147,7 @@ jobs:
151147
LOGGING_EXPORT_FORMAT: ${{ vars.LOGGING_EXPORT_FORMAT }}
152148
TRACING_SERVICE_NAME: ${{ vars.TRACING_SERVICE_NAME }}
153149
LOGGING_SERVICE_NAME: ${{ vars.LOGGING_SERVICE_NAME }}
154-
SERVICE_INSTANCE_ID: ${{ github.head_ref || github.ref_name }}
150+
SERVICE_INSTANCE_ID: ${{ github.head_ref || github.ref_name }}
155151
run: >
156152
poetry run pytest --durations=0 --cov-append --cov-report=term --cov-report=html:htmlcov --cov-report=xml:coverage.xml --cov=schematic/
157153
-m "not (rule_benchmark or single_process_execution)" --reruns 4 -n 8 --ignore=tests/unit

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@ manifests/*
180180
https:*
181181

182182
# schematic config file
183-
config.yml
183+
config.yml

.pre-commit-config.yaml

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,68 @@
1-
repos:
2-
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
3-
# This is recommended by psf/black: https://github.com/psf/black/blob/main/.pre-commit-hooks.yaml
4-
- repo: https://github.com/psf/black-pre-commit-mirror
5-
rev: 23.7.0
6-
hooks:
7-
- id: black
8-
# It is recommended to specify the latest version of Python
9-
# supported by your project here, or alternatively use
10-
# pre-commit's default_language_version, see
11-
# https://pre-commit.com/#top_level-default_language_version
12-
language_version: python3.10
13-
files: ^(tests|schematic|schematic_api)/
14-
15-
- repo: https://github.com/pycqa/isort
16-
rev: 5.13.2
17-
hooks:
18-
- id: isort
19-
name: isort (python)
20-
files: ^(tests|schematic|schematic_api)/
21-
args: ["--profile", "black", "--filter-files"]
1+
exclude: "^docs/conf.py|^docs/build/"
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: check-added-large-files
9+
- id: check-ast
10+
# - id: check-json
11+
- id: check-merge-conflict
12+
- id: check-xml
13+
- id: check-yaml
14+
exclude: ^mkdocs\.yml$
15+
- id: debug-statements
16+
- id: end-of-file-fixer
17+
- id: requirements-txt-fixer
18+
- id: mixed-line-ending
19+
args: ["--fix=auto"] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows
20+
21+
# - repo: https://github.com/astral-sh/ruff-pre-commit
22+
# rev: "v0.0.270"
23+
# hooks:
24+
# - id: ruff
25+
26+
# - repo: https://github.com/pycqa/isort
27+
# rev: 5.13.2
28+
# hooks:
29+
# - id: isort
30+
# name: isort (python)
31+
32+
- repo: https://github.com/psf/black
33+
rev: 23.12.1
34+
hooks:
35+
- id: black
36+
language_version: python3
37+
38+
# - repo: https://github.com/PyCQA/bandit
39+
# rev: 1.7.5
40+
# hooks:
41+
# - id: bandit
42+
# args: ["-c", "pyproject.toml"]
43+
# additional_dependencies: ["bandit[toml]"]
44+
# - repo: https://github.com/asottile/blacken-docs
45+
# rev: v1.12.0
46+
# hooks:
47+
# - id: blacken-docs
48+
# additional_dependencies: [black]
49+
50+
# - repo: https://github.com/pre-commit/mirrors-mypy
51+
# rev: 'v1.0.1'
52+
# hooks:
53+
# - id: mypy
54+
# additional_dependencies: [pydantic~=1.10]
55+
56+
# Checks for missing docstrings
57+
# - repo: https://github.com/econchick/interrogate
58+
# rev: 1.5.0
59+
# hooks:
60+
# - id: interrogate
61+
# exclude: ^(docs/conf.py|setup.py|tests)
62+
# args: [--config=pyproject.toml]
63+
64+
# finds dead python code
65+
# - repo: https://github.com/jendrikseipp/vulture
66+
# rev: 'v2.7'
67+
# hooks:
68+
# - id: vulture

0 commit comments

Comments
 (0)