Python Development Skill
Reference data for the Developer Hub, Python Specialist, and wxPython Specialist agents.
Python Version Quick Reference
| Version |
Key Features |
EOL |
| 3.10 |
match/case, X | Y unions, ParamSpec |
Oct 2026 |
| 3.11 |
Exception groups, Self type, tomllib, faster CPython |
Oct 2027 |
| 3.12 |
Type parameter syntax def f[T](), @override, f-string nesting |
Oct 2028 |
| 3.13 |
Experimental free-threaded mode, improved error messages |
Oct 2029 |
| 3.14 |
async pdb.set_trace_async(), template strings (PEP 750) |
Oct 2030 |
pyproject.toml Skeleton
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "my-app"
version = "1.0.0"
requires-python = ">=3.10"
dependencies = []
[project.optional-dependencies]
dev = ["pytest>=8.0", "ruff>=0.6", "mypy>=1.11"]
[project.scripts]
myapp = "my_app.__main__:main"
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-ra --strict-markers"
[tool.ruff]
target-version = "py310"
line-length = 100
[tool.ruff.lint]
select = ["E", "F", "W", "I", "N", "UP", "B", "SIM", "TCH"]
[tool.mypy]
python_version = "3.10"
strict = true
PyInstaller Quick Reference
One-File Mode
exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas,
name='MyApp', console=False, icon='icon.ico')
One-Folder Mode
exe = EXE(pyz, a.scripts, exclude_binaries=True,
name='MyApp', console=False, icon='icon.ico')
coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, name='MyApp')
Common Hidden Imports
pkg_resources.extern
accessible_output2 (for a11y desktop apps)
keyring.backends (for credential storage)
platformdirs
httpx._transports / httpcore._backends
encodings (always needed)
wxPython Quick Reference
Sizer Cheat Sheet
| Sizer |
When to Use |
wx.BoxSizer(wx.VERTICAL) |
Stack items top-to-bottom |
wx.BoxSizer(wx.HORIZONTAL) |
Lay items left-to-right |
wx.GridBagSizer(vgap, hgap) |
Form layouts with labels + controls |
wx.FlexGridSizer(rows, cols, vgap, hgap) |
Even grid layouts |
wx.WrapSizer |
Flow layout that wraps |
wx.StaticBoxSizer(wx.VERTICAL, parent, "Label") |
Grouped controls with border |
Thread-Safe GUI Updates
# From worker thread:
wx.CallAfter(self.update_status, "Done")
wx.PostEvent(self, CustomEvent(data=result))
# NEVER do this from a worker thread:
self.status_bar.SetStatusText("Done") # CRASH or CORRUPTION
Standard IDs
| ID |
Purpose |
wx.ID_OK |
OK button |
wx.ID_CANCEL |
Cancel button |
wx.ID_SAVE |
Save action |
wx.ID_OPEN |
Open action |
wx.ID_EXIT |
Exit / Quit |
wx.ID_HELP |
Help action |
wx.ID_NEW |
New document |
wx.ID_UNDO / wx.ID_REDO |
Undo / Redo |
Event Types
| Event |
Trigger |
wx.EVT_BUTTON |
Button click |
wx.EVT_MENU |
Menu item selected |
wx.EVT_CLOSE |
Window close requested |
wx.EVT_SIZE |
Window resized |
wx.EVT_TIMER |
Timer fired |
wx.EVT_TEXT |
Text control content changed |
wx.EVT_LIST_ITEM_SELECTED |
List item selected |
wx.EVT_TREE_SEL_CHANGED |
Tree selection changed |
wx.EVT_UPDATE_UI |
UI state update check |
Common Pitfalls
Python
- Mutable default arguments:
def f(items=[]) shares the list across calls. Use None and create inside.
- Late binding closures:
lambda: x in a loop captures the variable, not the value. Use lambda x=x: x.
- Circular imports: Move imports inside functions, use
TYPE_CHECKING block, or restructure modules.
field() outside dataclass: field() is only valid inside @dataclass classes. Use plain type annotations elsewhere.
is vs ==: is checks identity, == checks equality. Use is only for None, True, False.
- String concatenation in loops: Use
"".join() or io.StringIO instead.
wxPython
- GUI from worker thread: Always use
wx.CallAfter() or wx.PostEvent().
- Missing
event.Skip(): Other handlers won't fire. Call event.Skip() unless you intentionally consume the event.
- Timer not stopped: Stop timers in
EVT_CLOSE handler to prevent callbacks after destruction.
- AUI not uninitialized: Call
_mgr.UnInit() in close handler.
- Dialog not destroyed: Use context managers (
with MyDialog(...) as dlg:) for automatic cleanup.
- Wrong parent for sizer items: All controls in a sizer must have the same parent panel.
- Absolute positioning: Never use
SetPosition() or SetSize() for layout. Always use sizers.
Cross-Platform Paths
from platformdirs import user_config_dir, user_data_dir, user_cache_dir
config = user_config_dir("MyApp", "MyCompany") # %APPDATA% / ~/Library/... / ~/.config/
data = user_data_dir("MyApp", "MyCompany")
cache = user_cache_dir("MyApp", "MyCompany")
Testing Quick Reference
# Run all tests
pytest
# Run specific test file
pytest tests/test_queue.py
# Run specific test
pytest tests/test_queue.py::test_submit_job -v
# With coverage
pytest --cov=mypackage --cov-report=term-missing
# Stop on first failure
pytest -x
# Show locals on failure
pytest -l
Logging Setup Template
import logging
def setup_logging(level: int = logging.INFO) -> None:
logging.basicConfig(
level=level,
format="%(asctime)s %(name)s %(levelname)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
# Quiet noisy libraries
logging.getLogger("httpx").setLevel(logging.WARNING)
logging.getLogger("httpcore").setLevel(logging.WARNING)
Desktop Accessibility Quick Reference
Platform API Summary
| Platform |
API |
Python Binding |
Use For |
| Windows |
UI Automation (UIA) |
comtypes, pywinauto |
Modern apps, NVDA/Narrator |
| Windows |
MSAA / IAccessible2 |
comtypes, pywinauto |
Legacy apps, JAWS |
| macOS |
NSAccessibility |
pyobjc |
VoiceOver |
wxPython Accessibility Essentials
# Name every control that lacks a visible label
# CORRECT: use StaticText immediately before the control in the sizer
label = wx.StaticText(panel, label="Scan progress:")
# ctrl = wx.Gauge(panel) -- add label to sizer right before ctrl
# WRONG: SetName() is ignored by screen readers
# ctrl.SetName("Scan progress") -- only affects FindWindowByName()
# Tab order follows sizer insertion order; override with:
ctrl2.MoveAfterInTabOrder(ctrl1)
# Keyboard shortcuts via accelerator table
accel = wx.AcceleratorTable([
(wx.ACCEL_CTRL, ord('S'), wx.ID_SAVE),
(wx.ACCEL_CTRL, ord('Q'), wx.ID_EXIT),
])
frame.SetAcceleratorTable(accel)
# Platform-correct button order in dialogs
sizer.Add(dialog.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL))
Screen Reader Interaction Model
Screen readers expose controls as: Name + Role + Value + State
| Property |
wxPython Source |
Example |
| Name |
Preceding wx.StaticText, label= parameter, or SetToolTip() |
"Scan progress" |
| Role |
Widget type (automatic) |
button, text field, list |
| Value |
Widget content |
"75%", "Hello world" |
| State |
Widget flags |
focused, disabled, checked |
Desktop A11y Checklist
- Every control has a meaningful name (preceding
wx.StaticText for inputs, label= for buttons, SetToolTip() for image-only controls)
- Keyboard-only operation -- every action reachable via Tab/Enter/Space/arrows
- Focus visible -- never suppress focus indicators
- Tab order is logical (generally top-to-bottom, left-to-right)
- Color is not the sole information carrier
- High contrast mode supported (use system colors, not hardcoded)
- Dialogs use
CreateStdDialogButtonSizer() for platform-correct button order
- AUI panes are keyboard-navigable
Structured Audit Rule Sets
When audit mode is activated, agents use these structured detection rule sets:
| Rule Prefix |
Agent |
Scope |
Count |
| WX-A11Y-001..012 |
wxpython-specialist |
wxPython-specific patterns (StaticText labels, AcceleratorTable, mouse-only events, dialogs) |
12 rules |
| DTK-A11Y-001..012 |
desktop-a11y-specialist |
Platform-level API patterns (Name/Role/State/Value, focus, UIA/NSAccessibility) |
12 rules |
| TST-A11Y-001..010 |
desktop-a11y-testing-coach |
Test coverage gaps (automated tests, SR testing, keyboard plans, CI integration) |
10 rules |
Rule sets don't overlap -- WX covers wxPython widget patterns, DTK covers platform APIs, TST covers testing process gaps.
Agent Routing
For deeper expertise, the skill routes to these specialists:
desktop-a11y-specialist -- Platform API implementation, wx.Accessible, custom widget patterns (DTK-A11Y-* audit rules)
desktop-a11y-testing-coach -- NVDA/JAWS/Narrator testing, Accessibility Insights, automated UIA tests (TST-A11Y-* audit rules)
a11y-tool-builder -- Rule engine architecture, document parsers, severity scoring, report generators
1---2name: python-development3description: Python Development Skill4---56# Python Development Skill78Reference data for the Developer Hub, Python Specialist, and wxPython Specialist agents.910## Python Version Quick Reference1112| Version | Key Features | EOL |13|---|---|---|14| 3.10 | `match/case`, `X \| Y` unions, `ParamSpec` | Oct 2026 |15| 3.11 | Exception groups, `Self` type, `tomllib`, faster CPython | Oct 2027 |16| 3.12 | Type parameter syntax `def f[T]()`, `@override`, f-string nesting | Oct 2028 |17| 3.13 | Experimental free-threaded mode, improved error messages | Oct 2029 |18| 3.14 | `async pdb.set_trace_async()`, template strings (PEP 750) | Oct 2030 |1920## pyproject.toml Skeleton2122```toml23[build-system]24requires = ["hatchling"]25build-backend = "hatchling.build"2627[project]28name = "my-app"29version = "1.0.0"30requires-python = ">=3.10"31dependencies = []3233[project.optional-dependencies]34dev = ["pytest>=8.0", "ruff>=0.6", "mypy>=1.11"]3536[project.scripts]37myapp = "my_app.__main__:main"3839[tool.pytest.ini_options]40testpaths = ["tests"]41addopts = "-ra --strict-markers"4243[tool.ruff]44target-version = "py310"45line-length = 1004647[tool.ruff.lint]48select = ["E", "F", "W", "I", "N", "UP", "B", "SIM", "TCH"]4950[tool.mypy]51python_version = "3.10"52strict = true53```5455## PyInstaller Quick Reference5657### One-File Mode5859```python60exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas,61 name='MyApp', console=False, icon='icon.ico')62```6364### One-Folder Mode6566```python67exe = EXE(pyz, a.scripts, exclude_binaries=True,68 name='MyApp', console=False, icon='icon.ico')69coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, name='MyApp')70```7172### Common Hidden Imports7374- `pkg_resources.extern`75- `accessible_output2` (for a11y desktop apps)76- `keyring.backends` (for credential storage)77- `platformdirs`78- `httpx._transports` / `httpcore._backends`79- `encodings` (always needed)8081## wxPython Quick Reference8283### Sizer Cheat Sheet8485| Sizer | When to Use |86|---|---|87| `wx.BoxSizer(wx.VERTICAL)` | Stack items top-to-bottom |88| `wx.BoxSizer(wx.HORIZONTAL)` | Lay items left-to-right |89| `wx.GridBagSizer(vgap, hgap)` | Form layouts with labels + controls |90| `wx.FlexGridSizer(rows, cols, vgap, hgap)` | Even grid layouts |91| `wx.WrapSizer` | Flow layout that wraps |92| `wx.StaticBoxSizer(wx.VERTICAL, parent, "Label")` | Grouped controls with border |9394### Thread-Safe GUI Updates9596```python97# From worker thread:98wx.CallAfter(self.update_status, "Done")99wx.PostEvent(self, CustomEvent(data=result))100101# NEVER do this from a worker thread:102self.status_bar.SetStatusText("Done") # CRASH or CORRUPTION103```104105### Standard IDs106107| ID | Purpose |108|---|---|109| `wx.ID_OK` | OK button |110| `wx.ID_CANCEL` | Cancel button |111| `wx.ID_SAVE` | Save action |112| `wx.ID_OPEN` | Open action |113| `wx.ID_EXIT` | Exit / Quit |114| `wx.ID_HELP` | Help action |115| `wx.ID_NEW` | New document |116| `wx.ID_UNDO` / `wx.ID_REDO` | Undo / Redo |117118### Event Types119120| Event | Trigger |121|---|---|122| `wx.EVT_BUTTON` | Button click |123| `wx.EVT_MENU` | Menu item selected |124| `wx.EVT_CLOSE` | Window close requested |125| `wx.EVT_SIZE` | Window resized |126| `wx.EVT_TIMER` | Timer fired |127| `wx.EVT_TEXT` | Text control content changed |128| `wx.EVT_LIST_ITEM_SELECTED` | List item selected |129| `wx.EVT_TREE_SEL_CHANGED` | Tree selection changed |130| `wx.EVT_UPDATE_UI` | UI state update check |131132## Common Pitfalls133134### Python135136- **Mutable default arguments:** `def f(items=[])` shares the list across calls. Use `None` and create inside.137- **Late binding closures:** `lambda: x` in a loop captures the variable, not the value. Use `lambda x=x: x`.138- **Circular imports:** Move imports inside functions, use `TYPE_CHECKING` block, or restructure modules.139- **`field()` outside dataclass:** `field()` is only valid inside `@dataclass` classes. Use plain type annotations elsewhere.140- **`is` vs `==`:** `is` checks identity, `==` checks equality. Use `is` only for `None`, `True`, `False`.141- **String concatenation in loops:** Use `"".join()` or `io.StringIO` instead.142143### wxPython144145- **GUI from worker thread:** Always use `wx.CallAfter()` or `wx.PostEvent()`.146- **Missing `event.Skip()`:** Other handlers won't fire. Call `event.Skip()` unless you intentionally consume the event.147- **Timer not stopped:** Stop timers in `EVT_CLOSE` handler to prevent callbacks after destruction.148- **AUI not uninitialized:** Call `_mgr.UnInit()` in close handler.149- **Dialog not destroyed:** Use context managers (`with MyDialog(...) as dlg:`) for automatic cleanup.150- **Wrong parent for sizer items:** All controls in a sizer must have the same parent panel.151- **Absolute positioning:** Never use `SetPosition()` or `SetSize()` for layout. Always use sizers.152153## Cross-Platform Paths154155```python156from platformdirs import user_config_dir, user_data_dir, user_cache_dir157158config = user_config_dir("MyApp", "MyCompany") # %APPDATA% / ~/Library/... / ~/.config/159data = user_data_dir("MyApp", "MyCompany")160cache = user_cache_dir("MyApp", "MyCompany")161```162163## Testing Quick Reference164165```bash166# Run all tests167pytest168169# Run specific test file170pytest tests/test_queue.py171172# Run specific test173pytest tests/test_queue.py::test_submit_job -v174175# With coverage176pytest --cov=mypackage --cov-report=term-missing177178# Stop on first failure179pytest -x180181# Show locals on failure182pytest -l183```184185## Logging Setup Template186187```python188import logging189190def setup_logging(level: int = logging.INFO) -> None:191 logging.basicConfig(192 level=level,193 format="%(asctime)s %(name)s %(levelname)s %(message)s",194 datefmt="%Y-%m-%d %H:%M:%S",195 )196 # Quiet noisy libraries197 logging.getLogger("httpx").setLevel(logging.WARNING)198 logging.getLogger("httpcore").setLevel(logging.WARNING)199```200201## Desktop Accessibility Quick Reference202203### Platform API Summary204205| Platform | API | Python Binding | Use For |206|---|---|---|---|207| Windows | UI Automation (UIA) | `comtypes`, `pywinauto` | Modern apps, NVDA/Narrator |208| Windows | MSAA / IAccessible2 | `comtypes`, `pywinauto` | Legacy apps, JAWS |209| macOS | NSAccessibility | `pyobjc` | VoiceOver |210211### wxPython Accessibility Essentials212213```python214# Name every control that lacks a visible label215# CORRECT: use StaticText immediately before the control in the sizer216label = wx.StaticText(panel, label="Scan progress:")217# ctrl = wx.Gauge(panel) -- add label to sizer right before ctrl218# WRONG: SetName() is ignored by screen readers219# ctrl.SetName("Scan progress") -- only affects FindWindowByName()220221# Tab order follows sizer insertion order; override with:222ctrl2.MoveAfterInTabOrder(ctrl1)223224# Keyboard shortcuts via accelerator table225accel = wx.AcceleratorTable([226 (wx.ACCEL_CTRL, ord('S'), wx.ID_SAVE),227 (wx.ACCEL_CTRL, ord('Q'), wx.ID_EXIT),228])229frame.SetAcceleratorTable(accel)230231# Platform-correct button order in dialogs232sizer.Add(dialog.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL))233```234235### Screen Reader Interaction Model236237Screen readers expose controls as: **Name + Role + Value + State**238239| Property | wxPython Source | Example |240|---|---|---|241| Name | Preceding `wx.StaticText`, `label=` parameter, or `SetToolTip()` | "Scan progress" |242| Role | Widget type (automatic) | button, text field, list |243| Value | Widget content | "75%", "Hello world" |244| State | Widget flags | focused, disabled, checked |245246### Desktop A11y Checklist2472481. Every control has a meaningful name (preceding `wx.StaticText` for inputs, `label=` for buttons, `SetToolTip()` for image-only controls)2492. Keyboard-only operation -- every action reachable via Tab/Enter/Space/arrows2503. Focus visible -- never suppress focus indicators2514. Tab order is logical (generally top-to-bottom, left-to-right)2525. Color is not the sole information carrier2536. High contrast mode supported (use system colors, not hardcoded)2547. Dialogs use `CreateStdDialogButtonSizer()` for platform-correct button order2558. AUI panes are keyboard-navigable256257### Structured Audit Rule Sets258259When audit mode is activated, agents use these structured detection rule sets:260261| Rule Prefix | Agent | Scope | Count |262|---|---|---|---|263| WX-A11Y-001..012 | `wxpython-specialist` | wxPython-specific patterns (StaticText labels, AcceleratorTable, mouse-only events, dialogs) | 12 rules |264| DTK-A11Y-001..012 | `desktop-a11y-specialist` | Platform-level API patterns (Name/Role/State/Value, focus, UIA/NSAccessibility) | 12 rules |265| TST-A11Y-001..010 | `desktop-a11y-testing-coach` | Test coverage gaps (automated tests, SR testing, keyboard plans, CI integration) | 10 rules |266267Rule sets don't overlap -- WX covers wxPython widget patterns, DTK covers platform APIs, TST covers testing process gaps.268269### Agent Routing270271For deeper expertise, the skill routes to these specialists:272273- **`desktop-a11y-specialist`** -- Platform API implementation, wx.Accessible, custom widget patterns (DTK-A11Y-* audit rules)274- **`desktop-a11y-testing-coach`** -- NVDA/JAWS/Narrator testing, Accessibility Insights, automated UIA tests (TST-A11Y-* audit rules)275- **`a11y-tool-builder`** -- Rule engine architecture, document parsers, severity scoring, report generators