decorators-learn 0.0.2__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,37 @@
1
+ Metadata-Version: 2.3
2
+ Name: decorators-learn
3
+ Version: 0.0.2
4
+ Summary: A project to learn decorators
5
+ Author: Rohit Gupta
6
+ Author-email: Rohit Gupta <gupta.rohit21198@gmail.com>
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Classifier: Programming Language :: Python :: 3.14
11
+ Requires-Dist: opentelemetry-exporter-otlp>=1.39.1
12
+ Requires-Dist: opentelemetry-sdk>=1.39.1
13
+ Requires-Dist: pydantic-settings>=2.12.0
14
+ Requires-Dist: python-json-logger>=4.0.0
15
+ Requires-Dist: python-logging-loki-v2>=1.1.1
16
+ Requires-Dist: pyyaml>=6.0.3
17
+ Requires-Dist: rich>=14.3.2
18
+ Requires-Python: >=3.12.8
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Decorators Learn
22
+
23
+ [![pr-checks](https://github.com/rohit1998/decorators-learn/actions/workflows/pr-checks.yml/badge.svg?branch=main)](https://github.com/rohit1998/decorators-learn/actions/workflows/pr-checks.yml)
24
+ [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://rohit1998.github.io/decorators-learn/)
25
+ [![PyPI version](https://img.shields.io/pypi/v/decorators-learn.svg?color=blue)](https://pypi.org/project/decorators-learn/)
26
+ [![Python versions](https://img.shields.io/pypi/pyversions/decorators-learn.svg?color=blue)](https://pypi.org/project/decorators-learn/)
27
+ [![Docker Image](https://img.shields.io/docker/v/rohgupt/decorators-learn?label=latest)](https://hub.docker.com/r/rohgupt/decorators-learn/)
28
+
29
+ A project to learn decorators. Checkout
30
+
31
+ - [local_docs_link](https://decorators-learn.dev.local)
32
+ - [tailscale_docs_link](https://decorators-learn.tailb437ea.ts.net)
33
+ - [repo_docs_path](docs/index.md)
34
+
35
+ ## License
36
+
37
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,17 @@
1
+ # Decorators Learn
2
+
3
+ [![pr-checks](https://github.com/rohit1998/decorators-learn/actions/workflows/pr-checks.yml/badge.svg?branch=main)](https://github.com/rohit1998/decorators-learn/actions/workflows/pr-checks.yml)
4
+ [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://rohit1998.github.io/decorators-learn/)
5
+ [![PyPI version](https://img.shields.io/pypi/v/decorators-learn.svg?color=blue)](https://pypi.org/project/decorators-learn/)
6
+ [![Python versions](https://img.shields.io/pypi/pyversions/decorators-learn.svg?color=blue)](https://pypi.org/project/decorators-learn/)
7
+ [![Docker Image](https://img.shields.io/docker/v/rohgupt/decorators-learn?label=latest)](https://hub.docker.com/r/rohgupt/decorators-learn/)
8
+
9
+ A project to learn decorators. Checkout
10
+
11
+ - [local_docs_link](https://decorators-learn.dev.local)
12
+ - [tailscale_docs_link](https://decorators-learn.tailb437ea.ts.net)
13
+ - [repo_docs_path](docs/index.md)
14
+
15
+ ## License
16
+
17
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,122 @@
1
+ [project]
2
+ name = "decorators-learn"
3
+ version = "0.0.2"
4
+ description = "A project to learn decorators"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Rohit Gupta", email = "gupta.rohit21198@gmail.com" }
8
+ ]
9
+ classifiers = [
10
+ "License :: OSI Approved :: MIT License",
11
+ "Programming Language :: Python :: 3.12",
12
+ "Programming Language :: Python :: 3.13",
13
+ "Programming Language :: Python :: 3.14",
14
+ ]
15
+ requires-python = ">=3.12.8"
16
+ dependencies = [
17
+ "opentelemetry-exporter-otlp>=1.39.1",
18
+ "opentelemetry-sdk>=1.39.1",
19
+ "pydantic-settings>=2.12.0",
20
+ "python-json-logger>=4.0.0",
21
+ "python-logging-loki-v2>=1.1.1",
22
+ "pyyaml>=6.0.3",
23
+ "rich>=14.3.2",
24
+ ]
25
+
26
+ [project.scripts]
27
+ cli = "cli.main:main"
28
+
29
+ [build-system]
30
+ requires = ["uv_build"]
31
+ build-backend = "uv_build"
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ "pytest-cov>=7.0.0",
36
+ "pytest>=9.0.2",
37
+ "ruff>=0.14.14",
38
+ "pyright>=1.1.408",
39
+ "ty>=0.0.14",
40
+ "rumdl>=0.1.12",
41
+ ]
42
+ docs = [
43
+ "mkdocs>=1.6.1",
44
+ "mkdocs-material>=9.7.1",
45
+ "mkdocstrings>=1.0.2",
46
+ "mkdocstrings-python>=2.0.1",
47
+ "mkdocs-gen-files>=0.6.0",
48
+ "mkdocs-literate-nav>=0.6.2",
49
+ "mkdocs-section-index>=0.3.10",
50
+ "mkdocs-mermaid2-plugin>=1.2.3",
51
+ "mdx-truly-sane-lists>=1.3",
52
+ ]
53
+ notebooks = [
54
+ "marimo>=0.19.7",
55
+ "pandas>=3.0.0",
56
+ "pyarrow>=23.0.0",
57
+ ]
58
+
59
+ [tool.ruff]
60
+ line-length = 79
61
+ show-fixes = true
62
+ unsafe-fixes = true
63
+ exclude = ["scratchpad", "notebooks"]
64
+
65
+ [tool.ruff.lint]
66
+ select = ["ALL"]
67
+ ignore = [
68
+ "COM812", # redundant, ruff enforces consistent use of trailing commas
69
+ ]
70
+
71
+ [tool.ruff.format]
72
+ docstring-code-format = true
73
+ quote-style = "single"
74
+ [tool.ruff.lint.flake8-quotes]
75
+ inline-quotes = "single"
76
+
77
+ [tool.ruff.lint.pycodestyle]
78
+ max-doc-length = 79
79
+
80
+ [tool.ruff.lint.pydocstyle]
81
+ convention = "google"
82
+
83
+ [tool.ruff.lint.extend-per-file-ignores]
84
+ "tests/**/*.py" = [
85
+ "S101", # asserts allowed in tests
86
+ "ARG", # unused function args in tests
87
+ "FBT", # booleans as positional arguments in tests
88
+ ]
89
+
90
+ [tool.pytest.ini_options]
91
+ addopts = [
92
+ "--cov=src",
93
+ "--cov-report=html",
94
+ "--cov-fail-under=100",
95
+ "--durations=0",
96
+ "--durations-min=0.5",
97
+ "--doctest-modules",
98
+ ]
99
+ norecursedirs = ["scratchpad", "notebooks", "tools"]
100
+
101
+ [tool.coverage.run]
102
+ data_file = ".coverage_data/.coverage"
103
+ omit = []
104
+
105
+ [tool.pyright]
106
+ venvPath = "."
107
+ venv = ".venv"
108
+ ignore = ["scratchpad", "notebooks", "tools"]
109
+
110
+ [tool.ty.src]
111
+ exclude = ["scratchpad", "notebooks", "tools"]
112
+
113
+ [tool.rumdl]
114
+ disable = ["MD013"]
115
+ exclude = [
116
+ ".opencode/skills/*/assets/*.md",
117
+ ".opencode/tmp/*.md",
118
+ ]
119
+
120
+ [tool.rumdl.per-file-ignores]
121
+ "docs/index.md" = ["MD057"]
122
+ "docs/tutorials/intro.md" = ["MD033"]
@@ -0,0 +1,11 @@
1
+ """My Project."""
2
+
3
+ from .module import (
4
+ MyClass,
5
+ my_add_function,
6
+ )
7
+
8
+ __all__ = [
9
+ 'MyClass',
10
+ 'my_add_function',
11
+ ]
@@ -0,0 +1,98 @@
1
+ """Sample module."""
2
+
3
+ import logging
4
+
5
+ from opentelemetry import trace
6
+
7
+ from cli.tracing_setup import trace_function
8
+
9
+ logger = logging.getLogger(__name__)
10
+ tracer = trace.get_tracer(__name__)
11
+
12
+
13
+ class MyClass:
14
+ """My module."""
15
+
16
+ def __init__(self, name: str) -> None:
17
+ """Initialize the module.
18
+
19
+ Args:
20
+ name: The name of the person to greet.
21
+ """
22
+ self.name = name
23
+
24
+ @trace_function
25
+ def run(self) -> str:
26
+ """Run the module.
27
+
28
+ Returns:
29
+ The greeting.
30
+ """
31
+ logger.debug('Running module')
32
+ greeting = f'Hello {self.name}'
33
+ logger.debug('Ran module')
34
+ return greeting
35
+
36
+ def get_env_var(self, env_var_name: str) -> str:
37
+ """Get the environment variable.
38
+
39
+ Args:
40
+ env_var_name (str): The name of the environment variable.
41
+
42
+ Returns:
43
+ The environment variable.
44
+
45
+ Raises:
46
+ ValueError: If the environment variable is not found.
47
+ """
48
+ logger.debug('Getting environment variable')
49
+ if env_var_name is None:
50
+ logger.error('Environment variable not found')
51
+ msg = 'Environment variable not found'
52
+ raise ValueError(msg)
53
+ logger.debug('Got environment variable')
54
+ return env_var_name + '_verified'
55
+
56
+
57
+ @trace_function
58
+ def my_add_function(a: int, b: int) -> int:
59
+ """My add function.
60
+
61
+ Generic function to
62
+
63
+ - add two numbers `a` and `b`
64
+ - both a and b must be integers
65
+
66
+ Args:
67
+ a (int): The first number to add.
68
+ b (int): The second number to add.
69
+
70
+ Returns:
71
+ int: The sum of `a` and `b`.
72
+
73
+ Raises:
74
+ TypeError: If the `a` or `b` is not an integer.
75
+
76
+ Examples:
77
+ >>> from decorators_learn import my_add_function
78
+ >>> my_add_function(2, 3)
79
+ 5
80
+ >>> my_add_function(2, '3')
81
+ Traceback (most recent call last):
82
+ ...
83
+ TypeError: Both a and b must be integers
84
+
85
+ Warning:
86
+ - No support for floats.
87
+ """
88
+ if not isinstance(a, int) or not isinstance(b, int):
89
+ logger.error('Both a and b must be integers')
90
+ msg = 'Both a and b must be integers'
91
+ raise TypeError(msg)
92
+
93
+ logger.debug('Running my add function')
94
+ with tracer.start_as_current_span('perform-addition'):
95
+ logger.debug('Adding %s and %s', a, b)
96
+ result = a + b
97
+ logger.debug('%s + %s = %s', a, b, result)
98
+ return result