panyc 1.0.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.
panyc-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.4
2
+ Name: panyc
3
+ Version: 1.0.0
4
+ Home-page: https://codeberg.org/bnz/panyc
5
+ Author: bnz
6
+ Author-email: matteo.benzi97@gmail.com
7
+ License: MIT
8
+ Description-Content-Type: text/markdown
9
+ Dynamic: author
10
+ Dynamic: author-email
11
+ Dynamic: description
12
+ Dynamic: description-content-type
13
+ Dynamic: home-page
14
+ Dynamic: license
15
+
16
+ # Panyc
17
+
18
+ Super simple python package to solve 2 problems:
19
+ - In Python `assert` is not guaranteed to work (see the `-O` flag)
20
+ - The very convenient `todo()`/`unreachable()`/... functions to panic in case reached, are missing
21
+
22
+ ### Usage
23
+
24
+ ```python
25
+ from panyc import raise_if
26
+
27
+ def is_even(x):
28
+ raise_if(type(x) != int, f"expected an integer, got {type(x)}")
29
+ return x % 2 == 0
30
+
31
+ def main():
32
+ x = 6.9
33
+ print("Is", x, "even?", is_even(x))
34
+
35
+ main()
36
+ ```
37
+ Will result in `AssertionError: /path/to/file/example.py:4: expected an integer, got <class 'float'>`
38
+
39
+ > A couple of notice:
40
+ > - first of all the condition must be true to raise, in the contrary of `assert` where it must be false
41
+ > - secondly it raise an `AssertionError` as well, so the error handling remain the same
42
+ >
43
+ > So if you plan to rewrite your `assert`s you have to change the condition and nothing else
44
+
45
+
46
+ ```python
47
+ from panyc import todo
48
+
49
+ def end_world_hungry():
50
+ todo()
51
+
52
+ def main():
53
+ end_world_hungry()
54
+
55
+ main()
56
+ ```
57
+ Will result in `NotImplementedError: /path/to/file/example.py:4: Function "end_world_hungry" not implemented`
58
+
59
+
60
+ ```python
61
+ from panyc import unreachable
62
+
63
+ def sound(x):
64
+ if x == "cat":
65
+ return "meow"
66
+ elif x == "dog":
67
+ return "woof"
68
+ elif x == "duck":
69
+ return "quack"
70
+ unreachable() # we do not expect other animals
71
+
72
+ def main():
73
+ print(sound("crocodile"))
74
+
75
+ main()
76
+ ```
77
+ Will result in `NotImplementedError: /path/to/file/example.py:10: Reached unreachable code in "sound"`
78
+
79
+ ### Installation
80
+
81
+ Just copy the only file `panyc.py` in your project.
82
+
83
+ If you like the slop, there's also the package on pypi:
84
+ ```console
85
+ $ pip install panyc
86
+ ```
panyc-1.0.0/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Panyc
2
+
3
+ Super simple python package to solve 2 problems:
4
+ - In Python `assert` is not guaranteed to work (see the `-O` flag)
5
+ - The very convenient `todo()`/`unreachable()`/... functions to panic in case reached, are missing
6
+
7
+ ### Usage
8
+
9
+ ```python
10
+ from panyc import raise_if
11
+
12
+ def is_even(x):
13
+ raise_if(type(x) != int, f"expected an integer, got {type(x)}")
14
+ return x % 2 == 0
15
+
16
+ def main():
17
+ x = 6.9
18
+ print("Is", x, "even?", is_even(x))
19
+
20
+ main()
21
+ ```
22
+ Will result in `AssertionError: /path/to/file/example.py:4: expected an integer, got <class 'float'>`
23
+
24
+ > A couple of notice:
25
+ > - first of all the condition must be true to raise, in the contrary of `assert` where it must be false
26
+ > - secondly it raise an `AssertionError` as well, so the error handling remain the same
27
+ >
28
+ > So if you plan to rewrite your `assert`s you have to change the condition and nothing else
29
+
30
+
31
+ ```python
32
+ from panyc import todo
33
+
34
+ def end_world_hungry():
35
+ todo()
36
+
37
+ def main():
38
+ end_world_hungry()
39
+
40
+ main()
41
+ ```
42
+ Will result in `NotImplementedError: /path/to/file/example.py:4: Function "end_world_hungry" not implemented`
43
+
44
+
45
+ ```python
46
+ from panyc import unreachable
47
+
48
+ def sound(x):
49
+ if x == "cat":
50
+ return "meow"
51
+ elif x == "dog":
52
+ return "woof"
53
+ elif x == "duck":
54
+ return "quack"
55
+ unreachable() # we do not expect other animals
56
+
57
+ def main():
58
+ print(sound("crocodile"))
59
+
60
+ main()
61
+ ```
62
+ Will result in `NotImplementedError: /path/to/file/example.py:10: Reached unreachable code in "sound"`
63
+
64
+ ### Installation
65
+
66
+ Just copy the only file `panyc.py` in your project.
67
+
68
+ If you like the slop, there's also the package on pypi:
69
+ ```console
70
+ $ pip install panyc
71
+ ```
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.4
2
+ Name: panyc
3
+ Version: 1.0.0
4
+ Home-page: https://codeberg.org/bnz/panyc
5
+ Author: bnz
6
+ Author-email: matteo.benzi97@gmail.com
7
+ License: MIT
8
+ Description-Content-Type: text/markdown
9
+ Dynamic: author
10
+ Dynamic: author-email
11
+ Dynamic: description
12
+ Dynamic: description-content-type
13
+ Dynamic: home-page
14
+ Dynamic: license
15
+
16
+ # Panyc
17
+
18
+ Super simple python package to solve 2 problems:
19
+ - In Python `assert` is not guaranteed to work (see the `-O` flag)
20
+ - The very convenient `todo()`/`unreachable()`/... functions to panic in case reached, are missing
21
+
22
+ ### Usage
23
+
24
+ ```python
25
+ from panyc import raise_if
26
+
27
+ def is_even(x):
28
+ raise_if(type(x) != int, f"expected an integer, got {type(x)}")
29
+ return x % 2 == 0
30
+
31
+ def main():
32
+ x = 6.9
33
+ print("Is", x, "even?", is_even(x))
34
+
35
+ main()
36
+ ```
37
+ Will result in `AssertionError: /path/to/file/example.py:4: expected an integer, got <class 'float'>`
38
+
39
+ > A couple of notice:
40
+ > - first of all the condition must be true to raise, in the contrary of `assert` where it must be false
41
+ > - secondly it raise an `AssertionError` as well, so the error handling remain the same
42
+ >
43
+ > So if you plan to rewrite your `assert`s you have to change the condition and nothing else
44
+
45
+
46
+ ```python
47
+ from panyc import todo
48
+
49
+ def end_world_hungry():
50
+ todo()
51
+
52
+ def main():
53
+ end_world_hungry()
54
+
55
+ main()
56
+ ```
57
+ Will result in `NotImplementedError: /path/to/file/example.py:4: Function "end_world_hungry" not implemented`
58
+
59
+
60
+ ```python
61
+ from panyc import unreachable
62
+
63
+ def sound(x):
64
+ if x == "cat":
65
+ return "meow"
66
+ elif x == "dog":
67
+ return "woof"
68
+ elif x == "duck":
69
+ return "quack"
70
+ unreachable() # we do not expect other animals
71
+
72
+ def main():
73
+ print(sound("crocodile"))
74
+
75
+ main()
76
+ ```
77
+ Will result in `NotImplementedError: /path/to/file/example.py:10: Reached unreachable code in "sound"`
78
+
79
+ ### Installation
80
+
81
+ Just copy the only file `panyc.py` in your project.
82
+
83
+ If you like the slop, there's also the package on pypi:
84
+ ```console
85
+ $ pip install panyc
86
+ ```
@@ -0,0 +1,7 @@
1
+ README.md
2
+ panyc.py
3
+ setup.py
4
+ panyc.egg-info/PKG-INFO
5
+ panyc.egg-info/SOURCES.txt
6
+ panyc.egg-info/dependency_links.txt
7
+ panyc.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ panyc
panyc-1.0.0/panyc.py ADDED
@@ -0,0 +1,26 @@
1
+ # Copyright © 2025 Matteo Benzi <matteo.benzi97@gmail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+ #
5
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+ #
7
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
9
+ import inspect
10
+
11
+ def raise_if(expr, message):
12
+ if expr:
13
+ caller = inspect.stack()[1]
14
+ raise AssertionError(f"{caller.filename}:{caller.lineno}: {message}")
15
+
16
+ def todo(message=""):
17
+ caller = inspect.stack()[1]
18
+ if len(message) > 0:
19
+ message = f" ({message})"
20
+ raise NotImplementedError(f'{caller.filename}:{caller.lineno}: Function "{caller.function}" not implemented{message}')
21
+
22
+ def unreachable(message=""):
23
+ caller = inspect.stack()[1]
24
+ if len(message) > 0:
25
+ message = f" ({message})"
26
+ raise NotImplementedError(f'{caller.filename}:{caller.lineno}: Reached unreachable code in "{caller.function}"{message}')
panyc-1.0.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
panyc-1.0.0/setup.py ADDED
@@ -0,0 +1,17 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ with open("README.md", "r") as f:
4
+ description = f.read()
5
+
6
+ setup(
7
+ name='panyc',
8
+ version='1.0.0',
9
+ description='',
10
+ long_description=description,
11
+ long_description_content_type="text/markdown",
12
+ author='bnz',
13
+ author_email='matteo.benzi97@gmail.com',
14
+ url='https://codeberg.org/bnz/panyc',
15
+ license="MIT",
16
+ scripts=["panyc.py"],
17
+ )