language-python

Write idiomatic Python code with type hints, context managers, and pytest tests.

2|8|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/lugassawan/swe-workbench --skill language-python-lugassawan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: language-python
Source: https://github.com/lugassawan/swe-workbench/tree/main/skills/language-python
Command: npx skills add https://github.com/lugassawan/swe-workbench --skill language-python-lugassawan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing Python code that is readable, maintainable, and reliable—without accidentally adopting anti-patterns around typing, errors, context management, concurrency, and testing.

Core Features & Use Cases

  • Type-hint and data modeling guidance: Prefer dataclass, TypedDict, and Protocol, and use from __future__ import annotations for forward references.
  • Correct exception and resource handling: Use specific exceptions, avoid broad except Exception, and manage lifetimes with with and contextlib.
  • Pythonic performance, concurrency, and testing: Use generators, itertools, structured concurrency with asyncio, and pytest-first testing patterns.

Quick Start

Ask an AI to refactor your Python function so it follows these idioms: “Refactor my .py code to use idiomatic type hints, safe exceptions, proper context managers, and pytest-based tests.”

Frequently Asked Questions about language-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write idiomatic Python code with proper type hints and dataclasses?

Idiomatic Python code uses dataclasses for modeling, enforces strong type hints, and applies `from __future__ import annotations` for forward references to ensure maintainability and correct static analysis.

What is the best way to handle exceptions and manage resources in Python?

Safe resource handling in Python uses specific exceptions, avoids broad `except Exception` blocks, and manages lifetimes with `with` statements and `contextlib` to guarantee proper cleanup.

How do I structure concurrency in Python using asyncio?

Structured concurrency in Python uses `asyncio` to manage asynchronous tasks, ensuring reliable execution and safe cancellation while maintaining performance-minded implementation choices.

Can I use pytest to test Python modules that use generators and context managers?

Yes, pytest-first testing patterns effectively validate Python modules that use generators, `itertools`, and context managers, ensuring your idiomatic code remains correct and maintainable.

Why does my Python code fail PEP 8 conventions and lack maintainability?

Code fails PEP 8 conventions when it ignores idiomatic patterns like TypedDict, Protocol, and disciplined exception handling, leading to unmaintainable and error-prone application logic.

When do I need to use Protocol and TypedDict for Python type hinting?

Use Protocol and TypedDict in Python when you need structural subtyping and typed dictionary structures, ensuring strong type-hint usage and maintainable data modeling.