Python
Notes on the Python programming language — testing, async, type hints, and practical patterns.
Combine pytest fixtures with unittest.mock.patch for clean, reusable test mocking patterns that integrate seamlessly with pytest's ecosystem.
Use Python's TypeGuard to create custom type narrowing functions that help static type checkers understand runtime type checks and validations.
Use Python's NoReturn type to annotate functions that never return normally, helping type checkers understand exception-raising and infinite loop code.
Master adding multiple attributes to Python enum members using __new__ method. Avoid hardcoded indexes and create more maintainable enums.
Explore how functools.wraps preserves function identity by copying metadata from wrapped functions using update_wrapper and partial application.
Control concurrent async requests with Python asyncio.Semaphore to respect rate limits and prevent overwhelming APIs or services.
Build Python decorators that work seamlessly with both sync and async functions using inspect.iscoroutinefunction for maximum flexibility.
Implement Rust-style Result types for type-safe exception handling in Python using generic Ok and Err types inspired by Black formatter.
Understand covariance, contravariance, and invariance in Python generics with practical examples of type relationships and subtyping rules.
Optimize Python dictionary slicing from O(DK) to O(K) complexity using direct key lookups instead of iterating through all items.
Avoid Python function default argument pitfalls caused by early binding, where mutable defaults and function calls bind at definition time.
Test literal booleans correctly in Python unittest using assertIs instead of assertTrue/assertFalse to avoid truthy/falsy confusion.
Type Python decorators accurately using ParamSpec and Concatenate to preserve wrapped function signatures and enable proper static analysis.
View Python docstrings from the command line with pydoc or serve them as HTML documentation for modules, classes, and functions.
Use Python's bit_count() method to elegantly check if an integer is a power of two by counting on-bits in binary representation.