File: CONTRIBUTING.md

package info (click to toggle)
python-asusrouter 1.21.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,856 kB
  • sloc: python: 20,497; makefile: 3
file content (150 lines) | stat: -rw-r--r-- 4,522 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Contributing to AsusRouter

This document describes the basics of contributing to the **AsusRouter** project.

_This file was auto-generated by **GitHub Copilot**, so minor adjustments may be needed. If you notice any issues or have suggestions for improvement, please feel free to submit a pull request or open an issue._

This project uses [uv](https://github.com/astral-sh/uv), [pre-commit](https://pre-commit.com/), and [Visual Studio Code](https://code.visualstudio.com/).

Please follow these guidelines for a smooth development experience.

---

## Development Environment Setup

1. **Clone the repository**

   ```sh
   git clone https://github.com/Vaskivskyi/asusrouter.git
   cd asusrouter
   ```

2. **Python Virtual Environment**

   - The project uses a `.venv` in the root directory.
   - Create it with:
     ```sh
     uv venv
     ```
   - In VS Code, select the interpreter from `.venv` via the Command Palette:
     `Python: Select Interpreter`.

3. **Install dependencies**

   - Install all dependencies (including dev and test) with:
     ```sh
     uv sync --all-groups
     ```

4. **Install pre-commit hooks**

   - Install pre-commit if not already installed:
     ```sh
     uv pip install pre-commit
     ```
   - Set up the hooks:
     ```sh
     pre-commit install
     ```
   - (Optional but recommended) Run on all files to check/fix the codebase:
     ```sh
     pre-commit run --all-files
     ```
   - **Note:** All commits will be checked by pre-commit hooks. You must fix any issues before committing.

5. **VS Code Workspace**

   - The `.vscode` folder is versioned and contains:
     - **Recommended extensions** (`extensions.json`)
     - **Editor settings** (`settings.json`)
     - **Common tasks** (`tasks.json`)
   - VS Code should prompt you to install recommended extensions on open.

---

## Recommended VS Code Extensions

These are listed in `.vscode/extensions.json` and will be suggested automatically:

- [Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) (`charliermarsh.ruff`)
- [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) (`esbenp.prettier-vscode`)
- [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) (`ms-python.python`)

---

## Recommended VS Code Settings

These are already included in `.vscode/settings.json`:

```jsonc
{
  "editor.formatOnSave": true,
  "[python]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.fixAll": "explicit",
      "source.organizeImports": "explicit"
    },
    "editor.defaultFormatter": "charliermarsh.ruff"
  },
  "python.analysis.typeCheckingMode": "basic",
  "mypy-type-checker.args": ["--config-file=pyproject.toml"]
}
```

---

## Common Tasks

### Dependencies and development

You can run common development tasks from the VS Code Command Palette (`Ctrl+Shift+P` → "Run Task") or from the terminal:

- **Install requirements:**
  `uv sync`
- **Install dev requirements:**
  `uv sync --group dev`
- **Install test requirements:**
  `uv sync --group test`
- **Run tests:**
  Use the provided tasks in `.vscode/tasks.json` for different Python versions and test types.
- **Build package:**
  `uv build`

### Testing

You can run test suites using the pre-configured tasks. All the needed requirements for testing will be installed automatically.

- **Run Pytest / 3.{xx} / Unit:**
  Run all the unit tests for a corresponding Python version.
  Tasks include all the supported Python versions as per the `pyproject.toml` file.
- **Run Pytest / Devices:**
  Run all the device tests (tests on the raw / pre-configured data parsed from the actual devices).
  This test is run on the latest supported Python version.

---

## Code Style, Linting and Checks

- **Ruff** is used for linting and formatting.
  Code style is enforced automatically via pre-commit and VS Code settings.
- **mypy** is used for type checking.
- **pre-commit** is required for all commits.
  You must run `pre-commit install` after cloning (see setup above) to ensure all commits are checked locally.
  PRs that do not pass pre-commit checks will be blocked until they are fixed.

---

## Pull Requests

- Ensure all pre-commit hooks pass before pushing.
- Make sure your code is covered by tests.
- Describe your changes clearly in the PR description.

---

## Need Help?

If you have any questions or issues, please open an issue on [GitHub](https://github.com/Vaskivskyi/asusrouter/issues).

---