Skip to content

Change untyped libraries from error to warning by default #10456

Closed
@CrazyPython

Description

@CrazyPython

Feature

Change "found module but no type hints or library stubs" to a warning, not an error.

Change this:

lib.py:22: error: Skipping analyzing 'regex': found module but no type hints or library stubs
lib.py:136: error: Incompatible types in assignment (expression has type "float", variable has type "int")
persist.py:203: error: Skipping analyzing 'discord': found module but no type hints or library stubs
Found 2 errors in 2 files (checked 1 source file)

Into this:

lib.py:22: warning: Skipping analyzing 'regex': found module but no type hints or library stubs
lib.py:136: error: Incompatible types in assignment (expression has type "float", variable has type "int")
persist.py:203: warning: Skipping analyzing 'discord': found module but no type hints or library stubs
Found 1 error in 1 files (checked 1 source file)

Pitch

The vast majority of Python libraries lack type hints. Outside a group of highly skilled Pythonistas, few use type hints, partly because libraries don't use it. Showing that libraries fail to use type hints as an error dissuades new users from using mypy and hurts mypy adoption. Even without 3rd party type hints, type hinting a library internally can still be quite useful.

It also makes it harder to distinguish from actual typecheck errors.

Evidence

A lack of typing is the #1 most cited reason people avoid Python for large, "scalable" projects, and prefer Java, Go, or another statically typed language. On multiple occasions I have rebutted them by saying mypy exists and works well. Most of the time, the response is that most Python libraries do not support mypy. However, mypy can help people write Python in larger codebases without needing library type stubs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions