Skip to content

Commit

Permalink
Add assert_never to coverage ignore rules
Browse files Browse the repository at this point in the history
Since `assert_never` is not expected to be ever executed, I think it might be a good idea.
See https://docs.python.org/3/library/typing.html#typing.assert_never
  • Loading branch information
sobolevn authored and asottile committed Mar 5, 2023
1 parent 8f960b0 commit 6978aa5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions covdefaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def _version_pragmas(
r': \.\.\.(\s*#.*)?$',
r'^ +\.\.\.$',
r'-> [\'"]?NoReturn[\'"]?:',
r'^\s*assert_never\b',
# non-runnable code
r'^if __name__ == [\'"]__main__[\'"]:$',
*_plat_impl_pragmas(),
Expand Down
1 change: 1 addition & 0 deletions tests/covdefaults_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def test_exclude_lines_does_not_include_defaults(configured):
' if False:\n',
'if TYPE_CHECKING:\n',
' if TYPE_CHECKING:\n',
'assert_never(instance)',
'def f(x: int) -> int: ...\n',
'def f(x: int) -> int:\n ...\n',
'def f(x: int) -> C: ...# noqa: F821\n',
Expand Down

0 comments on commit 6978aa5

Please sign in to comment.