You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 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
+
```
27
25
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.
30
27
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
+
```
36
84
37
85
## Development Process
38
86
39
87
1. Fork the repository and set the upstream remote
40
88
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
41
89
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.
45
93
7. Commit your changes (`git commit -m 'Add some amazing feature'`)
46
94
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.
48
96
49
97
## Code Style
50
98
51
99
We use the following tools to ensure code quality:
52
100
53
-
-**ruff** for linting
101
+
- **ruff**for linting and formatting
54
102
- **mypy**fortype checking
55
103
56
104
Please make sure your code passes all checks before submitting a pull request:
57
105
58
106
```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
64
108
ruff check .
109
+
ruff format .
110
+
111
+
# Check types
65
112
mypy .
66
113
```
67
114
@@ -70,10 +117,7 @@ mypy .
70
117
We use pytest for testing. Please write tests for any new features and ensure all tests pass:
71
118
72
119
```bash
73
-
# Using uv
74
-
uv run pytest
75
-
76
-
# Or directly
120
+
# Run all tests
77
121
pytest
78
122
```
79
123
@@ -96,4 +140,4 @@ Please note we have a code of conduct, please follow it in all your interactions
96
140
97
141
## Questions?
98
142
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