File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ ###########################################################################
2
+ # Copyright (c), The AiiDA team. All rights reserved. #
3
+ # This file is part of the AiiDA code. #
4
+ # #
5
+ # The code is hosted on GitHub at https://github.com/aiidateam/aiida-core #
6
+ # For further information on the license, see the LICENSE.txt file #
7
+ # For further information please visit http://www.aiida.net #
8
+ ###########################################################################
9
+ """Module with asserts that can be used in the codebase."""
10
+
11
+ from typing import Optional
12
+
13
+ try :
14
+ from typing import Never
15
+ except ImportError :
16
+ # Fallback for Python 3.10 and older
17
+ from typing_extensions import Never
18
+
19
+
20
+ def assert_never (arg : Never , message : Optional [str ] = None ) -> Never :
21
+ """Assert a part of code that should never be reached.
22
+ This is useful, especially when adding new variables to an enum,
23
+ so to remind the developers to handle the new variable in all the switch cases.
24
+ """
25
+
26
+ raise AssertionError ('This part of code should never be reached' if not message else message )
You can’t perform that action at this time.
0 commit comments