Python Expert Best Practices Code Review

wispbit-ai/skills/skills/python-expert-best-practices-code-review

by wispbit-ai8b2c7d0ceca0MIT8 starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated 7 months ago

Python best practices for writing production-grade code. This skill should be used when writing, reviewing, or refactoring Python code. Triggers on tasks involving Python development, error handling patterns, dictionary operations, and code quality improvements.

Instructions onlySoftware Development
AI-generated overview

Guidelines for writing, reviewing and refactoring production-grade Python code against eight best-practice rules.

What it does
This skill supplies an opinionated set of Python best-practice guidelines organized by priority, covering error handling, common bugs, code clarity and style. It points to eight individual rule files, each with an explanation, when to use the pattern, implementation requirements, and incorrect and correct code examples. It produces review guidance and refactoring advice rather than executable output.
When to use it
Use it when writing Python functions, classes or modules, reviewing Python code for error-handling or quality issues, or refactoring an existing Python codebase. It is also relevant when implementing data validation and API boundaries or improving error detection and debugging patterns.
Requirements
No tools, packages or credentials are needed; it is instructions and reference documents only and ships no scripts.

Python 3.14+ Expert Best Practices

Simple, pragmatic, opinionated. Only what matters for writing production-grade python code.

When to Apply

Reference these guidelines when:

  • Writing Python functions, classes, or modules
  • Reviewing Python code for error handling issues
  • Refactoring existing Python codebases
  • Implementing data validation and API boundaries
  • Optimizing error detection and debugging patterns

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Error HandlingCRITICALdict-, operators-
2Common BugsCRITICAL-HIGHno-mutable-, no-generic-
3Code ClarityHIGH-MEDIUMlistcomp-, no-inline-
4Code StyleLOWavoid-, unnecessary-

Quick Reference

  • dict-required-keys - Use d[key] for required dictionary keys to fail fast with KeyError
  • no-mutable-defaults - No mutable defaults in function/method parameters
  • operators-return-notimplemented - Return NotImplemented for unsupported operand types and design + vs += intentionally
  • no-generic-except - Avoid generic except clauses to prevent hiding unexpected errors
  • listcomp-no-side-effects - List comprehensions must produce a value you use (no side-effect listcomps)
  • no-inline-imports - Place all import statements at the top of the file
  • avoid-explanatory-comments - Avoid unnecessary comments for self-documenting code
  • unnecessary-else-blocks - Avoid unnecessary else blocks after return/break/continue statements

How to Use

Read individual rule files for detailed explanations and code examples:

rules/dict-required-keys.mdrules/no-mutable-defaults.mdrules/operators-return-notimplemented.mdrules/no-generic-except.mdrules/listcomp-no-side-effects.mdrules/no-inline-imports.mdrules/avoid-explanatory-comments.mdrules/unnecessary-else-blocks.md

Each rule file contains:

  • Brief explanation of why it matters
  • When to use and when not to use the pattern
  • Implementation requirements
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references

Source and attribution

Source:wispbit-ai/skillsinskills/python-expert-best-practices-code-reviewat commit8b2c7d0

License: MIT

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal