Mypy & optionnal static type checker #27

Closed
opened 2020-12-11 11:19:41 +01:00 by Fred · 0 comments
Owner

Mypy is an optional static type checker for Python that aims to combine the benefits of dynamic (or "duck") typing and static typing. Mypy combines the expressive power and convenience of Python with a powerful type system and compile-time type checking. Mypy type checks standard Python programs; run them using any Python VM with basically no runtime overhead.

http://mypy-lang.org/

Avec Python 3.9, il est possible de développer ceci, grâce à la prise en compte des Generics dans les collections pour les typehints:

def first_int_elem(l: list[int]) -> int:
  return l[0] if l else None

Cf. 484, 526, 544, 560 et 563 - source LinuxFr.

Mais surtout cf. 585

> Mypy is an optional static type checker for Python that aims to combine the benefits of dynamic (or "duck") typing and static typing. Mypy combines the expressive power and convenience of Python with a powerful type system and compile-time type checking. Mypy type checks standard Python programs; run them using any Python VM with basically no runtime overhead. http://mypy-lang.org/ Avec Python 3.9, il est possible de développer ceci, grâce à la prise en compte des `Generics` dans les collections pour les typehints: ```python def first_int_elem(l: list[int]) -> int: return l[0] if l else None ``` Cf. [484](https://www.python.org/dev/peps/pep-0484/), [526](https://www.python.org/dev/peps/pep-0526/), [544](https://www.python.org/dev/peps/pep-0544/), [560](https://www.python.org/dev/peps/pep-0560/) et [563](https://www.python.org/dev/peps/pep-0563/) - source [LinuxFr](https://linuxfr.org/news/python-3-9-est-disponible). Mais surtout cf. [585](https://www.python.org/dev/peps/pep-0585/)
Fred closed this issue 2020-12-21 20:23:07 +01:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Fred/gwift-book#27
No description provided.