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
Copy file name to clipboardExpand all lines: docs/sdk_developers/ruff.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,33 @@ uv run ruff check . && uv run ruff format --check .
100
100
}
101
101
```
102
102
103
+
104
+
## 🛠️ Handling Linting Issues
105
+
106
+
### Manual vs. Automatic Fixes
107
+
108
+
Ruff is smart, but it won't change your code if it might break logic.
109
+
110
+
-**Auto-Fixed:** Unused imports, unsorted imports (Isort-style), and basic whitespace.
111
+
112
+
-**Manual Action Required:** Complex issues like unused function arguments (`ARG001`), overly complex logic (`C901`), or missing docstrings. You must refactor these yourself based on the terminal output.
113
+
114
+
115
+
### Ignoring Rules (Suppressing Warnings)
116
+
117
+
Sometimes, a linter rule conflicts with a specific technical requirement. You can tell Ruff to ignore a line using the `# noqa` comment followed by the error code.
118
+
119
+
```python
120
+
# Ignore a specific error on a line
121
+
import unused_module # noqa: F401
122
+
123
+
# Ignore multiple errors on a line
124
+
x =1# noqa: E701, F841
125
+
```
126
+
Each error has a code. You can look up the full details of any code in the [Ruff Documentation](https://docs.astral.sh/ruff/rules/).
127
+
128
+
> **Global Ignore:** To disable linting for an entire file (e.g., an auto-generated file), add `# ruff: noqa` to the very top
To maintain high code quality and security, this repository uses `re-commit` hooks. These hooks automatically run checks (like `Ruff` for linting and `Gitleaks` for security) every time you attempt to commit code.
180
182
183
+
### Installation
184
+
---
185
+
181
186
**Option 1: Using `uv` (Recommended)**
182
187
183
188
`uv` is recommended because it manages pre-commit within your project’s locked environment, ensuring your local linting matches the CI exactly.
@@ -210,6 +215,20 @@ Once installed, `git commit` will automatically trigger the checks.
210
215
- If they **pass**: Your commit is created normally.
211
216
- If they **fail**: The hooks will often fix the files for you (e.g., `Ruff` reformatting). Simply `git add` the changed files and commit again.
212
217
218
+
219
+
### Manual Execution
220
+
---
221
+
To run the hooks manually at any time:
222
+
223
+
```
224
+
# Run against only changed files
225
+
uv run pre-commit run
226
+
227
+
# Run against every file in the repository
228
+
uv run pre-commit run --all-files
229
+
```
230
+
231
+
213
232
## Generate Protocol Buffers
214
233
215
234
The SDK uses protocol buffers to communicate with the Hedera network. Generate the Python code from the protobuf definitions:
0 commit comments