|
|
|
|
|
by St-Clock
3405 days ago
|
|
For our small team, we found that type annotations are useful as a substitute of documentation and it cut our docstrings at least by half. For most small and well-named API functions, we don't need docstrings anymore. We're big fans of type aliases also. For example, API functions do not return an int, they return a PK. They do not return a str (or Text), they return a URL. We're also heavy users of typing.Optional to mark parameters or return values that can accept and return None. We tried mypy but it failed miserably on our large codebase and frankly, with our large test suite, we never had a typing error found in production so I think it's not a good investment of our time. I'm eager to test type annotations with our next intern to see if it speed up the ramp up process. |
|
I've just finished porting a small application to Python 3 just because 2020 and deprecation is in sight already - there are so many things that have passed me by in the Py3 world.