Explicit method overriding with @typing.overrideCatch method override errors at type-check time with Python's @override decorator from PEP 698, preventing typos and signature mismatches.Redowan Delowar·Nov 6·2 min readFollowPythonTILTyping
TypeIs does what I thought TypeGuard would do in PythonUnderstand TypeIs vs TypeGuard in Python: TypeIs provides more intuitive type narrowing by narrowing both positive and negative branches.Redowan Delowar·Apr 27·4 min readFollowPythonTypingTIL
Annotating args and kwargs in PythonProperly annotate Python *args and **kwargs with heterogeneous types using Unpack, TypedDict, and modern type hints from PEP-692.Redowan Delowar·Jan 8·3 min readFollowPythonTypingTIL
Statically enforcing frozen data classes in PythonEnforce immutable dataclasses at type-check time with @final decorator to catch mutations before runtime without frozen=True performance cost.Redowan Delowar·Jan 4·3 min readFollowPythonTILTyping
Guard clause and exhaustiveness checkingMaster TypeScript's never type and Python's NoReturn for exhaustiveness checking. Flatten nested conditionals with guard clauses for cleaner code.Redowan Delowar·May 22·3 min readFollowTypeScriptPythonTyping
Declarative payloads with TypedDict in PythonUse Python TypedDict to declaratively define API payload structures. Get type safety for nested dictionaries and improve code maintainability.Redowan Delowar·Mar 11·4 min readFollowPythonTypingAPI
Self type in PythonUse Python's Self type from PEP 673 to annotate methods returning class instances, eliminating complex forward references and TypeVars.Redowan Delowar·Feb 28·2 min readFollowPythonTyping
Narrowing types with TypeGuard in PythonUse Python's TypeGuard to create custom type narrowing functions that help static type checkers understand runtime type checks and validations.Redowan Delowar·Feb 23·5 min readFollowPythonTyping
Why 'NoReturn' type exists in PythonUse Python's NoReturn type to annotate functions that never return normally, helping type checkers understand exception-raising and infinite loop code.Redowan Delowar·Feb 21·2 min readFollowPythonTyping
Go Rusty with exception handling in PythonImplement Rust-style Result types for type-safe exception handling in Python using generic Ok and Err types inspired by Black formatter.Redowan Delowar·Feb 2·2 min readFollowPythonError HandlingTyping
Variance of generic types in PythonUnderstand covariance, contravariance, and invariance in Python generics with practical examples of type relationships and subtyping rules.Redowan Delowar·Jan 31·4 min readFollowPythonTyping
Static typing Python decoratorsType Python decorators accurately using ParamSpec and Concatenate to preserve wrapped function signatures and enable proper static analysis.Redowan Delowar·Jan 23·4 min readFollowPythonTyping
Difference between constrained 'TypeVar' and 'Union' in PythonUnderstand when to use constrained TypeVar vs Union in Python type hints for consistent types across function parameters and return values.Redowan Delowar·Jan 19·2 min readFollowPythonTypingTIL
Structural subtyping in PythonImplement Go-style structural subtyping in Python with Protocol for duck typing and interface-based APIs without inheritance dependencies.Redowan Delowar·Dec 4·6 min readFollowPythonTyping