-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Numerous type annotation enhancements have been made for both simplifying and specifying (i.e., being more specific and helpful for static analysis) such annotations up through our current minimum Python version of 3.12.
We should do the following (not necessarily exhaustive list):
- Replace
Dict,List,Tuple,Typewithdict,list,tuple,type - Replace
Unionwith| - Replace
Optional[X]withX | None - Use
**P(ParamSpec) for decorator functions so that the decorators "pass through" the signature of the decorated functions, making it easy to see the param types and return type in code completion. - Import
Callable,Mapping,Sequence, and other "collection" types fromcollections.abcrather than fromtyping(python 3.10 deprecated importing these fromtypingin favor ofcollections.abc) - Replace
Dict(dict) type withMapping, where possible (i.e., where a dependency does not prevent it), asMappingis less problematic with type variance since it is an immutable type (we should generally prefer immutable over mutable types for this reason, among others) - Replace
List(list) type withtuple,Sequence, orIterable(as appropriate) for same reasons as previous point.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels