diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c850bbc --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.6.7 # Use the latest stable version of Ruff + hooks: + - id: ruff diff --git a/.vscode/settings.json b/.vscode/settings.json index f51c61d..dcb900a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,8 +9,8 @@ "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, "[python]": { - "editor.defaultFormatter": "ms-python.autopep8", - "editor.formatOnSave": true + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.formatOnSave": false }, "python.formatting.provider": "none" } \ No newline at end of file diff --git a/generate_pyproj.py b/generate_pyproj.py index 2e4b851..9cdb6ba 100644 --- a/generate_pyproj.py +++ b/generate_pyproj.py @@ -15,13 +15,13 @@ "version": version, "description": "A python wrapper for use with ChurchToolsAPI", "authors": ["bensteUEM", "kolibri52", "fschrempf"], - "homepage": 'https://github.com/bensteUEM/ChurchToolsAPI', + "homepage": "https://github.com/bensteUEM/ChurchToolsAPI", "license": "CC-BY-SA", "readme": "README.md", "dependencies": { - "python": "^3.8", + "python": "^3.9", "python-docx": "^0.8.11", - "requests": "^2.31.0" + "requests": "^2.31.0", }, "group": { "dev": { @@ -31,16 +31,82 @@ "wheel": "^0.41.2", "setuptools": "^66.1.1", "autopep8": "^2.0.4", - "pytest" : "^8.3.3", + "pytest": "^8.3.3", + "pre-commit": "^3.8.0", } } - } - } + }, + }, + "ruff": { + # Exclude a variety of commonly ignored directories. + "exclude": [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", + ], + # Same as Black. + "line-length": 88, + "indent-width": 4, + # Assume Python 3.9 + "target-version": "py39", + # Group violations by containing file. + "output-format": "grouped", + "lint": { + # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. + "select": ["ALL"], + "ignore": [], + # 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]+?))$", + "pydocstyle": { + "convention": "google", + }, + }, + "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. + "docstring-code-format": False, + # Set the line length limit used when formatting code snippets in docstrings. + "docstring-code-line-length": "dynamic", + }, + }, }, "build-system": { "requires": ["poetry-core"], - "build-backend": "poetry.core.masonry.api" - } + "build-backend": "poetry.core.masonry.api", + }, } with open("pyproject.toml", "wb") as toml_file: diff --git a/pyproject.toml b/pyproject.toml index d4d69a9..7b39d4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ license = "CC-BY-SA" readme = "README.md" [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" python-docx = "^0.8.11" requests = "^2.31.0" @@ -23,6 +23,63 @@ wheel = "^0.41.2" setuptools = "^66.1.1" autopep8 = "^2.0.4" pytest = "^8.3.3" +pre-commit = "^3.8.0" + +[tool.ruff] +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] +line-length = 88 +indent-width = 4 +target-version = "py39" +output-format = "grouped" + +[tool.ruff.lint] +select = [ + "ALL", +] +ignore = [] +fixable = [ + "ALL", +] +unfixable = [] +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" +docstring-code-format = false +docstring-code-line-length = "dynamic" [build-system] requires = [