[Python-ideas] Decorator to avoid a mistake

Nick Timkovich prometheus235 at gmail.com
Fri Nov 25 23:44:12 EST 2016


Here's hopefully a working link; GitHub's rendering seems to be iffy:
https://nbviewer.jupyter.org/urls/gist.githubusercontent.com/nicktimko/5f08d6adfa1dbe1319c3bfc715ec0aa4/raw/37dd95cd92be7b7e5af01b98ce9e8e00a705b3f7/override_guard.ipynb

Knowing how to do some introspection with dunder magic attributes can make
tracing methods easier. There's also a bunch of caveats that could probably
bite you (and make my demo full of holes)

On Fri, Nov 25, 2016 at 10:26 PM, Guido van Rossum <guido at python.org> wrote:

> This idea is being kicked around from forum to forum and nobody wants to
> have it.
>
> Here it's brought up from time to time and the response is usually "let a
> linter do it".
>
> In mypy (which is essentially a powerful linter) it was proposed (
> https://github.com/python/mypy/issues/1888) and the response was
> essentially "better go to python-ideas or bugs.python.org".
>
> It's also been proposed as a PEP 484 feature: https://github.com/python/
> typing/issues/269#issuecomment-243765549 .
>
> I think one reason why such proposals are unwelcome to experienced users
> may be that when done right this is totally legitimate, and the requirement
> to use an @override decorator is just making code more verbose with very
> little benefit. (I could see a benefit -- if this is used consistently it
> could make spelunking a large codebase easier, because you would know which
> methods are overrides. Something like mypy could then enforce its use. But
> an IDE could also just highlight method overrides differently, maybe
> PyCharm or PyDev already do that?)
>
> --
> --Guido van Rossum (python.org/~guido <http://python.org/%7Eguido>)
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161125/c5562ee2/attachment.html>


More information about the Python-ideas mailing list