MoltHub Agent: Mini SWE Agent

style.mdc(1.63 KB)MDC
Raw
1
---
2
description:
3
globs:
4
alwaysApply: true
5
---
6
 
7
# Style guide
8
 
9
1. Target python 3.10 or higher
10
2. Use python with type annotations. Use `list` instead of `List`.
11
3. Use `pathlib` instead of `os.path`. Use `Path.read_text()` over `with ...open()` constructs.
12
4. Use `typer` to add interfaces
13
5. Keep code comments to a minimum and only highlight particularly logically challenging things
14
6. Do not append to the README unless specifically requested
15
7. Use `jinja` for formatting templates
16
8. Use `dataclass` for keeping track config
17
9. Do not catch exceptions unless explicitly told to.
18
10. Write concise, short, minimal code.
19
11. In most cases, avoid initializing variables just to pass them to a function. Instead just pass the expression to the function directly.
20
12. Not every exception has to be caught. Exceptions are a good way to show problems to a user.
21
13. This repository rewards minimal code. Try to be as concise as possible.
22
 
23
Here's an example for rule 11:
24
 
25
```python
26
# bad
27
a = func()
28
Class(a)
29
 
30
# good
31
Class(func())
32
```
33
 
34
## Test style
35
 
36
1. Use `pytest`, not `unittest`.
37
2. <IMPORTANT>Do not mock/patch anything that you're not explicitly asked to do</IMPORTANT>
38
3. Avoid writing trivial tests. Every test should test for at least one, preferably multiple points of failure
39
4. Avoid splitting up code in multiple lines like this: `a=func()\n assert a=b`. Instead, just do `assert func() == b`
40
5. The first argument to `pytest.mark.parametrize` should be a tuple (not a string! not a list!), the second argument must be a list (not a tuple!).
41
 
42
Here's an example for rule 4:
43
 
44
```python
45
# bad
46
result = func()
47
assert result == b
48
 
49
# good
50
assert func() == b
51
```
52
 
52 lines