Deutsch English Français Italiano |
<mailman.90.1737217058.2912.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Pilcher <arequipeno@gmail.com> Newsgroups: comp.lang.python Subject: [SOLVED] Struggling to understand Callable type hinting Date: Sat, 18 Jan 2025 10:17:31 -0600 Lines: 35 Message-ID: <mailman.90.1737217058.2912.python-list@python.org> References: <f01d0808-16fb-4b91-a518-a84d6973fee1@gmail.com> <113709c0-0530-47c7-ad8d-8294dd00924f@DancesWithMice.info> <3da391eb-b245-429b-bcc1-3c88ef557241@gmail.com> <11ea559c-26da-4676-8bfc-1e58660d45cd@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de jbnJYezT60ClfET1VeSRdwqlkaWO1O8eBnnyrKFenuMg== Cancel-Lock: sha1:UIhbEdrGuhy0kKG5DrY1s3CKRj0= sha256:HH2Z9uTeXFEU0GawWJEMzFE0pPDAsvP9hZZANbj0Z70= Return-Path: <arequipeno@gmail.com> X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org Authentication-Results: mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=ePRg8u7E; dkim-adsp=pass; dkim-atps=neutral X-Spam-Status: OK 0.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'skip:@ 10': 0.03; 'def': 0.04; 'parameter': 0.04; 'arguments': 0.16; 'instance': 0.16; 'intuitive': 0.16; 'received:mail-oi1-x22a.google.com': 0.16; 'subject:hinting': 0.16; 'threading': 0.16; 'wrote:': 0.16; 'message-id:@gmail.com': 0.18; 'to:addr:python-list': 0.20; 'subject:] ': 0.20; 'unable': 0.21; 'to:name:python- list@python.org': 0.24; '(and': 0.25; 'cc:2**0': 0.25; 'interface': 0.26; "isn't": 0.27; 'fact': 0.28; 'think': 0.29; 'header:User-Agent:1': 0.30; 'seem': 0.31; 'takes': 0.31; 'am,': 0.31; "doesn't": 0.32; 'disabled': 0.32; "wouldn't": 0.32; 'but': 0.32; "i'm": 0.33; 'there': 0.33; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34; 'subject:[': 0.34; 'from:addr:gmail.com': 0.34; 'really': 0.36; '...': 0.37; 'way': 0.38; 'read': 0.38; 'list': 0.39; 'use': 0.39; 'two': 0.39; 'this,': 0.39; 'try': 0.40; 'method': 0.61; 'skip:b 10': 0.63; 'delivery': 0.64; 'your': 0.64; 'skip:t 20': 0.65; 'types': 0.67; 'skip:t 30': 0.67; 'respond': 0.68; 'supposed': 0.76; 'out.': 0.80; 'skip:= 70': 0.84; 'subject:type': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737217056; x=1737821856; darn=python.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=hkaKBrxdtnC5nLVrGw3oas86Oz1EVuYAJeItB1wKkSs=; b=ePRg8u7EJodJvxMmFqpPGV+0c8fJJ7QU8e6O3SkGBMwoP6ivxkNRXxcwHydPM+20uS Wcl4FbOuUbRoMCjQ2X8zQht9lH+xV5rAtQUVK3Hy7iAQY7cvK7el1PInTw4MMJuNNpUG h0H5sfjk0wxp01u5EgnVVrphc6cspg5fpqML8gQxuqAEz3Wyv03FCCPpaXH1CfsJJus9 yOkiIHMbmGlCXj+O9dA4dZ9sBWoKnYOFldP2xRaZzFU5OUSw0pZUrIUyvWNdyrTJPIPA r/esPIoMq+dGGWeWKq2W4pk5lJ0FGidjivXGj1g8kW88PEnp/o4y7M5cpAM4Z7aClhmV 9I9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737217056; x=1737821856; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hkaKBrxdtnC5nLVrGw3oas86Oz1EVuYAJeItB1wKkSs=; b=W7xIb0AHs08uHJ0vKaLJJT2gcCt3Cvzmxen8VWhZLiZgtv3fAeAvs1cZnGbS0TXpkG KPvLR9U3uBO6KzFHtgrOMEfUhS1+lozf20i7sGvZnctuwfmK0x/lrdnMHigRWbWjSTR2 DUDgADc+Gg9gwPQCRNLUui3tggBbqPoS4r7brwIwpjYSHk2XPX2XSmc/hCASSy/suss1 yK6NVrOueR+2r+cyRhI2iVNngG+/VOC/BHhA5aGxFQa00X/3OKUWRj0E58lgPxetE0iP uLPS/r/7yOfHLL7exHVYRTqdEVeXcNz+/xgvmNyBqmjjAtDPCoRpwtL+e5wIiY/yNllf yXiA== X-Gm-Message-State: AOJu0YzK30iqPNWK0ryzAMrIzbHNGnzjRboFZ1GbEnAW0VlkbnAYvcwF atovpr55FJWrGIf+I1vfKlYL80gxpCx2HgyrV6WCw8cwbTNQhE1VjRkXKw== X-Gm-Gg: ASbGnctGCheGiuJ4ROsfaSSrs0Sm4ECIXP9qEw43DUZOhc1ZDdLRXl4XiVFUjLPjxWL l7q89mhZu/7aafJYotre5jzDYbYOHNQKyXqjtf8VTsKeI0E+g6x9EBmCFW/Alx8YshVdCfDFGN4 UWmKh96RsqLp/ogdxH9uQ5L5DtM7BUUReKtlVjNIEQx6HWb+IJEDOorlb9BIZ+wRBqkBDd3Q8Vr F6ZlxhmW1lGFmYHyowRomfm4Lr8WatNf8JePSGte7mXMXZ0KlS8ebvCt3n5j8ZwLxZgiF6ReUEc PhLcJI3mq+t2p769WLqBUrlcivOKyRBGvPAs2PY= X-Google-Smtp-Source: AGHT+IFckYehh53Xottxt2BX+z4AkphOch797iEaho8D/y/3p5RPo2sPpSHnHEhTbbXKTYzpVF4xCA== X-Received: by 2002:a05:6808:179d:b0:3eb:7c84:a808 with SMTP id 5614622812f47-3f095a5f4c4mr9334532b6e.5.1737217054328; Sat, 18 Jan 2025 08:17:34 -0800 (PST) User-Agent: Mozilla Thunderbird Content-Language: en-US In-Reply-To: <3da391eb-b245-429b-bcc1-3c88ef557241@gmail.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: General discussion list for the Python programming language <python-list.python.org> List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> List-Archive: <https://mail.python.org/pipermail/python-list/> List-Post: <mailto:python-list@python.org> List-Help: <mailto:python-list-request@python.org?subject=help> List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> X-Mailman-Original-Message-ID: <11ea559c-26da-4676-8bfc-1e58660d45cd@gmail.com> X-Mailman-Original-References: <f01d0808-16fb-4b91-a518-a84d6973fee1@gmail.com> <113709c0-0530-47c7-ad8d-8294dd00924f@DancesWithMice.info> <3da391eb-b245-429b-bcc1-3c88ef557241@gmail.com> Bytes: 6898 (Note: I have mail delivery disabled for this list and read it through GMane, so I am unable to respond with correct threading if I'm not cc'ed directly.) On 1/18/25 8:52 AM, Ian Pilcher wrote: > (And even that wouldn't really be correct, if it worked, because it > doesn't express the fact that the arguments of the two Callables are the > same. I believe that ParamSpecs are supposed to address this, but there > doesn't seem to be any way to use a ParamSpec when one or more of the > parameter types is known. I think that I figured it out. __P = typing.ParamSpec('__P') @staticmethod def _check_eof( method: collections.abc.Callable[ typing.Concatenate[BufferScanner, __P], None ] ) -> ( collections.abc.Callable[ typing.Concatenate[BufferScanner, __P], bool ] ): ... Mypy is happy, and it catches me if I try to use the decorator on some- thing that isn't a method of BufferScanner (or some other callable that takes an instance of BufferScanner as its first positional argument). -- ======================================================================== If your user interface is intuitive in retrospect ... it isn't intuitive ========================================================================