Download fixtures/pattern_lab/src/guards.py from tailot/codex-python: direct link, hf CLI and curl.
- Browser
- Download file 567 Bytes
-
https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/guards.py
- Command line
-
hf download hf://datasets/tailot/codex-python/fixtures/pattern_lab/src/guards.py
-
curl -L -o guards.py https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/guards.py
567 Bytes
| """Input checks carried over from a command line wrapper. | |
| One function opens with a bare assert, which is the shape the explicit raise pattern | |
| rewrites. The other asserts further down, where rewriting it would change what the | |
| function checks first, so the pattern refuses it. | |
| """ | |
| def open_ticket(queue_name): | |
| assert queue_name, "queue name is required" | |
| return {"queue": queue_name, "opened": True} | |
| def close_ticket(ticket): | |
| ticket = dict(ticket) | |
| ticket["opened"] = False | |
| assert ticket.get("queue"), "queue name is required" | |
| return ticket | |