Redowan's Reflections
Recent writing
Embracing sentence case over title case in technical writing eliminates capitalization ambiguity and improves readability.
Prevent excessive file downloads in Python by streaming with HTTPX and limiting file size with chunk-based validation and memory-safe processing.
Leverage Python's __post_init__ hook to declaratively transform dataclass fields. Automatically serialize data with clean, maintainable code.
Mock chained datetime methods in Python tests using unittest.mock to handle immutable datetime objects without external dependencies.
Fix Python ModuleNotFoundError by using python -m instead of direct script execution to ensure correct sys.path handling for imports.
Learn efficient patterns for caching database connection objects in Python without import-time side effects or lru_cache complexity.
Use Python TypedDict to declaratively define API payload structures. Get type safety for nested dictionaries and improve code maintainability.
Create dynamic pytest fixtures with @pytest.fixture(params) to run tests with multiple configurations and parameter combinations.
Safely modify lists, sets, and dictionaries while iterating using list comprehensions, filters, or copying to avoid skipping elements.
Production-ready GitHub Actions workflow for Python with multi-OS testing, dependency caching, automated updates, and daily scheduled runs.
Use Python's Self type from PEP 673 to annotate methods returning class instances, eliminating complex forward references and TypeVars.
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.