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.

[Feature Request] Mypy type checking

See original GitHub issue

🚀 Feature

Use mypy as the type checker.

Follow-up of https://github.com/DLR-RM/stable-baselines3/issues/1119#issuecomment-1279241980

Motivation

Currently, type checking is done with pytype. It seems that many errors are not correctly detected: #894 #1027 #1039 #1040 #1117 #1119

Pitch

Replace pytype by mypy. Or just add mypy.

Alternatives

No response

Additional context

This would require a lot of changes, in particular removing the use of None for undefined variables:

current usage

from typing import Optional

class A:
    def __init__(self):
        self.a = None # type: Optional[int]

what should be done, according to PEP526 (if I understand properly)

class A:
    def __init__(self):
        self.a: int

Checklist

  • I have checked that there is no similar issue in the repo

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
qgallouedeccommented, Oct 27, 2022

I don’t mind either way. We can go with 3 for now, if it gets too messy we can switch to 2.

Let’s do the opposite: we go for option 2 and if fixing is too hard, we switch to 3. Ok for you?

0reactions
araffincommented, Oct 27, 2022

So we would go with option 3?

i thought that @Rocamonde described option 2, no?

This is because the same error across different files is usually caused by totally different reasons

I was expecting the opposite actually (that’s why I was suggesting option 1).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request: mypy type-checking · Issue #794 · taichi-dev ...
Concisely describe the proposed feature I use the mypy static type-checker in my python projects and I'd like to use it with my...
Read more >
mypy 0.991 documentation
Mypy is a static type checker for Python. ... Mypy has a powerful and easy-to-use type system, supporting features such as type inference,...
Read more >
Python Type Checking (Guide) - Real Python
In this guide, you'll look at Python type checking. Traditionally, types have been handled by the Python interpreter in a flexible but implicit...
Read more >
Optional Static Typing using mypy - Anvil Works
We need a type checker like MyPy to enforce those types. I stumbled across this older thread looking for this exact feature.
Read more >
How to start using Python Type Annotations with Mypy
Mypy is a third-party Python library that provides optional static type checking. Unlike other non-dynamic programming languages like Java, where the static ...
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