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..3751c9f --- /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.14.14 + 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", +] 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