Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

feat(dspy): adding missing precommit files

piotrlaczkowski3c0eb6b4333b
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 000000000..8596afc68
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,68 @@
+default_language_version:
+ python: python3.11
+
+default_stages: [commit]
+default_install_hook_types: [pre-commit, commit-msg]
+
+repos:
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ # Ruff version.
+ rev: v0.1.11
+ hooks:
+ # Run the linter.
+ - id: ruff
+ args: [--fix]
+ # Run the formatter.
+ - id: ruff-format
+
+ - repo: https://github.com/timothycrosley/isort
+ rev: 5.12.0
+ hooks:
+ - id: isort
+ args:
+ [
+ "--profile=black",
+ "--py=311",
+ "--line-length=120",
+ "--multi-line=3",
+ "--trailing-comma",
+ "--force-grid-wrap=0",
+ "--use-parentheses",
+ "--ensure-newline-before-comments",
+ "--project=CORE,src,config,preprocess,train,transform,main,model",
+ ]
+
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.1.0
+ hooks:
+ - id: check-yaml
+ args: ["--allow-multiple-documents", "--unsafe"]
+ - id: end-of-file-fixer
+ - id: trailing-whitespace
+ - id: check-docstring-first
+ - id: check-toml
+ - id: check-added-large-files
+ args: ["--maxkb=1024"]
+ - id: requirements-txt-fixer
+ - id: check-merge-conflict
+ - id: debug-statements
+ - id: pretty-format-json
+ args:
+ - "--autofix"
+ - "--indent=2"
+ - repo: local
+ hooks:
+ - id: validate-commit-msg
+ name: Commit Message is Valid
+ language: pygrep
+ entry: ^(break|build|ci|docs|feat|fix|perf|refactor|style|test|ops|hotfix|release|maint|init|enh|revert)\([\w,\.,\-,\(,\),\/]+\)(!?)(:)\s{1}([\w,\W,:]+)
+ stages: [commit-msg]
+ args: [--negate]
+
+ - repo: https://github.com/pre-commit/mirrors-prettier
+ rev: v3.0.3
+ hooks:
+ - id: prettier
+ additional_dependencies:
+ - "@prettier/[email protected]"
diff --git a/pyproject.toml b/pyproject.toml
index 98fda3c0b..83f313b84 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -125,4 +125,144 @@ mkdocs-material-extensions = ">=1.3.1"
mkdocs-gen-files = "^0.5.0"
mkdocstrings-python = "^1.7.5"
mkdocstrings = {extras = ["python"], version = ">=0.20.0"}
-mike = ">=2.0.0"
\ No newline at end of file
+mike = ">=2.0.0"
+
+[tool.coverage.run]
+branch = true
+omit = [
+ "*/__init__.py",
+ "*/test_*.py",
+ "*/tests/*.py",
+ "*/conftest.py",
+ "*/venv/*",
+ "*/virtualenv/*",
+ "*/.venv/*",
+ "*/.virtualenv/*",
+ "*/env/*",
+ "*/.env/*",
+ "*/setup.py"
+]
+
+[tool.coverage.report]
+exclude_lines = [
+ "pragma: no cover",
+ "def __repr__",
+ "if self.debug:",
+ "raise AssertionError",
+ "raise NotImplementedError",
+ "if __name__ == '__main__':",
+ "logger",
+ "try",
+ "except",
+ "^\\s*self\\.\\w+(:\\s*[^=]+)?\\s*=.*$",
+ "continue",
+]
+
+[tool.ruff]
+line-length = 120
+indent-width = 4
+target-version = "py311"
+extend-unsafe-fixes = ["D"]
+
+[tool.ruff.lint]
+# List of rules: https://docs.astral.sh/ruff/rules
+select = [
+ # flake8-builtins
+ "A",
+ # flake8-commas
+ "COM812",
+ # flake8-comprehensions
+ "C4",
+ # pydocstyle
+ "D",
+ # pycodestyle
+ "E",
+ # Pyflakes
+ "F",
+ # pyupgrade
+ "UP",
+ # flake8-bugbear
+ "B",
+ # flake8-simplify
+ "SIM",
+ # flake8-implicit-str-concat
+ "ISC",
+ # pep8-naming
+ "N",
+ # flake8-annotations
+ "ANN",
+ # flake8-async
+ "ASYNC",
+ # flake8-bandid selected
+ "S",
+ # flake8-print
+ "T20",
+ # flake8-return
+ "RET",
+ # flake8-simplify
+ "SIM",
+ # flake8-unused-arguments
+ "ARG",
+ # flake8-use-pathlib
+ "PTH",
+ # eradicate
+ "ERA",
+ # pandas-vet
+ "PD",
+]
+ignore = [
+ "D100",
+ "D101",
+ "D104",
+ "D106",
+ # missing-type-self
+ "ANN101",
+ # missing-type-cls
+ "ANN102",
+ # missing-type-kwargs
+ "ANN003",
+ # utf-8 encoding skip
+ "UP009",
+ # First argument of a method should be named `self`
+ "N805",
+ # 1 blank line required between summary line and description
+ "D205",
+ # Missing return type annotation for special method `__init__`
+ "ANN204",
+ # Avoid using the generic variable name `df` for DataFrames
+ "PD901",
+ # Unnecessary assignment to `df` before `return` statement
+ "RET504",
+ # commented code
+ "ERA001",
+ # Star-arg unpacking after a keyword argument is strongly discouraged
+ "B026",
+ # Missing type annotation for function argument `self`
+ "ANN001",
+ # Dynamically typed expressions (typing.Any) are disallowed in `wrapper`
+ "ANN401",
+ # Unnecessary `elif` after `return` statement
+ "RET505",
+ # Within an `except` clause, raise exceptions with `raise
+ "B904",
+]
+
+# Allow fix for all enabled rules (when `--fix`) is provided.
+fixable = ["ALL"]
+unfixable = []
+
+[tool.ruff.format]
+docstring-code-format = true
+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"
+
+[tool.ruff.lint.pydocstyle]
+convention = "google"
+
+[tool.ruff.lint.per-file-ignores]
+"**/{test,docs}/*" = ["ALL"]