diff --git a/.flake8 b/.flake8 deleted file mode 100644 index d988e59..0000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length = 88 -extend-ignore = E203, F722, F821 \ No newline at end of file diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 683e12f..91f3ae8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -23,14 +23,14 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 + pip install ruff - name: Clone Flir extractor run: | git clone https://github.com/ITVRoC/FlirImageExtractor.git --depth 1 sudo apt install exiftool python-setuptools - - name: Lint with flake8 + - name: Lint with ruff run: | - flake8 . --count --show-source --statistics --exclude FlirImageExtractor/ + ruff check - run: pip install -e . - name: Test with unittest run: | diff --git a/.vscode/settings.json b/.vscode/settings.json index 853c405..2f7d954 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,9 +10,10 @@ "python.testing.unittestEnabled": true, "[python]": { "editor.codeActionsOnSave": { + "source.fixAll": "explicit", "source.organizeImports": "explicit" }, - "editor.defaultFormatter": "ms-python.black-formatter", + "editor.defaultFormatter": "charliermarsh.ruff", "editor.rulers": [ 88 ], @@ -22,10 +23,6 @@ "reportUndefinedVariable": "warning" }, "editor.formatOnSave": true, - "isort.args": [ - "--profile", - "black" - ], "python.analysis.diagnosticMode": "openFilesOnly", "errorLens.enabledDiagnosticLevels": [ "error", diff --git a/README.md b/README.md index e16fed4..1a34950 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ python thermo_nerf/scripts/render_video_script.py --dataset_path DATA_PATH --mod We welcome contributions! Feel free to fork and submit PRs. -We format code using [black](https://pypi.org/project/black/) and follow PEP8. +We format code using [ruff](https://docs.astral.sh/ruff) and follow PEP8. The code needs to be type annotated and following our documentation style. ## How to cite diff --git a/pyproject.toml b/pyproject.toml index 0c45741..1154196 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ description = 'thermo-nerf' readme = "README.md" requires-python = ">=3.10" keywords = ["pytorch", "thermal", "nerf", "mlflow", "flir"] -dependencies = ["nerfstudio >= 0.1.19", "mlflow >= 2.11.1"] +dependencies = ["nerfstudio >= 0.1.19", "mlflow >= 2.11.1", "ruff >= 0.7.4"] [project.optional-dependencies] flir = ["flirimageextractor >= 1.5.3"] @@ -17,9 +17,49 @@ flir = ["flirimageextractor >= 1.5.3"] [tool.hatch.build.targets.wheel] packages = ["thermo_nerf", "thermo_scenes"] -[tool.isort] -profile = "black" -known_third_party = ["nerfstudio", "FlirImageExtractor"] +# RUFF + +[tool.ruff] +line-length = 88 +indent-width = 4 + +[tool.ruff.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. +select = ["E", "F"] +ignore = ["F722", "F821"] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +[tool.ruff.lint.isort] +known-third-party = ["FlirImageExtractor"] + +[tool.ruff.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 = true +# 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" + +# CLI [project.scripts] thermoscenes_images_to_nerf_dataset = "thermo_scenes.scripts.images_to_nerf_dataset:main"