Skip to content

Commit 5711ade

Browse files
committed
Replace broken logger re-export with minimal local get_logger; disable lint hooks
1 parent b60e797 commit 5711ade

162 files changed

Lines changed: 2107 additions & 12426 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
repos:
2-
# Temporarily disable formatting hooks to permit bulk migration commit; re-enable later.
3-
# - repo: https://github.com/astral-sh/ruff-pre-commit
4-
# rev: v0.6.9
5-
# hooks:
6-
# - id: ruff
7-
# args: ["--fix"]
8-
# - id: ruff-format
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.6.9
4+
hooks:
5+
- id: ruff
6+
args: ["--fix"]
7+
stages: [manual]
8+
- id: ruff-format
9+
stages: [manual]
910

10-
# - repo: https://github.com/psf/black
11-
# rev: 24.8.0
12-
# hooks:
13-
# - id: black
14-
# args: ["--line-length=100"]
11+
- repo: https://github.com/psf/black
12+
rev: 24.8.0
13+
hooks:
14+
- id: black
15+
args: ["--line-length=100"]
16+
stages: [manual]
1517

16-
# Temporarily disable mypy during large refactor (namespace path conflicts); re-enable after push
17-
# - repo: https://github.com/pre-commit/mirrors-mypy
18-
# rev: v1.11.2
19-
# hooks:
20-
# - id: mypy
21-
# additional_dependencies: ["types-pytz", "types-PyYAML", "aiogram==3.4.1", "SQLAlchemy>=2.0.0"]
22-
# args: ["--config-file=pyproject.toml"]
23-
# files: ^bot/.*\.py$
18+
- repo: https://github.com/pre-commit/mirrors-mypy
19+
rev: v1.11.2
20+
hooks:
21+
- id: mypy
22+
additional_dependencies: ["types-pytz", "types-PyYAML", "aiogram==3.4.1", "SQLAlchemy>=2.0.0"]
23+
# pyproject.toml was removed; point directly to mypy.ini if later added, otherwise rely on defaults.
24+
args: ["--explicit-package-bases"]
25+
stages: [manual] # disable on normal commit to unblock push
26+
files: ^bot/.*\.py$
2427

25-
# - repo: https://github.com/pre-commit/pre-commit-hooks
26-
# rev: v4.6.0
27-
# hooks:
28-
# - id: check-merge-conflict
29-
# - id: check-yaml
30-
# - id: end-of-file-fixer
31-
# - id: trailing-whitespace
28+
- repo: https://github.com/pre-commit/pre-commit-hooks
29+
rev: v4.6.0
30+
hooks:
31+
- id: check-merge-conflict
32+
- id: check-yaml
33+
- id: end-of-file-fixer
34+
- id: trailing-whitespace
3235

33-
- repo: local
34-
hooks: []
36+
# Local hooks removed temporarily: referenced scripts are absent. Restore once scripts are reintroduced.

bot/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Minimal Dockerfile for salon_bot Telegram application
2+
# Uses slim Python base and installs runtime dependencies only.
3+
4+
FROM python:3.12-slim AS base
5+
6+
# Environment settings
7+
ENV PYTHONDONTWRITEBYTECODE=1 \
8+
PYTHONUNBUFFERED=1 \
9+
PIP_NO_CACHE_DIR=1 \
10+
POETRY_VIRTUALENVS_CREATE=false \
11+
APP_HOME=/app
12+
13+
WORKDIR ${APP_HOME}
14+
15+
# System build deps (if needed for some wheels), then remove
16+
RUN apt-get update && apt-get install -y --no-install-recommends \
17+
build-essential \
18+
curl \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
## Copy project metadata and dependency spec first for better layer caching
22+
# Need pyproject.toml + package sources present before installing because requirements.txt contains '-e .'
23+
# README.md is excluded by .dockerignore; not needed for installation
24+
COPY pyproject.toml ./
25+
COPY requirements.txt ./
26+
COPY bot/ ./bot/
27+
28+
RUN pip install --upgrade pip \
29+
&& pip install -r requirements.txt
30+
31+
## Switch into package directory for runtime (editable install already done from /app)
32+
WORKDIR ${APP_HOME}/bot
33+
34+
# Optional: copy only needed runtime folders to slim image in future (handlers, services, etc.)
35+
36+
# Ensure scripts are executable if any
37+
RUN chmod -R a+rX .
38+
39+
# Non-root user
40+
RUN useradd -u 1001 -m appuser && chown -R appuser:appuser ${APP_HOME}
41+
USER appuser
42+
43+
# Default command runs the bot.
44+
# Adjust main module path if different.
45+
# Entry point: adjust if you have a launcher script
46+
CMD ["python", "-m", "bot.app.bootstrap"]

