Refactor store_message function and add Simple Git Hooks (#1827)
This pull request adds Simple Git Hooks for better code quality and consistency. It also updates the pre-commit-config.yaml and Makefile, and refactors the pre-commit installation in the Makefile. Additionally, the update_poetry.sh script is refactored to not install pipx anymore.
This commit is contained in:
commit
0ce2853f4c
7 changed files with 134 additions and 87 deletions
24
.pre-commit-config.yaml
Normal file
24
.pre-commit-config.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
repos:
|
||||
- repo: https://github.com/pre-commit/mirrors-eslint
|
||||
rev: "v9.1.1"
|
||||
hooks:
|
||||
- id: eslint
|
||||
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
|
||||
types: [file]
|
||||
additional_dependencies:
|
||||
- eslint-plugin-prettier
|
||||
- eslint-config-prettier
|
||||
- prettier
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: v0.4.2
|
||||
hooks:
|
||||
# Run the linter.
|
||||
- id: ruff
|
||||
# Python
|
||||
files: \.py$
|
||||
types: [file]
|
||||
# Run the formatter.
|
||||
- id: ruff-format
|
||||
files: \.py$
|
||||
types: [file]
|
||||
1
Makefile
1
Makefile
|
|
@ -123,6 +123,7 @@ setup_devcontainer:
|
|||
setup_env:
|
||||
@sh ./scripts/setup/update_poetry.sh 1.8.2
|
||||
@sh ./scripts/setup/setup_env.sh
|
||||
@poetry run pre-commit install
|
||||
|
||||
frontend:
|
||||
make install_frontend
|
||||
|
|
|
|||
90
poetry.lock
generated
90
poetry.lock
generated
|
|
@ -828,6 +828,17 @@ files = [
|
|||
[package.dependencies]
|
||||
pycparser = "*"
|
||||
|
||||
[[package]]
|
||||
name = "cfgv"
|
||||
version = "3.4.0"
|
||||
description = "Validate configuration and produce human readable error messages."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"},
|
||||
{file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chardet"
|
||||
version = "5.2.0"
|
||||
|
|
@ -1604,6 +1615,17 @@ files = [
|
|||
{file = "diskcache-5.6.3.tar.gz", hash = "sha256:2c3a3fa2743d8535d832ec61c2054a1641f41775aa7c556758a109941e33e4fc"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "distlib"
|
||||
version = "0.3.8"
|
||||
description = "Distribution utilities"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
files = [
|
||||
{file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"},
|
||||
{file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "distro"
|
||||
version = "1.9.0"
|
||||
|
|
@ -3143,6 +3165,20 @@ files = [
|
|||
{file = "hyperframe-6.0.1.tar.gz", hash = "sha256:ae510046231dc8e9ecb1a6586f63d2347bf4c8905914aa84ba585ae85f28a914"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "identify"
|
||||
version = "2.5.36"
|
||||
description = "File identification library for Python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "identify-2.5.36-py2.py3-none-any.whl", hash = "sha256:37d93f380f4de590500d9dba7db359d0d3da95ffe7f9de1753faa159e71e7dfa"},
|
||||
{file = "identify-2.5.36.tar.gz", hash = "sha256:e5e00f54165f9047fbebeb4a560f9acfb8af4c88232be60a488e9b68d122745d"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
license = ["ukkonen"]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.7"
|
||||
|
|
@ -5229,6 +5265,20 @@ plot = ["matplotlib"]
|
|||
tgrep = ["pyparsing"]
|
||||
twitter = ["twython"]
|
||||
|
||||
[[package]]
|
||||
name = "nodeenv"
|
||||
version = "1.8.0"
|
||||
description = "Node.js virtual environment builder"
|
||||
optional = false
|
||||
python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*"
|
||||
files = [
|
||||
{file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"},
|
||||
{file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
setuptools = "*"
|
||||
|
||||
[[package]]
|
||||
name = "numexpr"
|
||||
version = "2.10.0"
|
||||
|
|
@ -6215,6 +6265,24 @@ dev = ["black", "flake8", "flake8-print", "isort", "pre-commit"]
|
|||
sentry = ["django", "sentry-sdk"]
|
||||
test = ["coverage", "flake8", "freezegun (==0.3.15)", "mock (>=2.0.0)", "pylint", "pytest", "pytest-timeout"]
|
||||
|
||||
[[package]]
|
||||
name = "pre-commit"
|
||||
version = "3.7.0"
|
||||
description = "A framework for managing and maintaining multi-language pre-commit hooks."
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
files = [
|
||||
{file = "pre_commit-3.7.0-py2.py3-none-any.whl", hash = "sha256:5eae9e10c2b5ac51577c3452ec0a490455c45a0533f7960f993a0d01e59decab"},
|
||||
{file = "pre_commit-3.7.0.tar.gz", hash = "sha256:e209d61b8acdcf742404408531f0c37d49d2c734fd7cff2d6076083d191cb060"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
cfgv = ">=2.0.0"
|
||||
identify = ">=1.0.0"
|
||||
nodeenv = ">=0.11.1"
|
||||
pyyaml = ">=5.1"
|
||||
virtualenv = ">=20.10.0"
|
||||
|
||||
[[package]]
|
||||
name = "prometheus-client"
|
||||
version = "0.20.0"
|
||||
|
|
@ -9561,6 +9629,26 @@ files = [
|
|||
{file = "vine-5.1.0.tar.gz", hash = "sha256:8b62e981d35c41049211cf62a0a1242d8c1ee9bd15bb196ce38aefd6799e61e0"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "virtualenv"
|
||||
version = "20.26.1"
|
||||
description = "Virtual Python Environment builder"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "virtualenv-20.26.1-py3-none-any.whl", hash = "sha256:7aa9982a728ae5892558bff6a2839c00b9ed145523ece2274fad6f414690ae75"},
|
||||
{file = "virtualenv-20.26.1.tar.gz", hash = "sha256:604bfdceaeece392802e6ae48e69cec49168b9c5f4a44e483963f9242eb0e78b"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
distlib = ">=0.3.7,<1"
|
||||
filelock = ">=3.12.2,<4"
|
||||
platformdirs = ">=3.9.1,<5"
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"]
|
||||
test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"]
|
||||
|
||||
[[package]]
|
||||
name = "watchfiles"
|
||||
version = "0.21.0"
|
||||
|
|
@ -10253,4 +10341,4 @@ local = ["ctransformers", "llama-cpp-python", "sentence-transformers"]
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = ">=3.10,<3.12"
|
||||
content-hash = "bec34397b534f882551511558c76785c7cd67e6a1eefc1d45f6a64d97175d886"
|
||||
content-hash = "b3d424bc8e83a9f10a8e71f95e2499b3018711d8edf7a594814b9388e5393a84"
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ respx = "^0.21.1"
|
|||
pytest-instafail = "^0.5.0"
|
||||
pytest-asyncio = "^0.23.0"
|
||||
pytest-profiling = "^1.7.0"
|
||||
pre-commit = "^3.7.0"
|
||||
|
||||
[tool.poetry.extras]
|
||||
deploy = ["celery", "redis", "flower"]
|
||||
|
|
|
|||
|
|
@ -32,90 +32,6 @@ case "$OS" in
|
|||
;;
|
||||
esac
|
||||
|
||||
echo "Detected Operating System: $OS"
|
||||
|
||||
# Installation of pipx based on the detected OS
|
||||
install_pipx() {
|
||||
case $1 in
|
||||
macOS)
|
||||
# macOS installation using Homebrew
|
||||
command -v brew >/dev/null 2>&1 || exit_with_message "Homebrew is not installed. Please install Homebrew first."
|
||||
echo "Installing pipx using Homebrew..."
|
||||
brew install pipx
|
||||
pipx ensurepath
|
||||
;;
|
||||
Linux)
|
||||
# Linux installation. Further checks are needed to distinguish between distributions
|
||||
if grep -qEi "(ubuntu|debian)" /etc/*release; then
|
||||
echo "Installing pipx on Ubuntu/Debian..."
|
||||
sudo apt update
|
||||
sudo apt install pipx -y
|
||||
elif grep -qEi "fedora" /etc/*release; then
|
||||
echo "Installing pipx on Fedora..."
|
||||
sudo dnf install pipx -y
|
||||
else
|
||||
echo "Installing pipx using pip (other Linux distributions)..."
|
||||
python3 -m pip install --user pipx
|
||||
fi
|
||||
pipx ensurepath
|
||||
;;
|
||||
*)
|
||||
exit_with_message "Unsupported operating system for pipx installation."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to fetch the latest version of pipx from GitHub and compare with the installed version
|
||||
check_for_pipx_update() {
|
||||
echo "Checking for updates to pipx..."
|
||||
# Fetch the latest version of pipx, ensuring only to capture the numeric version without 'v' prefix.
|
||||
local latest_version=$(curl -s https://api.github.com/repos/pypa/pipx/releases/latest | grep '"tag_name":' | sed -E 's/.*"tag_name": "v?([^"]+)".*/\1/')
|
||||
# Extract the current installed version of pipx.
|
||||
local current_version=$(pipx --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
|
||||
if [[ "$latest_version" == "$current_version" ]]; then
|
||||
echo "You have the latest version of pipx ($current_version)."
|
||||
else
|
||||
echo "A newer version of pipx ($latest_version) is available. You have $current_version. Do you want to update? (yes/no)"
|
||||
read -r user_input
|
||||
if [[ "$user_input" == "yes" ]]; then
|
||||
echo "Updating pipx..."
|
||||
case "$OS" in
|
||||
macOS)
|
||||
brew upgrade pipx
|
||||
;;
|
||||
Linux)
|
||||
if grep -qEi "(ubuntu|debian)" /etc/*release; then
|
||||
sudo apt update
|
||||
sudo apt install --only-upgrade pipx -y
|
||||
elif grep -qEi "fedora" /etc/*release; then
|
||||
sudo dnf upgrade pipx -y
|
||||
else
|
||||
python3 -m pip install --user --upgrade pipx
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit_with_message "Unsupported operating system for pipx update."
|
||||
;;
|
||||
esac
|
||||
pipx ensurepath
|
||||
echo "pipx updated to version $latest_version"
|
||||
else
|
||||
echo "Not updating pipx at this time."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Now, modify the existing check to call check_for_pipx_update even if pipx is installed
|
||||
if ! command -v pipx &> /dev/null; then
|
||||
echo "Pipx is not installed. Installing..."
|
||||
install_pipx "$OS"
|
||||
echo "Pipx installed successfully."
|
||||
else
|
||||
echo "Pipx is already installed."
|
||||
check_for_pipx_update
|
||||
fi
|
||||
|
||||
|
||||
echo "Checking Poetry installation..."
|
||||
|
||||
|
|
@ -124,7 +40,7 @@ if ! command -v poetry &> /dev/null
|
|||
then
|
||||
echo "Poetry is not installed. Installing..."
|
||||
# Also install python 3.10 and use
|
||||
pipx install poetry --python python3.10 --fetch-missing-python
|
||||
curl -sSL https://install.python-poetry.org | python3 -
|
||||
echo "Poetry installed successfully."
|
||||
else
|
||||
echo "Poetry is already installed."
|
||||
|
|
@ -146,3 +62,5 @@ else
|
|||
echo "Poetry version is $1 or higher. No need to update."
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
11
src/frontend/package-lock.json
generated
11
src/frontend/package-lock.json
generated
|
|
@ -99,6 +99,7 @@
|
|||
"prettier-plugin-organize-imports": "^3.2.3",
|
||||
"prettier-plugin-tailwindcss": "^0.3.0",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"simple-git-hooks": "^2.11.1",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tailwindcss-dotted-background": "^1.1.0",
|
||||
"typescript": "^5.2.2",
|
||||
|
|
@ -11917,6 +11918,16 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/simple-git-hooks": {
|
||||
"version": "2.11.1",
|
||||
"resolved": "https://registry.npmjs.org/simple-git-hooks/-/simple-git-hooks-2.11.1.tgz",
|
||||
"integrity": "sha512-tgqwPUMDcNDhuf1Xf6KTUsyeqGdgKMhzaH4PAZZuzguOgTl5uuyeYe/8mWgAr6IBxB5V06uqEf6Dy37gIWDtDg==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"bin": {
|
||||
"simple-git-hooks": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/sisteransi": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz",
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@
|
|||
"format": "npx prettier --write \"./**/*.{js,jsx,ts,tsx,json,md}\" --ignore-path .prettierignore",
|
||||
"type-check": "tsc --noEmit --pretty --project tsconfig.json && vite"
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"pre-commit": "npx pretty-quick --staged"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
|
|
@ -121,10 +124,11 @@
|
|||
"prettier-plugin-organize-imports": "^3.2.3",
|
||||
"prettier-plugin-tailwindcss": "^0.3.0",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"simple-git-hooks": "^2.11.1",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tailwindcss-dotted-background": "^1.1.0",
|
||||
"typescript": "^5.2.2",
|
||||
"ua-parser-js": "^1.0.37",
|
||||
"vite": "^4.5.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue