Standard Search
About 149 results
https://rednafi.com/python/declarative-payloads-with-typedict/ · 11 Mar 2022
Use Python TypedDict to declaratively define API payload structures. Get type safety for nested dictionaries and improve code maintainability.
https://rednafi.com/python/parametrized-fixtures-in-pytest/ · 10 Mar 2022
Create dynamic pytest fixtures with @pytest.fixture(params) to run tests with multiple configurations and parameter combinations.
https://rednafi.com/python/modify-iterables-while-iterating/ · 4 Mar 2022
Safely modify lists, sets, and dictionaries while iterating using list comprehensions, filters, or copying to avoid skipping elements.
https://rednafi.com/python/github-action-template-python/ · 2 Mar 2022
Production-ready GitHub Actions workflow for Python with multi-OS testing, dependency caching, automated updates, and daily scheduled runs.
https://rednafi.com/python/self-type/ · 28 Feb 2022
Use Python's Self type from PEP 673 to annotate methods returning class instances, eliminating complex forward references and TypeVars.
https://rednafi.com/python/patch-with-pytest-fixture/ · 27 Feb 2022
Combine pytest fixtures with unittest.mock.patch for clean, reusable test mocking patterns that integrate seamlessly with pytest's ecosystem.
https://rednafi.com/python/type-guard/ · 23 Feb 2022
Use Python's TypeGuard to create custom type narrowing functions that help static type checkers understand runtime type checks and validations.
https://rednafi.com/python/why-noreturn-type-exists/ · 21 Feb 2022
Use Python's NoReturn type to annotate functions that never return normally, helping type checkers understand exception-raising and infinite loop code.
https://rednafi.com/python/add-attributes-to-enum-members/ · 17 Feb 2022
Master adding multiple attributes to Python enum members using __new__ method. Avoid hardcoded indexes and create more maintainable enums.
https://rednafi.com/python/internals-of-functools-wraps/ · 14 Feb 2022
Explore how functools.wraps preserves function identity by copying metadata from wrapped functions using update_wrapper and partial application.