Re: Python type annotations

2024-03-01 Thread Bruno Haible
Kévin Le Gouguec wrote: > >> So if Python 3.7 is acceptable as a minimum version (it seems available > >> in the distro releases you mention), you would be able to start using > >> this union syntax. > > > > I remember having to use the __future__ import. I guess I no longer > > have to now that De

Re: Python type annotations

2024-03-01 Thread Kévin Le Gouguec
Collin Funk writes: >> 'from __future__ import annotations', available since Python 3.7 [1], >> allows older Pythons to ignore type-hint syntax sophistications brought >> by newer Pythons. >> >> So if Python 3.7 is acceptable as a minimum version (it seems available >> in the distro releases you

Re: Python type annotations

2024-02-29 Thread dima . pasechnik
On Thu, Feb 29, 2024 at 05:16:29PM +0100, Kévin Le Gouguec wrote: > (Hi! Apologies for the drive-by comments, hopefully they won't be > complete noise. Butting in hoping to clarify things at best, stand > corrected at worst) > > Bruno Haible writes: > > >> Python has added a lot of interesting

Re: Python type annotations

2024-02-29 Thread Collin Funk
On 2/29/24 8:16 AM, Kévin Le Gouguec wrote: > * the former provide some runtime sanity-checking, > * the latter are ineffective at runtime, and exist mainly for the > programmer's benefit (IDE hints for completion, documentation, > linting, etc). > > (Though linters like mypy do _also_ pick up

Re: Python type annotations

2024-02-29 Thread Collin Funk
On 2/29/24 7:10 AM, Bruno Haible wrote: > Argument tests like we have them: > >if type(actioncmd) is not str: > > are perfectly OK to use. Simple and straightforward. > > is_iterable feels a bit like fashion: You can use them if you want to be > fashonable and have extra money to spend :

Re: Python type annotations

2024-02-29 Thread Kévin Le Gouguec
(Hi! Apologies for the drive-by comments, hopefully they won't be complete noise. Butting in hoping to clarify things at best, stand corrected at worst) Bruno Haible writes: >> Python has added a lot of interesting type hinting stuff over the past >> few years [3]. > > Interesting. Feel free t

Re: Python type annotations

2024-02-29 Thread Bruno Haible
Hi Collin, > Was gnulib-tool.py originally written in Python 2? Yes, it was written in Python 2, with the knowledge that Python 3 was already nearby around the corner. > I don't feel like I > don't see 'type(var) == list' anymore (in the very little Python code > I read). Usually I feel like you