On Fri, 25 Sep 2020 at 18:42, Steven D'Aprano <st...@pearwood.info> wrote: > There may be practical difficulties in sticking exceptions into > annotations. Annotations already can be pretty long and bulky. But if > you are okay with functions documenting that they might raise a certain > exception, then *in principle* you should be okay with moving that into > an annotation rather than the docstring. > > Annotations are just a form of documentation in a consistent standard > format to make it easy for IDEs to read them.
Expressed that way, it's a reasonable argument. And to the extent that we're talking about a way for functions to note what exceptions the developer feels are worth mentioning, having a language construct to do this would be OK. But in reality, people would treat the annotation as more definitive than it is. And people would feel pressure to "stick to the contract" when writing the annotated code. And style guides (which like it or not are sometimes written by people who are *not* experienced developers) will appear which state rules rather than allowing for nuanced interpretation. All of which might not be how the feature was intended to be used. I know, why assume the worst? But in contrast, what's the *best* outcome? My problem with the proposal is that it's about adding a mechanism, without any clear statement of how that mechanism is intended to be used. And there's so much scope for misguided use, and so few clear benefits, that it feels like a bad trade-off at the moment. (For the record, I'm not convinced by the IDE argument. I use Vim, which is relentlessly primitive in its basic form, and wouldn't use anything like this, and VS Code, which is so clever that it seems like magic most of the time, and I'm pretty certain that if people wanted it, VS Code could include "exception autocompletion" even without explicit annotation like this). Paul _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/LT6LFEHTUZY7SMFHEQU3K25ZQJIEUBIM/ Code of Conduct: http://python.org/psf/codeofconduct/