Skip to content

Commit 37904f9

Browse files
committed
added lint checks
1 parent a0d93a0 commit 37904f9

File tree

1 file changed

+147
-39
lines changed

1 file changed

+147
-39
lines changed

community/understand-lint-checks.md

Lines changed: 147 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,169 @@ title: Understand Checks before PR
44
sidebar_label: Understand Checks before PR
55
sidebar_position: 3
66
---
7+
# 🧠 Recode Python Backend Development Guide
78

8-
Thank you for considering contributing to CodeHarborHub! We welcome contributions from everyone. Whether you're a seasoned developer or just starting out, there are many ways to get involved and help improve CodeHarborHub. This document outlines the guidelines for contributing to this project.
9+
Welcome to Recode! To maintain a high standard of code quality, we follow a strict development and pull request process.
10+
Before submitting your PR, please **follow the instructions below and attach a screenshot of the checks passed**.
911

10-
## Getting Started
12+
---
13+
14+
## 📦 Prerequisites
15+
16+
- Python **3.8 or higher**
17+
- `pip` (Python package installer)
18+
- Git
19+
20+
---
21+
22+
## 🛠️ Tools and Configuration
23+
24+
### 🔧 Core Linting and QA Tools
25+
26+
We use the following tools to enforce code quality:
27+
28+
- `flake8`: Enforces PEP8 compliance
29+
- `black`: Code formatting with 88-char line width
30+
- `isort`: Automatically sorts imports
31+
- `mypy`: Static type checking with strict rules
32+
- `bandit`: Security vulnerability scanning
33+
- `safety`: Checks for insecure packages
34+
- `pre-commit`: Git hook to ensure checks are run before commit
35+
36+
### ⚙️ Config Files
37+
38+
| File | Purpose |
39+
|---------------------------|---------------------------------------------------------------------|
40+
| `.flake8` | Linting rules with complexity settings |
41+
| `pyproject.toml` | Central config for `black`, `isort`, `mypy`, and `coverage` |
42+
| `.pre-commit-config.yaml` | Pre-commit setup for linting, typing, formatting, and security |
43+
| `requirements-dev.txt` | Dev dependencies with fixed versions |
44+
| `.github/workflows/lint.yml` | CI/CD workflow for automated PR checks |
45+
| `Makefile` | Common commands for easy use |
46+
47+
---
48+
49+
## 🧪 Development Setup
50+
51+
### 🔄 Install Dev Dependencies
52+
53+
```bash
54+
pip install -r requirements-dev.txt
55+
pre-commit install
56+
57+
58+
📋 Makefile Commands
59+
Use these commands for a smooth workflow:
60+
61+
make install # Set up the development environment
62+
make format # Auto-format code (black + isort)
63+
make lint # Run flake8, mypy, bandit, etc.
64+
make test # Run tests with coverage report
65+
make all # Run everything above in sequence
66+
67+
68+
🧹 Code Quality Checks
69+
🖤 Code Formatting
70+
71+
black .
72+
isort .
73+
74+
🧭 Code Quality Standards
75+
| Standard | Tool(s) |
76+
| -------------------- | ------------------ |
77+
| PEP 8 Compliance | `flake8` |
78+
| Formatting (88-char) | `black` |
79+
| Sorted Imports | `isort` |
80+
| Static Typing | `mypy` |
81+
| Security Checks | `bandit`, `safety` |
82+
| Git Hook Automation | `pre-commit` |
83+
| Test Coverage | `pytest --cov` |
84+
85+
86+
📁 Project Structure
87+
📁 backend/
88+
├── __init__.py # Package initialization
89+
├── user_service.py # Service logic with type hints
90+
├── test_user_service.py # Pytest-based test suite
91+
📁 docs/python/
92+
└── code-quality-setup.md # Developer setup guide
93+
94+
95+
🚀 GitHub Actions Integration
96+
Our CI/CD pipeline automatically runs on every pull request and includes:
97+
98+
Python versions: 3.8, 3.9, 3.10, 3.11
99+
100+
Code formatting validation (black)
11101

12-
To get started with contributing to Recode-Hive, please refer to our [Contributing Guidelines](/community/contributing-guidelines).
102+
Linting and static typing checks (flake8, mypy)
13103

14-
Follow these steps:
104+
Security scanning (bandit, safety)
15105

106+
Test execution and coverage report
16107

17-
```mermaid
18-
flowchart LR
19-
Fork[Fork the project]-->branch[Create a New Branch]
20-
branch-->Edit[Edit file]
21-
Edit-->commit[Commit the changes]
22-
commit -->|Finally|creatpr((Create a Pull Request))
23-
```
108+
📸 Pull Request Submission Checklist
109+
Before opening a pull request:
24110

25-
1. **Clone the repository:**
26-
```bash
27-
git clone https://github.com/your-username/recodehive-website.git
28-
```
111+
✅ Run make all to ensure all checks pass
29112

30-
2. **Navigate to the project directory:**
31-
```bash
32-
cd recodehive-website
33-
```
113+
✅ Run python validate_config.py
34114

35-
3. **Install dependencies:**
36-
```bash
37-
npm install
38-
```
115+
📸 Take a screenshot showing the terminal output
39116

40-
4. **Running the Application:**
117+
📎 Attach the screenshot as a comment in your PR
41118

42-
Once you have installed the dependencies, you can run the application locally using:
43-
```bash
44-
npm i
45-
```
46-
```bash
47-
npm start
48-
```
119+
🧪 Config Validation Script
120+
Run this before submitting a PR:
49121

50-
This command will start a development server and open the application in your default web browser.
122+
bash
123+
Copy
124+
Edit
125+
python validate_config.py
126+
You should see:
51127

52-
**If you'd like to contribute to CodeHarborHub, please follow these guidelines:**
128+
pgsql
129+
Copy
130+
Edit
131+
✓ All checks passed! Python linting infrastructure is ready.
53132

54-
- **Fork** the repository and clone it locally.
55-
- Create a new branch for your feature or bug fix: `git checkout -b feature-name`
56-
- Make your changes and test thoroughly.
57-
- Commit your changes: `git commit -m "Brief description of your changes"`
58-
- Push to the branch: `git push origin feature-name`
59-
- Submit a pull request detailing your changes.
60133

61134

135+
🧹 Code Quality Checks
136+
🖤 Code Formatting
137+
bash
138+
Copy
139+
Edit
140+
black .
141+
isort .
142+
🧪 Linting & Typing
143+
bash
144+
Copy
145+
Edit
146+
flake8 .
147+
mypy .
148+
🔐 Security Scans
149+
bash
150+
Copy
151+
Edit
152+
bandit -r .
153+
safety check
154+
🔁 Run Pre-commit on All Files
155+
bash
156+
Copy
157+
Edit
158+
pre-commit run --all-files
159+
🧪 Testing
160+
Run Unit Tests
161+
bash
162+
Copy
163+
Edit
164+
pytest
165+
Run Tests with Coverage Report
166+
bash
167+
Copy
168+
Edit
169+
pytest --cov=. --cov-report=html
62170
## License
63171

64172
This project is licensed under the [MIT License](/License).

0 commit comments

Comments
 (0)