-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pre-commit Linting and Type checking (#2)
- Loading branch information
1 parent
f85d8b4
commit c6b93a8
Showing
7 changed files
with
223 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- uses: pre-commit/action@v3.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
exclude: "helm" | ||
default_stages: [commit] | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-toml | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: check-builtin-literals | ||
- id: check-case-conflict | ||
- id: detect-private-key | ||
|
||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: "v3.0.3" | ||
hooks: | ||
- id: prettier | ||
args: ["--tab-width", "2"] | ||
|
||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.10.1 | ||
hooks: | ||
- id: pyupgrade | ||
args: [--py311-plus] | ||
exclude: hooks/ | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.5.1 | ||
hooks: | ||
- id: mypy | ||
additional_dependencies: | ||
- pydantic==1.10.12 | ||
- requests==2.31 | ||
- fastapi==0.99 | ||
- dependency_injector==4.41.0 | ||
- langchain==0.0.264 | ||
args: [--install-types, --non-interactive] | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.0.287 | ||
hooks: | ||
- id: ruff | ||
args: [--fix, --exit-non-zero-on-fix] | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.7.0 | ||
hooks: | ||
- id: black | ||
|
||
ci: | ||
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks | ||
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from typing import get_args | ||
from __future__ import annotations | ||
|
||
from typing import Any, get_args | ||
|
||
def get_generic_type(cls: type) -> type: | ||
|
||
def get_generic_type(cls: type[Any]) -> Any: | ||
return get_args(cls.__orig_bases__[0])[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
[project] | ||
name = "docsie-ddd-framework" | ||
version = "0.0.1" | ||
description = "The package includes helper methods and types for working in DDD" | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
license = { file = "LICENSE" } | ||
authors = [ | ||
{ name = "Philippe Trounev", email = "philippe.trounev@likalo.com" }, | ||
{ name = "Nikita Belyaev", email = "nick@docsie.io" }, | ||
] | ||
maintainers = [ | ||
{ name = "Philippe Trounev", email = "philippe.trounev@likalo.com" }, | ||
{ name = "Nikita Belyaev", email = "nick@docsie.io" }, | ||
] | ||
classifiers = ["Programming Language :: Python"] | ||
dependencies = ["cattrs~=23.1.0", "attrs~=23.1.0", "pymongo~=4.3.3"] | ||
|
||
[project.optional-dependencies] | ||
dev = ["pre-commit", "mypy", "ruff"] | ||
|
||
[project.urls] | ||
Repository = "https://github.com/LikaloLLC/ddd-framework.git" | ||
|
||
[tool.setuptools.packages] | ||
find = {} | ||
|
||
[tool.mypy] | ||
strict = true | ||
explicit_package_bases = true | ||
packages = ["ddd_framework"] | ||
ignore_missing_imports = true | ||
exclude = ['ddd_framework/utils/types.py'] | ||
|
||
[tool.ruff] | ||
src = ["ddd_frameowrk"] | ||
|
||
select = [ | ||
"E", # pycodestyle errors | ||
"W", # pycodestyle warnings | ||
"F", # pyflakes | ||
"I", # isort | ||
"C", # flake8-comprehensions | ||
"B", # flake8-bugbear | ||
"ANN", # flake8-annotations | ||
"FA", # flake8-future-annotations | ||
"T20", # flake8-print | ||
"Q", # flake8-quotes | ||
"SIM", # flake8-simplify | ||
"TCH", # flake8-type-checking | ||
"PL", # Pylint | ||
] | ||
ignore = [ | ||
"E501", # line too long, handled by black | ||
"B008", # do not perform function calls in argument defaults | ||
"C901", # too complex | ||
"ANN101", # Missing type annotation for `self` in method | ||
"ANN002", # Missing type annotation for `*args` | ||
"ANN003", # Missing type annotation for `**kwargs` | ||
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in ... TODO: It's better to bring it back | ||
"ANN102", # Missing type annotation for `cls` in classmethod | ||
"PLR0913", # Too many arguments to function call (7 > 5) | ||
"PLW1508", #Invalid type for environment variable default; expected `str` or `None` | ||
] | ||
|
||
# Allow autofix for all enabled rules (when `--fix`) is provided. | ||
fixable = ["ALL"] | ||
unfixable = [] | ||
|
||
# Exclude a variety of commonly ignored directories. | ||
exclude = [ | ||
".bzr", | ||
".direnv", | ||
".eggs", | ||
".git", | ||
".git-rewrite", | ||
".hg", | ||
".mypy_cache", | ||
".nox", | ||
".pants.d", | ||
".pytype", | ||
".ruff_cache", | ||
".svn", | ||
".tox", | ||
".venv", | ||
"__pypackages__", | ||
"_build", | ||
"buck-out", | ||
"build", | ||
"dist", | ||
"node_modules", | ||
"venv", | ||
] | ||
|
||
# Same as Black. | ||
line-length = 128 | ||
|
||
# Allow unused variables when underscore-prefixed. | ||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" | ||
|
||
target-version = "py38" | ||
|
||
[tool.ruff.per-file-ignores] | ||
"__init__.py" = ["F401"] | ||
|
||
[tool.ruff.flake8-quotes] | ||
docstring-quotes = "double" | ||
inline-quotes = "single" | ||
multiline-quotes = "single" | ||
|
||
|
||
[tool.black] | ||
line-length = 128 | ||
skip-string-normalization = true | ||
target-version = ['py38'] |