Contributing to stdlib-sniper¶
Thank you for your interest in contributing to stdlib-sniper! We welcome all contributions that help make Pythonβs standard library more accessible and practical for everyone.
π§© How to Add a Snippet¶
- Copy the snippet template below.
- Fill in all fields:
- Title (concise and descriptive)
- Code (zero-dependency, stdlib-only)
- Description (what does it do?)
- Tags (comma-separated, e.g.
files, append, write
) - Notes (usage tips, edge cases, warnings)
- Add cross-references if your snippet relates to others.
- Place your snippet in the correct category folder in
snippets/
(e.g.,snippets/math/
,snippets/strings/
). - Run all checks and scripts before submitting a PR (see below).
π§© Snippet Template¶
### π§© Snippet Title
# ```python (Uncomment the code block)
# Your code here
# ```
π Short description of what the snippet does
π·οΈ Tags: tag1, tag2, ...
π Notes:
- Note 1
- Note 2
π Cross-Reference Template (Optional)¶
β Review Checklist¶
Before submitting your PR, please ensure:
- Stdlib only: Uses only the Python standard library (no pip installs).
- Follows the snippet template: All fields are filled in.
- Clear tags and notes: Tags are relevant, notes are helpful.
- No duplicate code or section headers: Run the duplicate check script.
- Passes all lint and validation scripts: See below.
- Cross-references added (if relevant).
- File is in the correct category folder.
π οΈ Running Checks¶
Before you submit your PR, run the following:
This will: - Lint all Markdown and Python files - Check for duplicate code blocks and section headers - Validate snippet formatting and tags - Update indexes and summaries - Export snippets to Python files
Fix any issues reported by the scripts before submitting.
π‘ Suggest a Snippet¶
- Open an issue with the
suggestion
label. - Or add to
WANTED_SNIPPETS.md
in the project root. - Or join the discussion on GitHub Discussions.
π Docs & Automation¶
- Docs are auto-generated from
snippets/
using MkDocs Material. - To build docs locally:
- Docs are auto-built in CI on every push/PR.
π€ Community & Support¶
- Questions? Open an issue or join the discussion on GitHub.
- Want to suggest a snippet? See above.
Thank you for helping make stdlib-sniper awesome!