From 7e2ed82fbc1ddc0a4df1d0a33801a3a6b6fb23b4 Mon Sep 17 00:00:00 2001 From: O-J1 <18110006+O-J1@users.noreply.github.com> Date: Tue, 23 Sep 2025 18:03:20 +1000 Subject: [PATCH 1/3] Add pre-commit --- .editorconfig | 19 +++++++++++++++++++ .pre-commit-config.yaml | 25 +++++++++++++++++++++++++ pyproject.toml | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 .editorconfig create mode 100644 .pre-commit-config.yaml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..80c7f52 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 120 +tab_width = 4 +ij_continuation_indent_size = 8 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = true +ij_smart_tabs = false +ij_visual_guides = none +ij_wrap_on_typing = false + +[*.bat] +end_of_line = crlf \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b35cbe7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-merge-conflict + - id: check-case-conflict + - id: check-illegal-windows-names + - id: destroyed-symlinks + - id: fix-byte-order-marker + - id: mixed-line-ending + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-executables-have-shebangs + - id: check-yaml + +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.13.0 + hooks: + # Run the Ruff linter, but not the formatter. + - id: ruff + args: ["--fix"] + types_or: [ python, pyi, jupyter ] + +ci: + autofix_prs: false diff --git a/pyproject.toml b/pyproject.toml index 6163bb3..ef24256 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,3 +22,39 @@ Homepage = "https://github.com/Nerogar/mgds" Issues = "https://github.com/Nerogar/mgds/issues" [tool.setuptools_scm] + +[tool.ruff] +extend-exclude = [ + # Exclude all third-party dependencies and environments. + # NOTE: Conda installs mgds+diffusers into "src/" in the project directory. + ".venv*", + "venv*", + "conda_env*", +] +line-length = 120 + +[tool.ruff.lint] +select = ["F", "E", "W", "I", "B", "UP", "YTT", "BLE", "C4", "T10", "ISC", "ICN", "PIE", "PYI", "RSE", "RET", "SIM", "PGH", "FLY", "NPY", "PERF"] +ignore = ["BLE001", "E402", "E501", "B024", "PGH003", "RET504", "RET505", "SIM102", "UP015", "PYI041"] + +[tool.ruff.lint.isort.sections] +hf = ["diffusers*", "transformers*"] +mgds = ["mgds"] +torch = ["torch*"] + +[tool.ruff.format] +quote-style = "double" +docstring-code-format = true + +[tool.ruff.lint.isort] +known-first-party = ["modules"] +section-order = [ + "future", + "standard-library", + "first-party", + "mgds", + "torch", + "hf", + "third-party", + "local-folder", +] From 4f187f9d49712d19b1bf5ea3d3b9372edbc37dcd Mon Sep 17 00:00:00 2001 From: O-J1 <18110006+O-J1@users.noreply.github.com> Date: Tue, 23 Sep 2025 23:03:27 +1000 Subject: [PATCH 2/3] Add dev reqs with pre-commit. --- requirements-dev.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 requirements-dev.txt diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..e076040 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +# Git commit hook handler. +# NOTE: It's a user-wide tool installed outside venv. Don't pin exact versions. +# SEE: https://pre-commit.com/ +pre-commit>=4.0.1 From 7465bffb40f5344b8b792fbaf15d988eb6ab5dd7 Mon Sep 17 00:00:00 2001 From: dxqb <183307934+dxqb@users.noreply.github.com> Date: Tue, 3 Feb 2026 15:29:56 +0100 Subject: [PATCH 3/3] Update Ruff pre-commit hook version to v0.14.14 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b35cbe7..3751c9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: - id: check-yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.13.0 + rev: v0.14.14 hooks: # Run the Ruff linter, but not the formatter. - id: ruff