-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add pre-commit
for code linting
#221
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e1d3980
Add pre-commit config
altheaden be4bc71
Add flake8 configuration file
altheaden 596ff5a
Add pre-commit to deps
altheaden 674d65b
Fix extra spaces at end of lines
altheaden 39a411a
Fix newlines at end of files
altheaden 3085de6
Flynt replace format strings
altheaden 0f60bb5
Minor bugfix in docs workflow
altheaden 7e4d714
Add pre-commit to build CI workflow
altheaden 996fd52
Isort reorder imports
altheaden fd39cc2
Add features_and_tags.json to ignore list
xylar 9004c4e
Add isort and flake8 to dev environment
xylar cfff1e5
Remove mypy
xylar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[flake8] | ||
# https://pep8.readthedocs.io/en/latest/intro.html#error-codes | ||
ignore = | ||
# line break after operator | ||
W504 | ||
# Max width of Github code review is 79 characters | ||
max-line-length = 79 | ||
max-complexity = 18 | ||
per-file-ignores = | ||
*/__init__.py: F401 | ||
exclude = | ||
.git, | ||
docs, | ||
.idea, | ||
.mypy_cache, | ||
.pytest_cache, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,34 @@ env: | |
PATHS_IGNORE: '["**/README.md", "**/docs/**"]' | ||
|
||
jobs: | ||
pre-commit-hooks: | ||
name: lint with pre-commit | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- id: skip_check | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
cancel_others: ${{ env.CANCEL_OTHERS }} | ||
paths_ignore: ${{ env.PATHS_IGNORE }} | ||
|
||
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }} | ||
name: Checkout Code Repository | ||
uses: actions/checkout@v4 | ||
|
||
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }} | ||
name: Set up Python 3.10 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }} | ||
# Run all pre-commit hooks on all the files. | ||
# Getting only staged files can be tricky in case a new PR is opened | ||
# since the action is run on a branch in detached head state | ||
name: Install and Run Pre-commit | ||
uses: pre-commit/[email protected] | ||
|
||
build: | ||
name: test geometric_features - python ${{ matrix.python-version }} | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ on: | |
release: | ||
types: [published] | ||
|
||
env: | ||
PYTHON_VERSION: "3.10" | ||
|
||
jobs: | ||
publish-docs: | ||
runs-on: ubuntu-latest | ||
|
@@ -40,14 +43,14 @@ jobs: | |
channels: conda-forge | ||
channel-priority: strict | ||
auto-update-conda: true | ||
python-version: ${{ matrix.python-version }} | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }} | ||
name: Install geometric_features | ||
run: | | ||
git config --global url."https://github.com/".insteadOf "[email protected]:" | ||
conda create -n geometric_features_dev --file dev-spec.txt \ | ||
python=${{ matrix.python-version }} | ||
python=${{ env.PYTHON_VERSION }} | ||
conda activate geometric_features_dev | ||
python -m pip install -vv --no-deps --no-build-isolation -e . | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
exclude: "docs|.git|geometric_data|geometric_features/features_and_tags.json" | ||
default_stages: [pre-commit] | ||
fail_fast: true | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
|
||
# Can run individually with `pre-commit run isort --all-files` | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
exclude: "geometric_features/__init__.py" | ||
|
||
# Can run individually with `flynt [file]` or `flynt [source]` | ||
- repo: https://github.com/ikamensh/flynt | ||
rev: '1.0.1' | ||
hooks: | ||
- id: flynt | ||
args: ["--fail-on-change", "--verbose"] | ||
require_serial: true | ||
|
||
# Can run individually with `pre-commit run flake8 --all-files` | ||
# Need to use flake8 GitHub mirror due to CentOS git issue with GitLab | ||
# https://github.com/pre-commit/pre-commit/issues/1206 | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 7.1.1 | ||
hooks: | ||
- id: flake8 | ||
args: ["--config=.flake8"] | ||
additional_dependencies: [flake8-isort] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ shapely>=2.0,<3.0 | |
pip | ||
pytest | ||
setuptools>=60 | ||
pre-commit | ||
isort | ||
flake8 | ||
|
||
# Documentation | ||
sphinx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xylar isort reordering the imports for this file broke everything, so I've excluded it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's follow up on that in a separate PR. We don't need all the
__future__
stuff anymore. That was for python 2. Maybe that will help. But if that's not the problem, we maybe need to add missing imports somewhere else.