Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109675
| From | Nagy László Zsolt <gandalf@shopzeus.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Recursive type annotations |
| Date | 2016-06-08 15:02 +0200 |
| Message-ID | <mailman.77.1465390948.2306.python-list@python.org> (permalink) |
| References | <8e439d4f-182d-334d-ffbe-8c39856cdd33@shopzeus.com> |
class Test:
def test(self, child : Test):
pass
NameError: name 'Test' is not defined
I understand that the class "Test" is not defined until the class
definition is executed. But it is very very common to build recursive
data structures, and I have concrete use case where the IDE did not
recognize the type of the argument, and as a result it forgot to rename
some method calls when I auto-refactored the name of the method.
I'm not an expert, but I believe that these annotations are not used by
the byte compiler for anything. This is just pure syntax introduced for
the person who reads the code.
Is there a known obsticle that would prevent us from detecting recursive
type annotations? (E.g. bind the annotation to the class that is being
defined.)
Thanks,
Laszlo
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Recursive type annotations Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-08 15:02 +0200
Re: Recursive type annotations Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-06-08 13:11 +0000
Re: Recursive type annotations Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-08 15:31 +0200
Re: Recursive type annotations Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-08 08:58 -0600
csiph-web