-
Notifications
You must be signed in to change notification settings - Fork 42
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
[WIP] Inplement linting with Ruff #674
Open
quinto-clara
wants to merge
2
commits into
GlacioHack:main
Choose a base branch
from
quinto-clara:550-ruff_linter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,83 @@ | ||
# Exclude a variety of commonly ignored directories. | ||
exclude = ["ALL"] | ||
|
||
extend-exclude = [ | ||
".github", | ||
"binder", | ||
"doc", | ||
"xdem.egg-info", | ||
".coveragerc", | ||
".gitignore", | ||
".pre-commit-config.yaml", | ||
".readthedocs.yaml", | ||
".relint.yml", | ||
] | ||
|
||
# Support Python 3.10+. | ||
target-version = "py310" | ||
|
||
# Same as Black. | ||
# The formatter wraps lines at a length of 120 when enforcing long-lines violations (like E501). | ||
line-length = 120 | ||
# Number of spaces per tabulation, used by the formatter and when enforcing long-line violations. | ||
indent-width = 4 | ||
|
||
[lint.pycodestyle] | ||
# E501 reports lines that exceed the length of 120. | ||
max-line-length = 120 | ||
|
||
[lint] | ||
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. | ||
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or | ||
# McCabe complexity (`C901`) by default (10). | ||
select = ["ALL"] | ||
|
||
# Skip To do format annotations rules (FIX002, TD002, TD003) | ||
# Skip pydocstyle rules (D101, D205, D400, D401, D415) | ||
# Skip flake8-simplify rules (SIM102, SIM108, SIM115) | ||
# Skip pygrep-hooks rules (PGH003, PGH004) | ||
# Skip pylint refactor rules (PLR0912, PLR0913, PLR0915, PLR2004) | ||
# Skip the use of assert (S101) | ||
# Skip flake8-type-checking rules (TC001, TC002, TC003) | ||
# Skip tryceratops rules (TRY003, TRY201) | ||
# Skip pyupgrade rule : non-pep604-isinstance (UP038) | ||
# ... | ||
ignore = ["ANN401", "ARG002", "B028", "B904", "BLE001", "C901", "D101", "D205", "D400", "D401", "D415", "EM101", | ||
"EM102", "ERA001", "F541", "FBT001", "FBT002", "FBT003", "FIX002", "INP001", "PD011", "PGH003", "PGH004", | ||
"PLR0912", "PLR0913", "PLR0915", "PLR2004", "PLW0127", "PT011", "PTH118", "PYI041", "PYI051", "RET504", | ||
"S101", "SIM102", "SIM108", "SIM115", "T201", "TC001", "TC002", "TC003", "TD002", "TD003", "TRY003", | ||
"TRY201", "UP038"] | ||
|
||
# Allow fix for all enabled rules (when `--fix`) is provided. | ||
fixable = ["ALL"] | ||
unfixable = [] | ||
|
||
# Allow unused variables when underscore-prefixed. | ||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" | ||
|
||
[format] | ||
# Like Black, use double quotes for strings. | ||
quote-style = "double" | ||
|
||
# Like Black, indent with spaces, rather than tabs. | ||
indent-style = "space" | ||
|
||
# Like Black, respect magic trailing commas. | ||
skip-magic-trailing-comma = false | ||
|
||
# Like Black, automatically detect the appropriate line ending. | ||
line-ending = "auto" | ||
|
||
# Enable auto-formatting of code examples in docstrings. Markdown, | ||
# reStructuredText code/literal blocks and doctests are all supported. | ||
# | ||
# This is currently disabled by default, but it is planned for this | ||
# to be opt-out in the future. | ||
docstring-code-format = false | ||
|
||
# Set the line length limit used when formatting code snippets in | ||
# docstrings. | ||
# | ||
# This only has an effect when the `docstring-code-format` setting is | ||
# enabled. | ||
docstring-code-line-length = "dynamic" |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
############### GLOBAL VARIABLES ###################### | ||
.DEFAULT_GOAL := help | ||
SHELL := /bin/bash | ||
PATH :=. | ||
|
||
# Virtualenv directory name (can be overridden) | ||
ifndef VENV | ||
|
@@ -82,6 +83,26 @@ test: ## run tests | |
${VENV}/bin/pytest; \ | ||
fi | ||
|
||
## Code quality, linting section | ||
|
||
.PHONY: lint | ||
lint: ruff ## Apply the ruff linter. | ||
|
||
.PHONY: lint-check | ||
lint-check: ## Check whether the codebase satisfies the linter rules. | ||
@echo | ||
@echo "Checking linter rules..." | ||
@echo "========================" | ||
@echo | ||
@ruff check $(PATH) | ||
|
||
.PHONY: ruff | ||
ruff: ## Apply ruff. | ||
@echo "Applying ruff..." | ||
@echo "================" | ||
@echo | ||
@ruff --fix $(path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
## Clean section | ||
|
||
.PHONY: clean | ||
|
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,18 @@ | ||
# Copyright (c) 2024 Centre National d'Etudes Spatiales (CNES). | ||
# | ||
# This file is part of the xDEM project: | ||
# https://github.com/glaciohack/xdem | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""xDEM examples module init file.""" |
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,18 @@ | ||
# Copyright (c) 2024 Centre National d'Etudes Spatiales (CNES). | ||
# | ||
# This file is part of the xDEM project: | ||
# https://github.com/glaciohack/xdem | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""xDEM advanced examples module init file.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Files in examples/ or tests/ do not need a header as they are not part of the source code |
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.
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.
This command breaks the Makefile by overwriting the system's executable search paths, preventing essential commands from being found. Since PATH already exists, it's unnecessary to redefine it.