raisefunction 1.0.5__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {raisefunction-1.0.5 → raisefunction-1.1.0}/LICENSE.txt +1 -1
- raisefunction-1.1.0/MANIFEST.in +2 -0
- {raisefunction-1.0.5/src/raisefunction.egg-info → raisefunction-1.1.0}/PKG-INFO +8 -5
- raisefunction-1.1.0/README.rst +7 -0
- raisefunction-1.1.0/docs/v1.0.rst +55 -0
- raisefunction-1.1.0/docs/v1.1.rst +64 -0
- {raisefunction-1.0.5 → raisefunction-1.1.0}/pyproject.toml +9 -2
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction/core/__init__.py +3 -3
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction/tests/__init__.py +1 -1
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction/tests/test_0.py +11 -7
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction/tests/test_1.py +6 -2
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction/tests/test_2.py +8 -6
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction/tests/test_3.py +1 -1
- {raisefunction-1.0.5 → raisefunction-1.1.0/src/raisefunction.egg-info}/PKG-INFO +8 -5
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction.egg-info/SOURCES.txt +3 -0
- raisefunction-1.0.5/README.rst +0 -5
- {raisefunction-1.0.5 → raisefunction-1.1.0}/setup.cfg +0 -0
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction/__init__.py +0 -0
- /raisefunction-1.0.5/MANIFEST.in → /raisefunction-1.1.0/src/raisefunction/py.typed +0 -0
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction.egg-info/dependency_links.txt +0 -0
- {raisefunction-1.0.5 → raisefunction-1.1.0}/src/raisefunction.egg-info/top_level.txt +0 -0
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: raisefunction
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: This project provides a function that raises errors passed to it.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -24,6 +24,7 @@ License: The MIT License (MIT)
|
|
|
24
24
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
25
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
26
|
SOFTWARE.
|
|
27
|
+
|
|
27
28
|
Project-URL: Download, https://pypi.org/project/raisefunction/#files
|
|
28
29
|
Project-URL: Index, https://pypi.org/project/raisefunction/
|
|
29
30
|
Project-URL: Source, https://github.com/johannes-programming/raisefunction/
|
|
@@ -42,8 +43,10 @@ Description-Content-Type: text/x-rst
|
|
|
42
43
|
License-File: LICENSE.txt
|
|
43
44
|
Dynamic: license-file
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
====
|
|
47
|
+
v440
|
|
48
|
+
====
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
Each minor version has its own documentation.
|
|
51
|
+
These docs can be found as rst-files in the ``docs/`` directory of this project.
|
|
52
|
+
They can also be viewed on the website `https://raisefunction.johannes-programming.online/ <https://raisefunction.johannes-programming.online/>`_.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
====
|
|
2
|
+
v440
|
|
3
|
+
====
|
|
4
|
+
|
|
5
|
+
Each minor version has its own documentation.
|
|
6
|
+
These docs can be found as rst-files in the ``docs/`` directory of this project.
|
|
7
|
+
They can also be viewed on the website `https://raisefunction.johannes-programming.online/ <https://raisefunction.johannes-programming.online/>`_.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Introduction
|
|
2
|
+
------------
|
|
3
|
+
|
|
4
|
+
This project provides a function that raises errors passed to it.
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
To install ``raisefunction``, you can use ``pip``.
|
|
10
|
+
Open your terminal and run:
|
|
11
|
+
|
|
12
|
+
.. code-block:: shell
|
|
13
|
+
|
|
14
|
+
pip install raisefunction
|
|
15
|
+
|
|
16
|
+
Features
|
|
17
|
+
--------
|
|
18
|
+
|
|
19
|
+
``raisefunction.raisefunction(exc: BaseException) -> Never`` ``raisefunction.raisefunction(exc: BaseException, cause: Optional[BaseException]) -> Never``
|
|
20
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
21
|
+
|
|
22
|
+
This function binds the raise command.
|
|
23
|
+
|
|
24
|
+
``raisefunction.tests.test() -> unittest.TextTestResult``
|
|
25
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
26
|
+
|
|
27
|
+
This project can be tested through its test function.
|
|
28
|
+
|
|
29
|
+
.. code-block:: python
|
|
30
|
+
|
|
31
|
+
import raisefunction.tests
|
|
32
|
+
raisefunction.tests.test()
|
|
33
|
+
|
|
34
|
+
License
|
|
35
|
+
-------
|
|
36
|
+
|
|
37
|
+
This project is licensed under the MIT License.
|
|
38
|
+
|
|
39
|
+
Links
|
|
40
|
+
-----
|
|
41
|
+
|
|
42
|
+
- Download: https://pypi.org/project/raisefunction/#files
|
|
43
|
+
- Index: https://pypi.org/project/raisefunction/
|
|
44
|
+
- Source: https://github.com/johannes-programming/raisefunction/
|
|
45
|
+
- Website: https://raisefunction.johannes-programming.online/
|
|
46
|
+
|
|
47
|
+
Impressum
|
|
48
|
+
---------
|
|
49
|
+
|
|
50
|
+
**Johannes Programming**
|
|
51
|
+
|
|
52
|
+
- Name: Johannes
|
|
53
|
+
- Email: johannes.programming@gmail.com
|
|
54
|
+
- Homepage: https://www.johannes-programming.online/
|
|
55
|
+
- Gravatar: https://www.johannes-programming.fyi/
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Introduction
|
|
2
|
+
------------
|
|
3
|
+
|
|
4
|
+
This project provides a function that raises errors passed to it.
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
To install ``raisefunction``, you can use ``pip``.
|
|
10
|
+
Open your terminal and run:
|
|
11
|
+
|
|
12
|
+
.. code-block:: shell
|
|
13
|
+
|
|
14
|
+
pip install raisefunction
|
|
15
|
+
|
|
16
|
+
Typing
|
|
17
|
+
------
|
|
18
|
+
|
|
19
|
+
This project is strictly typed with ``mypy``.
|
|
20
|
+
|
|
21
|
+
.. container:: versionadded
|
|
22
|
+
|
|
23
|
+
**Added in version 1.1.**
|
|
24
|
+
|
|
25
|
+
Features
|
|
26
|
+
--------
|
|
27
|
+
|
|
28
|
+
``raisefunction.raisefunction(exc: BaseException) -> Never`` ``raisefunction.raisefunction(exc: BaseException, cause: Optional[BaseException]) -> Never``
|
|
29
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
30
|
+
|
|
31
|
+
This function binds the raise command.
|
|
32
|
+
|
|
33
|
+
``raisefunction.tests.test() -> unittest.TextTestResult``
|
|
34
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
35
|
+
|
|
36
|
+
This project can be tested through its test function.
|
|
37
|
+
|
|
38
|
+
.. code-block:: python
|
|
39
|
+
|
|
40
|
+
import raisefunction.tests
|
|
41
|
+
raisefunction.tests.test()
|
|
42
|
+
|
|
43
|
+
License
|
|
44
|
+
-------
|
|
45
|
+
|
|
46
|
+
This project is licensed under the MIT License.
|
|
47
|
+
|
|
48
|
+
Links
|
|
49
|
+
-----
|
|
50
|
+
|
|
51
|
+
- Download: https://pypi.org/project/raisefunction/#files
|
|
52
|
+
- Index: https://pypi.org/project/raisefunction/
|
|
53
|
+
- Source: https://github.com/johannes-programming/raisefunction/
|
|
54
|
+
- Website: https://raisefunction.johannes-programming.online/
|
|
55
|
+
|
|
56
|
+
Impressum
|
|
57
|
+
---------
|
|
58
|
+
|
|
59
|
+
**Johannes Programming**
|
|
60
|
+
|
|
61
|
+
- Name: Johannes
|
|
62
|
+
- Email: johannes.programming@gmail.com
|
|
63
|
+
- Homepage: https://www.johannes-programming.online/
|
|
64
|
+
- Gravatar: https://www.johannes-programming.fyi/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[build-system]
|
|
2
2
|
build-backend = "setuptools.build_meta"
|
|
3
3
|
requires = [
|
|
4
|
-
"setuptools>=
|
|
4
|
+
"setuptools>=77.0",
|
|
5
5
|
]
|
|
6
6
|
|
|
7
7
|
[project]
|
|
@@ -25,7 +25,7 @@ keywords = []
|
|
|
25
25
|
name = "raisefunction"
|
|
26
26
|
readme = "README.rst"
|
|
27
27
|
requires-python = ">=3.11"
|
|
28
|
-
version = "1.0
|
|
28
|
+
version = "1.1.0"
|
|
29
29
|
|
|
30
30
|
[project.license]
|
|
31
31
|
file = "LICENSE.txt"
|
|
@@ -35,3 +35,10 @@ Download = "https://pypi.org/project/raisefunction/#files"
|
|
|
35
35
|
Index = "https://pypi.org/project/raisefunction/"
|
|
36
36
|
Source = "https://github.com/johannes-programming/raisefunction/"
|
|
37
37
|
Website = "https://raisefunction.johannes-programming.online/"
|
|
38
|
+
|
|
39
|
+
[tool.mypy]
|
|
40
|
+
files = [
|
|
41
|
+
".",
|
|
42
|
+
]
|
|
43
|
+
python_version = "3.11"
|
|
44
|
+
strict = true
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Final, Never, Optional, cast, overload
|
|
2
2
|
|
|
3
3
|
__all__ = ["raisefunction"]
|
|
4
4
|
|
|
5
|
-
DEFAULT = object()
|
|
5
|
+
DEFAULT: Final[object] = object()
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
@overload
|
|
@@ -24,4 +24,4 @@ def raisefunction(
|
|
|
24
24
|
if cause is DEFAULT:
|
|
25
25
|
raise exc
|
|
26
26
|
else:
|
|
27
|
-
raise exc from cause
|
|
27
|
+
raise exc from cast(Optional[BaseException], cause)
|
|
@@ -10,13 +10,13 @@ class Test0(unittest.TestCase):
|
|
|
10
10
|
def test_dispatcher_no_arguments(self: Self) -> None:
|
|
11
11
|
"Test the dispatcher raises a TypeError with no arguments."
|
|
12
12
|
with self.assertRaises(TypeError):
|
|
13
|
-
raisefunction()
|
|
13
|
+
raisefunction() # type: ignore[call-overload]
|
|
14
14
|
# self.assertIn("requires at least 1 positional argument", str(context.exception))
|
|
15
15
|
|
|
16
16
|
def test_dispatcher_too_many_arguments(self: Self) -> None:
|
|
17
17
|
"Test the dispatcher raises a TypeError with more than 2 arguments."
|
|
18
18
|
with self.assertRaises(TypeError):
|
|
19
|
-
raisefunction(1, 2, 3)
|
|
19
|
+
raisefunction(1, 2, 3) # type: ignore[call-overload]
|
|
20
20
|
# self.assertIn("takes at most 2 positional arguments", str(context.exception))
|
|
21
21
|
|
|
22
22
|
def test_raise_single_exception(self: Self) -> None:
|
|
@@ -24,10 +24,12 @@ class Test0(unittest.TestCase):
|
|
|
24
24
|
with self.assertRaises(ValueError):
|
|
25
25
|
raisefunction(ValueError("Test single exception"))
|
|
26
26
|
|
|
27
|
-
def
|
|
27
|
+
def test_raise_exception_with_cause_0(self: Self) -> None:
|
|
28
28
|
"Test the exception raising overload with a cause."
|
|
29
29
|
with self.assertRaises(ValueError) as context:
|
|
30
|
-
raisefunction(
|
|
30
|
+
raisefunction(
|
|
31
|
+
ValueError("Test exception"), TypeError("Cause exception")
|
|
32
|
+
)
|
|
31
33
|
self.assertEqual(str(context.exception), "Test exception")
|
|
32
34
|
self.assertIsInstance(context.exception.__cause__, TypeError)
|
|
33
35
|
self.assertEqual(str(context.exception.__cause__), "Cause exception")
|
|
@@ -35,14 +37,16 @@ class Test0(unittest.TestCase):
|
|
|
35
37
|
def test_invalid_arguments_in_overloads(self: Self) -> None:
|
|
36
38
|
"Test invalid argument types raise appropriate errors."
|
|
37
39
|
with self.assertRaises(TypeError):
|
|
38
|
-
raisefunction("not an exception")
|
|
40
|
+
raisefunction("not an exception") # type: ignore[call-overload]
|
|
39
41
|
with self.assertRaises(TypeError):
|
|
40
|
-
raisefunction("not an exception", "not a cause")
|
|
42
|
+
raisefunction("not an exception", "not a cause") # type: ignore[call-overload]
|
|
41
43
|
|
|
42
44
|
def test_raise_exception_with_cause(self: Self) -> None:
|
|
43
45
|
"Test the exception raising overload with a cause."
|
|
44
46
|
with self.assertRaises(ValueError) as context:
|
|
45
|
-
raisefunction(
|
|
47
|
+
raisefunction(
|
|
48
|
+
ValueError("Test exception"), KeyError("Cause exception")
|
|
49
|
+
)
|
|
46
50
|
self.assertEqual(str(context.exception), "Test exception")
|
|
47
51
|
self.assertIsInstance(context.exception.__cause__, KeyError)
|
|
48
52
|
|
|
@@ -37,7 +37,9 @@ class Test1(unittest.TestCase):
|
|
|
37
37
|
|
|
38
38
|
self.assertIs(cm.exception.__cause__, cause)
|
|
39
39
|
|
|
40
|
-
def test_raises_with_suppressed_context_when_cause_is_none(
|
|
40
|
+
def test_raises_with_suppressed_context_when_cause_is_none(
|
|
41
|
+
self: Self,
|
|
42
|
+
) -> None:
|
|
41
43
|
exc: ValueError
|
|
42
44
|
exc = ValueError("no context")
|
|
43
45
|
|
|
@@ -48,7 +50,9 @@ class Test1(unittest.TestCase):
|
|
|
48
50
|
|
|
49
51
|
self.assertIsNone(cm.exception.__cause__)
|
|
50
52
|
|
|
51
|
-
def test_raising_class_that_requires_args_produces_type_error(
|
|
53
|
+
def test_raising_class_that_requires_args_produces_type_error(
|
|
54
|
+
self: Self,
|
|
55
|
+
) -> None:
|
|
52
56
|
class NeedsArg(Exception):
|
|
53
57
|
def __init__(self: Self, msg: str) -> None:
|
|
54
58
|
super().__init__(msg)
|
|
@@ -8,7 +8,7 @@ __all__ = ["Test2"]
|
|
|
8
8
|
|
|
9
9
|
class Test2(unittest.TestCase):
|
|
10
10
|
def test_raises_given_exception_instance_without_cause(self: Self) -> None:
|
|
11
|
-
cm:
|
|
11
|
+
cm: Any
|
|
12
12
|
exc: ValueError
|
|
13
13
|
exc = ValueError("boom")
|
|
14
14
|
|
|
@@ -21,7 +21,7 @@ class Test2(unittest.TestCase):
|
|
|
21
21
|
self.assertIsNone(cm.exception.__cause__)
|
|
22
22
|
|
|
23
23
|
def test_raises_given_exception_class_without_cause(self: Self) -> None:
|
|
24
|
-
cm:
|
|
24
|
+
cm: Any
|
|
25
25
|
with self.assertRaises(ValueError) as cm:
|
|
26
26
|
core.raisefunction(ValueError)
|
|
27
27
|
|
|
@@ -30,7 +30,7 @@ class Test2(unittest.TestCase):
|
|
|
30
30
|
|
|
31
31
|
def test_raises_with_explicit_cause(self: Self) -> None:
|
|
32
32
|
cause: RuntimeError
|
|
33
|
-
cm:
|
|
33
|
+
cm: Any
|
|
34
34
|
exc: ValueError
|
|
35
35
|
cause = RuntimeError("original")
|
|
36
36
|
exc = ValueError("wrapped")
|
|
@@ -41,7 +41,7 @@ class Test2(unittest.TestCase):
|
|
|
41
41
|
self.assertIs(cm.exception.__cause__, cause)
|
|
42
42
|
|
|
43
43
|
def test_raise_from_None(self: Self) -> None:
|
|
44
|
-
cm:
|
|
44
|
+
cm: Any
|
|
45
45
|
exc: ValueError
|
|
46
46
|
one: int
|
|
47
47
|
zero: int
|
|
@@ -59,12 +59,14 @@ class Test2(unittest.TestCase):
|
|
|
59
59
|
self.assertIsInstance(cm.exception.__context__, ZeroDivisionError)
|
|
60
60
|
self.assertTrue(cm.exception.__suppress_context__)
|
|
61
61
|
|
|
62
|
-
def test_raising_class_that_requires_args_produces_type_error(
|
|
62
|
+
def test_raising_class_that_requires_args_produces_type_error(
|
|
63
|
+
self: Self,
|
|
64
|
+
) -> None:
|
|
63
65
|
class NeedsArg(Exception):
|
|
64
66
|
def __init__(self: Self, msg: str) -> None:
|
|
65
67
|
super().__init__(msg)
|
|
66
68
|
|
|
67
|
-
cm:
|
|
69
|
+
cm: Any
|
|
68
70
|
with self.assertRaises(TypeError) as cm:
|
|
69
71
|
core.raisefunction(NeedsArg)
|
|
70
72
|
|
|
@@ -9,7 +9,7 @@ __all__ = ["Test3"]
|
|
|
9
9
|
class Test3(unittest.TestCase):
|
|
10
10
|
|
|
11
11
|
def go(self: Self, *, use_func: bool) -> None:
|
|
12
|
-
cm:
|
|
12
|
+
cm: Any
|
|
13
13
|
exc: ValueError
|
|
14
14
|
exc = ValueError("no context")
|
|
15
15
|
with self.assertRaises(ValueError) as cm:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: raisefunction
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: This project provides a function that raises errors passed to it.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -24,6 +24,7 @@ License: The MIT License (MIT)
|
|
|
24
24
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
25
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
26
|
SOFTWARE.
|
|
27
|
+
|
|
27
28
|
Project-URL: Download, https://pypi.org/project/raisefunction/#files
|
|
28
29
|
Project-URL: Index, https://pypi.org/project/raisefunction/
|
|
29
30
|
Project-URL: Source, https://github.com/johannes-programming/raisefunction/
|
|
@@ -42,8 +43,10 @@ Description-Content-Type: text/x-rst
|
|
|
42
43
|
License-File: LICENSE.txt
|
|
43
44
|
Dynamic: license-file
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
====
|
|
47
|
+
v440
|
|
48
|
+
====
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
Each minor version has its own documentation.
|
|
51
|
+
These docs can be found as rst-files in the ``docs/`` directory of this project.
|
|
52
|
+
They can also be viewed on the website `https://raisefunction.johannes-programming.online/ <https://raisefunction.johannes-programming.online/>`_.
|
|
@@ -3,7 +3,10 @@ MANIFEST.in
|
|
|
3
3
|
README.rst
|
|
4
4
|
pyproject.toml
|
|
5
5
|
setup.cfg
|
|
6
|
+
docs/v1.0.rst
|
|
7
|
+
docs/v1.1.rst
|
|
6
8
|
src/raisefunction/__init__.py
|
|
9
|
+
src/raisefunction/py.typed
|
|
7
10
|
src/raisefunction.egg-info/PKG-INFO
|
|
8
11
|
src/raisefunction.egg-info/SOURCES.txt
|
|
9
12
|
src/raisefunction.egg-info/dependency_links.txt
|
raisefunction-1.0.5/README.rst
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|