Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: =?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?= Newsgroups: comp.lang.python Subject: Re: Recursive type annotations Date: Wed, 8 Jun 2016 15:31:18 +0200 Lines: 17 Message-ID: References: <8e439d4f-182d-334d-ffbe-8c39856cdd33@shopzeus.com> <7de91f01-4b8c-8f29-294a-4f2f6909bc89@shopzeus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de IYEjvvs4xYpEm1Vl/fnS2wvHlJXW7byDWT/iWYDI7K0A== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'nameerror:': 0.09; 'def': 0.13; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:type': 0.16; 'string': 0.17; 'fix': 0.21; 'pass': 0.22; 'defined': 0.23; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'right.': 0.27; 'pep': 0.29; 'class': 0.33; 'url:python': 0.33; 'thanks!': 0.34; 'follows:': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.40; 'url:3': 0.60; "'test'": 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopzeus.com; s=shopzeus_com; t=1465392676; bh=cptT3Ic3dIXYw/mU0CXvrDvbB5Q6TnXlEmwJ6u6DGn4=; h=Subject:To:References:From:Date:In-Reply-To:From; b=MumAvVUeaJke11GIfxCER5quXyM11wgYvH9b6zTlF5JYXzhml8zZ01ZoJWtpmaa0b EnOZPIvFe7nAOkf+QeOP5VsEUNIlKKHxa6iuSlEtSOlfKO0HWgYy6bty/qAcXqifJ9 9tFJYY2Et5ebVGwWdle19xNe/N6QmRzTDHd5MYOKe6kQut3FSa9mabSnSOyKJPQdGi wDOUmzFi/8klh7eszSe1cfgBhyzqpi81p0GipXQkMIV+EhPvm1enrSLqJAGZmkbHc+ ewuvhhWfeCkj/XXyTyFb04OlosNv5954jl9eFcMAUErtdNZ86sl/efcuftQbsLYnYH qlGeLTEybmRaA== In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <7de91f01-4b8c-8f29-294a-4f2f6909bc89@shopzeus.com> X-Mailman-Original-References: <8e439d4f-182d-334d-ffbe-8c39856cdd33@shopzeus.com> Xref: csiph.com comp.lang.python:109678 >> pass >> >> NameError: name 'Test' is not defined > I think you can fix this by using a string annotation as follows: > > class Test: > def test(self, child: "Test"): > pass Yes, you are right. It is not directly written in the official documentation ( https://docs.python.org/3/library/typing.html ), but it is in the PEP 0484, section "Forward references". Thanks! Laszlo