StructResult 0.2.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.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.2
2
+ Name: StructResult
3
+ Version: 0.2.0
4
+ Summary: structural result with exception
5
+ Author-email: Serj Kotilevski <youserj@outlook.com>
6
+ Project-URL: Source, https://github.com/youserj/Result_prj
7
+ Keywords: result,exception
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.12
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Result_prj
15
+ python return struct
@@ -0,0 +1,2 @@
1
+ # Result_prj
2
+ python return struct
@@ -0,0 +1,28 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools",
4
+ "setuptools-scm"]
5
+ build-backend = "setuptools.build_meta"
6
+
7
+ [tool.setuptools.packages.find]
8
+ where = ["src"]
9
+
10
+ [project]
11
+ name = "StructResult"
12
+ version = "0.2.0"
13
+ requires-python = ">= 3.12"
14
+ authors = [
15
+ {name="Serj Kotilevski", email="youserj@outlook.com"}
16
+ ]
17
+ dependencies = [
18
+ ]
19
+ description="structural result with exception"
20
+ readme = "README.md"
21
+ keywords=['result', 'exception']
22
+ classifiers = [
23
+ "Programming Language :: Python :: 3",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Operating System :: OS Independent",
26
+ ]
27
+ [project.urls]
28
+ Source = "https://github.com/youserj/Result_prj"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from .main import Result
@@ -0,0 +1,26 @@
1
+ from typing import Optional, TypeVar, Generic
2
+
3
+ T = TypeVar("T")
4
+
5
+
6
+ class Result(Generic[T]):
7
+ value: T
8
+ err: Optional[list[Exception]]
9
+ __slots__ = ("value", "err")
10
+
11
+ def __init__(self, value: T):
12
+ self.value = value
13
+ self.err = None
14
+
15
+ def __getitem__(self, item):
16
+ if item == 0:
17
+ return self.value
18
+ elif item == 1:
19
+ return self.err
20
+ else:
21
+ raise StopIteration
22
+
23
+ def append_err(self, e: Exception):
24
+ if self.err is None:
25
+ self.err = list()
26
+ self.err.append(e)
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.2
2
+ Name: StructResult
3
+ Version: 0.2.0
4
+ Summary: structural result with exception
5
+ Author-email: Serj Kotilevski <youserj@outlook.com>
6
+ Project-URL: Source, https://github.com/youserj/Result_prj
7
+ Keywords: result,exception
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.12
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Result_prj
15
+ python return struct
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/StructResult/__init__.py
4
+ src/StructResult/main.py
5
+ src/StructResult.egg-info/PKG-INFO
6
+ src/StructResult.egg-info/SOURCES.txt
7
+ src/StructResult.egg-info/dependency_links.txt
8
+ src/StructResult.egg-info/top_level.txt
9
+ test/test_Result.py
@@ -0,0 +1 @@
1
+ StructResult
@@ -0,0 +1,11 @@
1
+ import unittest
2
+ from StructResult import Result
3
+
4
+
5
+ class TestType(unittest.TestCase):
6
+
7
+ def test_init(self):
8
+ res = Result[int](1)
9
+ self.assertEqual(res.value, 1)
10
+ self.assertEqual(list(res), [1, None])
11
+