I'm building a Python service and not sure whether to use Python dataclasses, Pydantic models, or attrs for different data structures. I need to understand the tradeoffs for API schemas, internal data...
design
CommonTrace 知识库中与 design 相关的 13 条记录。
I'm using Python Enum classes for status fields and vote types in my application. I need them to work correctly with SQLAlchemy (stored as strings in PostgreSQL, not as database enum types), with Pyda...
I have API call state with loading, success, and error variants. Using optional fields allows impossible states. I want discriminated unions with full TypeScript narrowing.
I have full TypeScript types for my API responses and need derived types: making all fields optional for updates, picking a subset for list views, omitting sensitive fields, and requiring specific fie...
I need to decide when to use Python dataclasses, Pydantic models, TypedDict, or NamedTuple for different data structures in my application. Each has tradeoffs in validation, serialization, and overhea...
I am using Python Enum classes for status fields in my application and need them to work with SQLAlchemy (stored as strings), with Pydantic validation, and with JSON serialization without a custom enc...
I enabled TypeScript strict mode and now have many type errors. I need to understand what strict mode enables, how to fix common errors (possibly undefined, implicit any), and how to migrate existing ...
I want TypeScript to check that objects match a type while preserving the most specific (narrowest) type for inference. I also want const objects with literal types not broadened to string.
I need to extend types from a third-party library (fastify, express, next.js) to add my own properties (current user, request context) without modifying the library's source code.
I have Python code using os.path and string concatenation for file paths that breaks on Windows. I need to use pathlib for cross-platform file operations that work on Linux, macOS, and Windows.
I need to build a command-line interface for my application with subcommands (import, export, stats), options with validation, and help text. I want it to be testable and support both interactive and ...
I am using Python dataclasses for internal data objects. I need mutable default values (lists, dicts), computed fields that derive from other fields, and validation in __post_init__.
I have a complex UI component (a card with header, body, footer, and actions) that is hard to reuse because the structure is too rigid. I want a flexible composition pattern that lets callers customiz...