Skip to content

Commit e8d5215

Browse files
committed
improve contibution guide
1 parent a5b190e commit e8d5215

File tree

1 file changed

+83
-39
lines changed

1 file changed

+83
-39
lines changed

CONTRIBUTING.md

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,114 @@
11
# Contributing to FastAPI-MCP
22

3-
First off, thank you for considering contributing to FastAPI-MCP!
3+
First off, thank you for considering contributing to FastAPI-MCP!
44

55
## Development Setup
66

7-
1. Make sure you have Python 3.10+ installed
8-
2. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) (recommended) or pip
9-
3. Fork the repository
10-
4. Clone your fork
7+
1. Make sure you have Python 3.10+ installed
8+
2. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) package manager
9+
3. Fork the repository
10+
4. Clone your fork
1111

12-
```bash
13-
# Clone your fork
14-
git clone https://github.com/YOUR-USERNAME/fastapi_mcp.git
15-
cd fastapi-mcp
12+
```bash
13+
git clone https://github.com/YOUR-USERNAME/fastapi_mcp.git
14+
cd fastapi-mcp
1615

17-
# Add the upstream remote
18-
git remote add upstream https://github.com/tadata-org/fastapi_mcp.git
19-
```
16+
# Add the upstream remote
17+
git remote add upstream https://github.com/tadata-org/fastapi_mcp.git
18+
```
2019

21-
5. Set up the development environment:
20+
5. Set up the development environment:
2221

23-
```bash
24-
# Create a virtual environment with uv (recommended)
25-
uv venv
26-
source .venv/bin/activate # On Windows: .venv\Scripts\activate
22+
```bash
23+
uv sync
24+
```
2725

28-
# Install development dependencies with uv
29-
uv sync --extra dev
26+
That's it! The `uv sync` command will automatically create and use a virtual environment.
3027
31-
# Alternatively, using pip
32-
# python -m venv venv
33-
# source venv/bin/activate # On Windows: venv\Scripts\activate
34-
# pip install -e ".[dev]"
35-
```
28+
6. Install pre-commit hooks:
29+
30+
```bash
31+
uv run pre-commit install
32+
uv run pre-commit run
33+
```
34+
35+
Pre-commit hooks will automatically run checks (like ruff, formatting, etc.) when you make a commit, ensuring your code follows our style guidelines.
36+
37+
### Running Commands
38+
39+
You have two options for running commands:
40+
41+
1. **With the virtual environment activated**:
42+
```bash
43+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
44+
45+
# Then run commands directly
46+
pytest
47+
mypy .
48+
ruff check .
49+
```
50+
51+
2. **Without activating the virtual environment**:
52+
```bash
53+
# Use uv run prefix for all commands
54+
uv run pytest
55+
uv run mypy .
56+
uv run ruff check .
57+
```
58+
59+
Both approaches work - use whichever is more convenient for you.
60+
61+
> **Note:** For simplicity, commands in this guide are mostly written **without** the `uv run` prefix. If you haven't activated your virtual environment, remember to prepend `uv run` to all python-related commands and tools.
62+
63+
### Adding Dependencies
64+
65+
When adding new dependencies to the library:
66+
67+
1. **Runtime dependencies** - packages needed to run the application:
68+
```bash
69+
uv add new-package
70+
```
71+
72+
2. **Development dependencies** - packages needed for development, testing, or CI:
73+
```bash
74+
uv add --group dev new-package
75+
```
76+
77+
After adding dependencies, make sure to:
78+
1. Test that everything works with the new package
79+
2. Commit both `pyproject.toml` and `uv.lock` files:
80+
```bash
81+
git add pyproject.toml uv.lock
82+
git commit -m "Add new-package dependency"
83+
```
3684

3785
## Development Process
3886

3987
1. Fork the repository and set the upstream remote
4088
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
4189
3. Make your changes
42-
4. Run type checking (`uv run mypy .`)
43-
5. Run the tests (`uv run pytest`)
44-
6. Format your code (`uv run ruff check .` and `uv run ruff format .`)
90+
4. Run type checking (`mypy .`)
91+
5. Run the tests (`pytest`)
92+
6. Format your code (`ruff check .` and `ruff format .`). Not needed if pre-commit is installed, as it will run it for you.
4593
7. Commit your changes (`git commit -m 'Add some amazing feature'`)
4694
8. Push to the branch (`git push origin feature/amazing-feature`)
47-
9. Open a Pull Request on [the project repository](https://github.com/tadata-org/fastapi_mcp/)
95+
9. Open a Pull Request. Make sure the Pull Request's base branch is [the original repository's](https://github.com/tadata-org/fastapi_mcp/) `main` branch.
4896

4997
## Code Style
5098

5199
We use the following tools to ensure code quality:
52100

53-
- **ruff** for linting
101+
- **ruff** for linting and formatting
54102
- **mypy** for type checking
55103

56104
Please make sure your code passes all checks before submitting a pull request:
57105

58106
```bash
59-
# Using uv
60-
uv run ruff check .
61-
uv run mypy .
62-
63-
# Or directly if tools are installed
107+
# Check code formatting and style
64108
ruff check .
109+
ruff format .
110+
111+
# Check types
65112
mypy .
66113
```
67114

@@ -70,10 +117,7 @@ mypy .
70117
We use pytest for testing. Please write tests for any new features and ensure all tests pass:
71118

72119
```bash
73-
# Using uv
74-
uv run pytest
75-
76-
# Or directly
120+
# Run all tests
77121
pytest
78122
```
79123

@@ -96,4 +140,4 @@ Please note we have a code of conduct, please follow it in all your interactions
96140
97141
## Questions?
98142
99-
Don't hesitate to open an issue if you have any questions about contributing to FastAPI-MCP.
143+
Don't hesitate to open an issue if you have any questions about contributing to FastAPI-MCP.

0 commit comments

Comments
 (0)