question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python type hints

See original GitHub issue

PEP 484 and PEP 526 introduced the concept of “type hints” which allow Python code to have inline type declarations to make it easier for editors and static analysis tools to work with Python code.

def add(a: int, b: int) -> int:
    return a + b

To maintain Python 2.7 compatibility, we’d have to use the comment-based syntax:

def add(a, b):
    # type: (int, int) -> int
    return a + b

Is this something that might be worthwhile for us to implement?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jdufresnecommented, Dec 18, 2020

Python type hints have since been added and are being improved upon. Perhaps it is okay to close this?

0reactions
jacopofarcommented, May 29, 2018

I see, the library supports Python 2 as well and so the parameter type has to be more flexible. Considering also the problem of the argument changing name, I think the added value of type hinting in this case is not worth it

Read more comments on GitHub >

github_iconTop Results From Across the Web

typing — Support for type hints — Python 3.11.1 documentation
This module provides runtime support for type hints. The most fundamental support consists of the types Any , Union , Callable , TypeVar...
Read more >
Type hints cheat sheet - mypy 0.991 documentation
Type hints cheat sheet#. This document is a quick cheat sheet showing how to use type annotations for various common types in Python....
Read more >
Type Hinting - Real Python
In this lesson, you'll learn about type hinting in Python. Type hinting is a formal solution to statically indicate the type of a...
Read more >
Python Type Hints
Python's type hints provide you with optional static typing to leverage the best of both static and dynamic typing. The following example defines...
Read more >
Get started with Python type hints | InfoWorld
Type hints in Python involve a colon and a type declaration after the first invocation of a name in a namespace. An example:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found