About 50 results
Open links in new tab
  1. What's the canonical way to check for type in Python?

    Aug 3, 2014 · In Python, you can use the built-in isinstance() function to check if an object is of a given type, or if it inherits from a given type. To check if the object o is of type str, you would …

  2. python - How does mypy use typing.TYPE_CHECKING to resolve …

    The TYPE_CHECKING constant defined by the typing module is False at runtime but True while type checking. I don't know a great deal about mypy, thus I fail to see how once the conditional …

  3. How can I type-check variables in Python? - Stack Overflow

    May 28, 2017 · Does Python provide any native means of type checking variables? Or is this considered to be a violation of the language's dynamically typed design? EDIT: since a …

  4. python - import from typing within TYPE_CHECKING block?

    Nov 8, 2023 · Does it make sense to import from typing inside a TYPE_CHECKING block? Is this good/bad or does it even matter? from __future__ import annotations from typing import …

  5. python - VSCode / Pylance / Disable TypeChecking? - Stack …

    May 9, 2023 · python.analysis.typeCheckingMode": "basic" I changed it to "off" and now everything works again as wanted. These are the different options for this parameter for the …

  6. python - How to check if type of a variable is string? - Stack …

    Jan 30, 2011 · Is there a way to check if the type of a variable in python is a string, like: isinstance(x,int); for integer values?

  7. python - Determine the type of an object? - Stack Overflow

    2398 There are two built-in functions that help you identify the type of an object. You can use type() if you need the exact type of an object, and isinstance() to check an object’s type …

  8. Python type hinting without cyclic imports - Stack Overflow

    Sep 28, 2016 · Rather than forcing oneself to engage in typing.TYPE_CHECKING shenanigans, there is a simple way to avoid circular type-hints: don't use from imports, and use either from …

  9. Tools for static type checking in Python - Stack Overflow

    But optional static type checking has successfully been added to Racket while preserving the "dynamic" programming style of the language. Gradual Typing for Python (Jeremy Siek et al, …

  10. Python Analysis: Type Checking Mode in VS CODE - Stack Overflow

    Feb 20, 2023 · But from a static type checker's perspective that complaint makes sense. Python is a dynamically typed language and that philosophy carries over to type annotations. There is a …