|
Download code/code201.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/d517dc97f4cfcf6f6f9b7fafc368554f077178b3/code/code201.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@d517dc97f4cfcf6f6f9b7fafc368554f077178b3/code/code201.jsonl
-
curl -L -o code201.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/d517dc97f4cfcf6f6f9b7fafc368554f077178b3/code/code201.jsonl
1.82 kB
| {"type": "session", "harness": "deepseek-harness", "id": "code201", "name": "Python type hints best practices"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}} | |
| {"type": "message", "message": {"role": "user", "content": "What are best practices for Python type hints?"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "**Basic Types:**\n```python\ndef greet(name: str) -> str:\n return f\"Hello, {name}\"\n\nitems: list[int] = [1, 2, 3]\nscores: dict[str, float] = {\"alice\": 95.5}\n```\n\n**Generics and TypeVars:**\n```python\nfrom typing import TypeVar, Generic\n\nT = TypeVar(\"T\")\n\nclass Container(Generic[T]):\n def __init__(self, value: T) -> None:\n self.value = value\n```\n\n**Protocols (Structural Typing):**\n```python\nfrom typing import Protocol\n\nclass Drawable(Protocol):\n def draw(self) -> None: ...\n\ndef render(obj: Drawable) -> None:\n obj.draw()\n```\n\n**Useful Patterns:**\n- `Optional[T]` = `T | None` (Python 3.10+)\n- `Union[T1, T2]` = `T1 | T2` (Python 3.10+)\n- `@overload` for multiple signatures\n- `typing.Final` for constants\n- `typing.Never` for unreachable code\n\n**Tools:**\n- `mypy` for static checking\n- `pyright` for fast type checking\n- `--strict` for maximum safety\n\n**Tips:**\n- Start with function signatures\n- Use `from __future__ import annotations`\n- Don't over-type (trust inference)\n- Use `Protocol` for duck typing\n- Run mypy in CI"}} | |