3 ms·
But how can you make sure that people annotate their functions with localscope?
by serial_dev 2y ago
But how can you make sure that people annotate their functions with localscope?
- igorguerrero 2y agoSame question people have with hinting, what makes Python cool is how loose it is... You could also make a lint rule for that and make fail CI if that rule failed, or... Write your own compiler you know?
- goodki-d 2y agoit's pretty easy to write a lint rule for that
- zahlman 2y agoIt's a decorator, not an annotation. The decorator syntax is purely sugar: @foo def bar(): pass is equivalent to def bar(): pass bar = foo(bar) except that `bar` only gets assigned once. It's possible to use metaprogramming to apply the decorator automatically to every function (by iterating over attributes of the module and filtering for functions).