8000 Skip rest of file upon top-level always-false assert by gvanrossum · Pull Request #5894 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Skip rest of file upon top-level always-false assert #5894

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

Merged
merged 5 commits into from
Nov 15, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add docs
  • Loading branch information
Guido van Rossum committed Nov 14, 2018
commit c38381873e8858d34e74e9deac2696fd684f9555
16 changes: 16 additions & 0 deletions docs/source/common_issues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,22 @@ More specifically, mypy will understand the use of ``sys.version_info`` and
else:
# Other systems

As a special case, you can also use one of these checks in a top-level
``assert``; this makes mypy skip the rest of the file. Example:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explicitly mention that the assert must be unconditional and not nested within a statement.


.. code-block:: python

import sys

assert sys.platform != 'win32'

# The rest of this file doesn't apply to Windows.

Some other expressions exhibit similar behavior; in particular,
``typing.TYPE_CHECKING``, variables named ``MYPY``, and any variable
whose name is passed to ``--always-true`` or ``--always-false``.
(However, ``True`` and ``False`` are not treated specially!)

.. note::

Mypy currently does not support more complex checks, and does not assign
Expand Down
0