FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Skip rest of file upon top-level always-false assert by gvanrossum · Pull Request #5894 · python/mypy · GitHub

Repository navigation

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

Merged
gvanrossum merged 5 commits into
python:masterfrom
gvanrossum:platform-assert
Nov 15, 2018
Merged

gvanrossum merged 5 commits into
python:masterfrom
gvanrossum:platform-assert

Conversation

Copy link
Copy Markdown
Member
  • A top-level assert has no indentation.

  • An always-false condition is a check for sys.platform or
    sys.version_info or a condition derived from MYPY or from a name
    passed to --always-false; assert False doesn't count (!).
    (This definition is the same used to exclude conditional imports.)

Fixes #5308.

Guido van Rossum added 3 commits November 14, 2018 15:10
- A top-level assert has no indentation.

- An always-false condition is a check for sys.platform or
  sys.version_info or a condition derived from MYPY or from a name
  passed to --always-false; `assert False` doesn't count (!).

Fixes python#5308
gvanrossum requested a review from JukkaL November 14, 2018 23:41

JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good, just a few minor comments.

Comment thread docs/source/common_issues.rst Outdated
# 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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

return 3
[builtins fixtures/isinstance.pyi]

[case testUnreachableAfterToplevelAssert]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Maybe also test the case where the assert is nested within an if statement.

Copy link
Copy Markdown
Member Author

OK, updated doc and added test.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL