Commit a274aa3
committed
Make Context's repr debug friendly
When viewing `Context`s in stack traces/debuggers, it was not obvious
which context one was looking at, especially if multiple contexts had
values of similar types. With this change, the context name is visible
in e.g. Django's debug mode exception page.
Since dataclasses are already in use for other classes in htpy, I opted
to make the `Context` class a dataclass too. The constructor should be
exactly the same before and after this change.
Before:
```
<htpy.Context object at 0x7f9af95a16d0>: <<Request: GET '/foo/bar/'> at 0x7f9af5e88410>
```
After:
```
Context(name='request', default=<class 'htpy._NO_DEFAULT'>): <<Request: GET '/foo/bar/'> at 0x7fab5e7a6ad0>
```1 parent 457a6f4 commit a274aa3
1 file changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
151 | 152 | | |
152 | | - | |
153 | | - | |
154 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| |||
0 commit comments