Python hints
This skill should be used when writing, reviewing, or refactoring Python code — any time files match `**/*.py` or `**/pyproject.toml`, or the user mentions Python conventions, type hints, generics, Protocols, dataclasses, `asyncio`, `unittest`, `unittest.mock`, context managers, or error handling. Covers general Python language guidance only — conventions, patterns and anti-patterns, stdlib-based testing, and type safety. Specific third-party tool, framework, or library rules (linters, formatters, type checkers, test frameworks, validation libraries, web frameworks, ORMs) belong in their own skills.From its SKILL.md
npx -y skills add trphume/daichijoubu --skill python-hintsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.5 KB, 899 tokens by cl100k_base, as published. Nobody here has run it
python-hints
Project-wide Python language guidance. Apply these rules when authoring or modifying Python code in this repository.
Scope
These references cover the Python language, its standard library, and the official toolchain (python, unittest, pip, venv). Guidance for specific third-party libraries and tools — linters/formatters, type checkers, test frameworks (pytest and similar), validation libraries, web frameworks, ORMs, HTTP clients, etc. — belongs in dedicated skills.
When to apply
Apply when any of the following is true:
- The task touches a file matching
**/*.py,**/pyproject.toml,**/requirements*.txt, or**/setup.cfg. - The user is designing a Python package, service, CLI, or library.
- The user asks about Python idioms, error handling, async, dependency injection, or performance.
- The user is writing or reviewing stdlib-based tests,
unittesttests, orunittest.mockusage. - The user is adding type annotations, defining
Protocols, using generics, or configuring type checking.
How to apply
- Before writing or editing Python code, load the reference file(s) relevant to the task. Do not rely on memory — these rules may evolve.
- Prefer the obvious, readable solution. Do not introduce abstractions, closures, or indirection that the task does not require.
- Match the repository's existing patterns before applying a rule — if a file already follows a rule, stay consistent; if it violates one, surface the mismatch rather than silently "fixing" surrounding code.
- If a rule touches a specific third-party tool the project uses, defer to that tool's dedicated skill and do not restate its rules here.
Non-negotiables (quick reference)
- Target Python 3.10+; use
T | None,list[T],dict[K, V]— notOptional,List,Dict. - Annotate every public function parameter, return type, and class attribute.
- Never use bare
except:orexcept Exception: pass. Catch specific exceptions; log or re-raise. When translating, useraise NewError(...) from e. - Never call blocking I/O (
time.sleep, synchronous sockets, synchronous file I/O) insideasync def. Use async-native APIs orasyncio.to_thread. - Always use context managers for resources (
with open(...),async with). - Validate external input at the boundary. Never unpack a raw
dictinto a domain model. - Do not expose persistence models through API responses — translate to DTOs.
- No mutable default arguments. Default to
Noneand build the value inside the function. - Tests: one behavior per test, always cover error paths, mock at boundaries not internal collaborators.
- Every
# type: ignoremust have a specific error code and an explanatory comment.
Reference Files
Load the specific file(s) for the task — do not load all four unnecessarily.
references/conventions.md— Target version, PEP 8 naming, import grouping, Google-style docstrings, line length, packaging layout, dataclass/enum usage.references/patterns.md— Design principles (KISS, SRP, separation of concerns, composition over inheritance, Rule of Three, function size, DI) and an anti-patterns checklist (exposed persistence models, mixed I/O + business logic, bare except,raise from, unclosed resources, blocking in async, mutable defaults, scattered retry, hard-coded config).references/testing.md— Layout, AAA pattern, test naming,unittestsetup/teardown,subTestparameterization, mocking at boundaries withunittest.mock, retries, time injection, async tests withIsolatedAsyncioTestCase, what not to test.references/type-safety.md— Modern annotations, union syntax, type narrowing with guards andassert_never, generics withTypeVarbounds and constraints, structural typing withProtocol, type aliases (PEP 695 vs.TypeAlias),Callable/Awaitable,TypedDict/NamedTuple, minimizingAny,# type: ignorehygiene.
What ships with it: 4 files
26.2 KB alongside SKILL.md
references/
- conventions.md3.8 KB
- patterns.md9.2 KB
- testing.md6.5 KB
- type-safety.md6.7 KB