Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add document for undocumented error codes #15212

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions docs/source/error_code_list2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,77 @@ Example:
# The following will not generate an error on either
# Python 3.8, or Python 3.9
42 + "testing..." # type: ignore

.. _code-empty-body:

Check that functions have empty body [empty-body]
-------------------------------------------------------------------

mypy generates an error if you have a function that has an empty body.
Example:

.. code-block:: python

# Use "mypy --enable-error-code empty-body ..."

def f(x: int) -> str:
# Error: Function is missing a body
pass

.. _code-top-level-await:

Check that your code have top-level await statements [top-level-await]
----------------------------------------------------------------------

mypy generates an error if you have a top-level await statement.

Example:

.. code-block:: python


import asyncio

async def f() -> int:
return 1

# Error: "await" used at the top level
await f()

.. _code-str-format:

Check that strings have wrong format parameters [str-format]
------------------------------------------------------------

mypy generates an error if you have a string with wrong format parameters.

Example:

.. code-block:: python

# Error: More parameters than arguments
print("Hello {0} {1}".format("World"))

# Error: More arguments than parameters
print("Hello {0} {1}".format(1, 2, 3))

# Error: format argument is not type-safe
print("%d %d" % ("Hello", "World"))

.. _code-annotation-unchecked:

Check that annotations are inside an unannotated function [annotation-unchecked]
--------------------------------------------------------------------------------

mypy generates an error to notify that you have annotations which are not checked in an unannotated function.

Consider using --check-untyped-defs option if you want to check unannotated functions as well.

Example:

.. code-block:: python

def f():
x: int = 1
# Error: Annotation type "int" is not checked
return x
Loading