From 34b180159f2215f946dd2921d2af39d821a51026 Mon Sep 17 00:00:00 2001 From: Ritabear Date: Mon, 17 Jun 2024 00:09:47 +0800 Subject: [PATCH 1/2] feat: pre-commit --- .pre-commit-config.yaml | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..9f108d0b5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,63 @@ +# https://github.com/pre-commit/pre-commit-hooks/blob/master/.pre-commit-config.yaml +# https://rednafi.github.io/digressions/python/2020/04/06/python-precommit.html +# manually run : poetry run pre-commit run --all-files +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + alias: Trim + - id: end-of-file-fixer + - id: check-added-large-files + - id: check-yaml + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + args: + - '--line-length=120' + - '--multi-line=3' + - '--trailing-comma' + - repo: https://github.com/asottile/pyupgrade + rev: v3.3.1 + hooks: + - id: pyupgrade + args: [--py38-plus] + - repo: https://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + args: + - '--select=B,C,E,F,W,T4,B9' + - '--max-line-length=120' + - '--ignore=E203,E265,E266,E402,E501,W391,W503' + - '--exclude=.git,.venv,__pycache__,build,dist,__init__.py' + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.1.1 + hooks: + - id: mypy + name: mypy + entry: mypy + args: + - '--explicit-package-bases' + - '--ignore-missing-imports' + - '--scripts-are-modules' + - '--no-site-packages' + - '--implicit-optional' + - '--exclude="(tmp|.venv)/$"' + - repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + name: black - code formatter + entry: black . + verbose: True + args: + - '--line-length=120' + - '--skip-string-normalization' + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.9 + hooks: + - id: ruff + args: [ --fix ] + - id: ruff-format From a251acea83cad45c26e457453486f039031242f0 Mon Sep 17 00:00:00 2001 From: Ritabear Date: Sat, 29 Jun 2024 12:29:45 +0800 Subject: [PATCH 2/2] feat:add new settings --- .pre-commit-config.yaml | 22 +++++++++ pyproject.toml | 2 +- src/pycontw2016/pyproject.toml | 82 ++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml create mode 100644 src/pycontw2016/pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..7101f3483 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.9 + hooks: + - id: ruff + name: ruff linter + args: [ + --fix, + --show-fixes, + ] + - id: ruff-format + name: ruff formatter diff --git a/pyproject.toml b/pyproject.toml index 14114a33e..8796d1977 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ sorl-thumbnail = "12.10.0" tabulate = "0.9.0" uwsgi = "2.0.24" Pillow = "10.3.0" - +pre-commit = "3.7.1" [tool.poetry.group.dev.dependencies] cssselect = "1.2.0" diff --git a/src/pycontw2016/pyproject.toml b/src/pycontw2016/pyproject.toml new file mode 100644 index 000000000..b4a383747 --- /dev/null +++ b/src/pycontw2016/pyproject.toml @@ -0,0 +1,82 @@ +[tool.poetry] +name = "pycontw-backend" +version = "0.1.0" +description = "The API backend and proposal system of PyCon TW website." +authors = ["PyCon TW Web Team "] +readme = "README.md" +package-mode = false + +[tool.poetry.dependencies] +python = "~3.10.0" + +Django = "3.2.25" +crispy-bootstrap3 = "2024.1" +dj-registry = "0.2.2" +django-cors-headers = "4.3.1" +django-compressor = "4.4" +django-compressor-toolkit = "0.6.0" +django-crispy-forms = "2.0" +django-environ = "0.11.2" +django-extensions = "3.2.3" +django-import-export = "3.3.8" +django-modeltranslation = "0.18.11" +django-storages = "1.14.2" +djangorestframework = "3.15.1" +google-cloud-storage = "1.44.0" +ipython = "8.23.0" +lxml = "4.9.4" +psycopg2 = "2.9.9" +pytz = "2024.1" +requests = "2.32.0" +sorl-thumbnail = "12.10.0" +tabulate = "0.9.0" +uwsgi = "2.0.24" +Pillow = "10.3.0" +pre-commit = "3.7.1" + +[tool.poetry.group.dev.dependencies] +cssselect = "1.2.0" +django-debug-toolbar = "4.3.0" +pytest = "8.1.1" +pytest-cov = "5.0.0" +pytest-django = "4.8.0" +pytest-mock = "3.14.0" +pytest-xdist = "3.5.0" +ruff = "0.3.5" +Werkzeug = "3.0.3" + + +[tool.ruff] +exclude = [".git", "__pycache__", "migrations"] +line-length = 120 + +[tool.ruff.lint] +ignore = ["E251"] +select = [ + "E", # pycodestyle error + "W", # pycodestyle warning + "F", # Pyflakes + "I001", # isort + "N", # pep8-naming + "B", # bugbear + "UP", # pyupgrade +] + +[tool.ruff.lint.isort] +known-first-party = [ + "attendee", + "ccip", + "core", + "events", + "postgres", + "proposals", + "pycontw2016", + "reviews", + "sponsors", + "users", +] + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"