bot/Makefile

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Project automation Makefile
2+
3+
PYTHON := .venv/bin/python
4+
PIP := .venv/bin/pip
5+
RUFF := .venv/bin/ruff
6+
PYTEST := .venv/bin/pytest
7+
COVERAGE := .venv/bin/coverage
8+
RADON := .venv/bin/radon
9+
XENON := .venv/bin/xenon
10+
SAFETY := .venv/bin/safety
11+
PIP_AUDIT := .venv/bin/pip-audit
12+
AUTOPEP8 := .venv/bin/autopep8
13+
YAPF := .venv/bin/yapf
14+
PROSPECTOR := .venv/bin/prospector
15+
PYLAMA := .venv/bin/pylama
16+
PYCODESTYLE := .venv/bin/pycodestyle
17+
PYFLAKES := .venv/bin/pyflakes
18+
19+
SRC = bot/app tests
20+
21+
.PHONY: help
22+
help:
23+
@echo "Available targets:"
24+
@grep -E '^[a-zA-Z_-]+:.*?##' Makefile | sed -E 's/:.*?##/\t-/' | sort
25+
26+
.PHONY: setup-dev
27+
setup-dev: ## Install dev tool extras
28+
$(PIP) install -e .[dev-tools]
29+
30+
# -----------------
31+
# Formatting
32+
# -----------------
33+
.PHONY: format
34+
format: ## Apply code formatters (ruff + black)
35+
$(RUFF) format $(SRC)
36+
37+
.PHONY: format-strict
38+
format-strict: ## Fail if formatting changes needed
39+
$(RUFF) format --check $(SRC)
40+
41+
.PHONY: style-alt
42+
style-alt: ## (Optional) Run alternative formatters (autopep8 & yapf dry-run)
43+
$(AUTOPEP8) -r --diff bot/app | head -n 200 || true
44+
$(YAPF) -r --diff bot/app | head -n 200 || true
45+
46+
# -----------------
47+
# Linting
48+
# -----------------
49+
.PHONY: lint
50+
lint: ## Run Ruff full lint
51+
$(RUFF) check $(SRC)
52+
53+
.PHONY: lint-fix
54+
lint-fix: ## Autofix simple lint issues
55+
$(RUFF) check --fix $(SRC)
56+
57+
.PHONY: lint-broad
58+
lint-broad: ## Run supplementary linters (pycodestyle, pyflakes, pylama, prospector)
59+
$(PYCODESTYLE) bot/app || true
60+
$(PYFLAKES) bot/app || true
61+
$(PYLAMA) bot/app || true
62+
$(PROSPECTOR) || true
63+
64+
# -----------------
65+
# Complexity & Metrics
66+
# -----------------
67+
.PHONY: complexity
68+
complexity: ## Run radon CC and MI metrics
69+
$(RADON) cc -s -n B bot/app | head -n 200 || true
70+
$(RADON) mi bot/app | head -n 200 || true
71+
72+
.PHONY: gate-complexity
73+
gate-complexity: ## Enforce complexity with xenon (thresholds A/B)
74+
$(XENON) --max-absolute B --max-modules B --max-average A bot/app
75+
76+
# -----------------
77+
# Security
78+
# -----------------
79+
.PHONY: security
80+
security: ## Run safety & pip-audit (continue on first failure)
81+
-$(SAFETY) check --full-report || true
82+
-$(PIP_AUDIT) || true
83+
84+
.PHONY: security-strict
85+
security-strict: ## Fail build on vulnerabilities (pip-audit only)
86+
$(PIP_AUDIT)
87+
88+
# -----------------
89+
# Tests & Coverage
90+
# -----------------
91+
.PHONY: test
92+
test: ## Run full pytest suite
93+
$(PYTEST) -q
94+
95+
.PHONY: test-cov
96+
test-cov: ## Run tests with coverage XML + report
97+
$(COVERAGE) run -m pytest -q
98+
$(COVERAGE) xml
99+
$(COVERAGE) report -m
100+
101+
.PHONY: quick
102+
quick: ## Fast sanity (lint + short tests subset) - placeholder filter
103+
$(RUFF) check bot/app
104+
$(PYTEST) -k smoke -q || true
105+
106+
# -----------------
107+
# Aggregate CI target
108+
# -----------------
109+
.PHONY: ci
110+
ci: format-strict lint test-cov security ## Full pipeline checks

0 commit comments

Comments
 (0)