typeguard-gunes 0.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.
- typeguard_gunes-0.1.0/PKG-INFO +32 -0
- typeguard_gunes-0.1.0/README.md +24 -0
- typeguard_gunes-0.1.0/pyproject.toml +17 -0
- typeguard_gunes-0.1.0/setup.cfg +4 -0
- typeguard_gunes-0.1.0/src/typeguard_gunes/__init__.py +4 -0
- typeguard_gunes-0.1.0/src/typeguard_gunes/__main__.py +22 -0
- typeguard_gunes-0.1.0/src/typeguard_gunes/core.py +24 -0
- typeguard_gunes-0.1.0/src/typeguard_gunes.egg-info/PKG-INFO +32 -0
- typeguard_gunes-0.1.0/src/typeguard_gunes.egg-info/SOURCES.txt +10 -0
- typeguard_gunes-0.1.0/src/typeguard_gunes.egg-info/dependency_links.txt +1 -0
- typeguard_gunes-0.1.0/src/typeguard_gunes.egg-info/entry_points.txt +2 -0
- typeguard_gunes-0.1.0/src/typeguard_gunes.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: typeguard_gunes
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fonksiyon argümanlarının tiplerini kontrol eden TypeGuard decorator'ı
|
|
5
|
+
Author: Beytullah
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# typeguard_gunes
|
|
10
|
+
|
|
11
|
+
Fonksiyonların keyword argümanlarını type annotation'lara göre kontrol eden bir decorator.
|
|
12
|
+
|
|
13
|
+
## Kurulum
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
pip install typeguard_gunes
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Kullanım
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from typeguard_gunes import TypeGuard, WrongTypeAnnotationError
|
|
23
|
+
|
|
24
|
+
@TypeGuard(label="Custom Type Guard")
|
|
25
|
+
def add(*, x: int, y: int) -> int:
|
|
26
|
+
return x + y
|
|
27
|
+
|
|
28
|
+
add(x=6, y=4) # 10
|
|
29
|
+
add(x=6, y="Canbula") # WrongTypeAnnotationError
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Örneği çalıştırmak için terminalde `typeguard_gunes` ya da `python -m typeguard_gunes` yazman yeterli.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# typeguard_gunes
|
|
2
|
+
|
|
3
|
+
Fonksiyonların keyword argümanlarını type annotation'lara göre kontrol eden bir decorator.
|
|
4
|
+
|
|
5
|
+
## Kurulum
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pip install typeguard_gunes
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Kullanım
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from typeguard_gunes import TypeGuard, WrongTypeAnnotationError
|
|
15
|
+
|
|
16
|
+
@TypeGuard(label="Custom Type Guard")
|
|
17
|
+
def add(*, x: int, y: int) -> int:
|
|
18
|
+
return x + y
|
|
19
|
+
|
|
20
|
+
add(x=6, y=4) # 10
|
|
21
|
+
add(x=6, y="Canbula") # WrongTypeAnnotationError
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Örneği çalıştırmak için terminalde `typeguard_gunes` ya da `python -m typeguard_gunes` yazman yeterli.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "typeguard_gunes"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Fonksiyon argümanlarının tiplerini kontrol eden TypeGuard decorator'ı"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
authors = [{ name = "Beytullah" }]
|
|
12
|
+
|
|
13
|
+
[project.scripts]
|
|
14
|
+
typeguard_gunes = "typeguard_gunes.__main__:main"
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
where = ["src"]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from typeguard_gunes import TypeGuard
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@TypeGuard(label="Custom Type Guard")
|
|
5
|
+
def add(*, x: int, y: int) -> int:
|
|
6
|
+
return x + y
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main():
|
|
10
|
+
x = 6
|
|
11
|
+
y = "Canbula"
|
|
12
|
+
try:
|
|
13
|
+
result = add(x=x, y=y)
|
|
14
|
+
print(f"Result: {result}")
|
|
15
|
+
except TypeError as e:
|
|
16
|
+
print(f"TypeError: {e}")
|
|
17
|
+
except Exception as e:
|
|
18
|
+
print(f"Error ({e.__class__.__name__}): {e}")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if __name__ == "__main__":
|
|
22
|
+
main()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class WrongTypeAnnotationError(TypeError):
|
|
2
|
+
pass
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TypeGuard:
|
|
6
|
+
def __init__(self, label: str = "TypeGuard"):
|
|
7
|
+
self.label = label
|
|
8
|
+
|
|
9
|
+
def __call__(self, func):
|
|
10
|
+
def wrapper(*args, **kwargs):
|
|
11
|
+
print(f"{self.label}: Type checking")
|
|
12
|
+
print(f"Function: {func.__name__}")
|
|
13
|
+
print(f"Type annotations: {func.__annotations__}")
|
|
14
|
+
for k, v in func.__annotations__.items():
|
|
15
|
+
if k in kwargs:
|
|
16
|
+
if not isinstance(kwargs[k], v):
|
|
17
|
+
raise WrongTypeAnnotationError(
|
|
18
|
+
f"Argument '{k}' must be of type {v.__name__}, "
|
|
19
|
+
f"but got {type(kwargs[k]).__name__}"
|
|
20
|
+
)
|
|
21
|
+
result = func(*args, **kwargs)
|
|
22
|
+
return result
|
|
23
|
+
|
|
24
|
+
return wrapper
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: typeguard_gunes
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fonksiyon argümanlarının tiplerini kontrol eden TypeGuard decorator'ı
|
|
5
|
+
Author: Beytullah
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# typeguard_gunes
|
|
10
|
+
|
|
11
|
+
Fonksiyonların keyword argümanlarını type annotation'lara göre kontrol eden bir decorator.
|
|
12
|
+
|
|
13
|
+
## Kurulum
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
pip install typeguard_gunes
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Kullanım
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from typeguard_gunes import TypeGuard, WrongTypeAnnotationError
|
|
23
|
+
|
|
24
|
+
@TypeGuard(label="Custom Type Guard")
|
|
25
|
+
def add(*, x: int, y: int) -> int:
|
|
26
|
+
return x + y
|
|
27
|
+
|
|
28
|
+
add(x=6, y=4) # 10
|
|
29
|
+
add(x=6, y="Canbula") # WrongTypeAnnotationError
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Örneği çalıştırmak için terminalde `typeguard_gunes` ya da `python -m typeguard_gunes` yazman yeterli.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/typeguard_gunes/__init__.py
|
|
4
|
+
src/typeguard_gunes/__main__.py
|
|
5
|
+
src/typeguard_gunes/core.py
|
|
6
|
+
src/typeguard_gunes.egg-info/PKG-INFO
|
|
7
|
+
src/typeguard_gunes.egg-info/SOURCES.txt
|
|
8
|
+
src/typeguard_gunes.egg-info/dependency_links.txt
|
|
9
|
+
src/typeguard_gunes.egg-info/entry_points.txt
|
|
10
|
+
src/typeguard_gunes.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
typeguard_gunes
|