About 60,700 results
Open links in new tab
  1. How to use python typing.Annotated - Stack Overflow

    Apr 17, 2022 · 171 Annotated in python allows developers to declare the type of a reference and provide additional information related to it.

  2. python - How to properly function annotate / type hint a list of ...

    Aug 9, 2015 · Python 3.5 standardizes the way function annotations are used for type hinting, as documented in PEP 484. To annotate a list of strings, you use List[str], where List is imported …

  3. python - What are variable annotations? - Stack Overflow

    140 Python 3.6 is about to be released. PEP 494 -- Python 3.6 Release Schedule mentions the end of December, so I went through What's New in Python 3.6 to see they mention the …

  4. python - How do I type hint a method with the type of the …

    Introduced in Python 3.11, typing.Self refers to the type of the current instance, even if that type is a subclass of the class the annotation appears in. So if you have the following code:

  5. How to specify multiple types using type-hints - Stack Overflow

    1050 From the documentation - Union Type: A union object holds the value of the | (bitwise or) operation on multiple type objects. These types are intended primarily for type annotations. …

  6. python - Type annotations for *args and **kwargs - Stack Overflow

    May 4, 2016 · I'm trying out Python's type annotations with abstract base classes to write some interfaces. Is there a way to annotate the possible types of *args and **kwargs? For example, …

  7. python - How to annotate a type that's a class object (instead of a ...

    With the introduction of variable annotations in 3.6 (including a ClassVar to differ instance variables from class variables), I wonder why should I use type to annotate class objects when …

  8. python - Type hints with user defined classes - Stack Overflow

    This feature is available in python 3.9+, and also in 3.7+ if using from __future__ import annotations. In terms of this specific question, it means that instead of from typing import …

  9. python - Type annotations for Enum attribute - Stack Overflow

    Oct 3, 2018 · If you use this syntax for type hinting, for clarity/readability of your code it's probably good to have these enum classes in a separate module/folder called "types" or something similar.

  10. python - What are good uses for Python3's "Function Annotations ...

    Function Annotations: PEP-3107 I ran across a snippet of code demonstrating Python3's function annotations. The concept is simple but I can't think of why these were implemented in Python3 …