sweet_tea 0.1.19__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.
Files changed (43) hide show
  1. sweet_tea-0.1.19/.github/workflows/ci.yml +260 -0
  2. sweet_tea-0.1.19/.gitignore +209 -0
  3. sweet_tea-0.1.19/.pre-commit-config.yaml +56 -0
  4. sweet_tea-0.1.19/LICENSE +201 -0
  5. sweet_tea-0.1.19/PKG-INFO +189 -0
  6. sweet_tea-0.1.19/PUBLISHING.md +99 -0
  7. sweet_tea-0.1.19/README.md +159 -0
  8. sweet_tea-0.1.19/docs/api/abstract-factory.md +9 -0
  9. sweet_tea-0.1.19/docs/api/entry.md +3 -0
  10. sweet_tea-0.1.19/docs/api/factory.md +9 -0
  11. sweet_tea-0.1.19/docs/api/registry.md +21 -0
  12. sweet_tea-0.1.19/docs/api/singleton-factory.md +33 -0
  13. sweet_tea-0.1.19/docs/development/contributing.md +83 -0
  14. sweet_tea-0.1.19/docs/development/testing.md +131 -0
  15. sweet_tea-0.1.19/docs/index.md +56 -0
  16. sweet_tea-0.1.19/docs/user-guide/advanced-features.md +116 -0
  17. sweet_tea-0.1.19/docs/user-guide/basic-usage.md +124 -0
  18. sweet_tea-0.1.19/docs/user-guide/getting-started.md +114 -0
  19. sweet_tea-0.1.19/mkdocs.yml +77 -0
  20. sweet_tea-0.1.19/pyproject.toml +55 -0
  21. sweet_tea-0.1.19/sweet_tea/__init__.py +13 -0
  22. sweet_tea-0.1.19/sweet_tea/abstract_factory.py +85 -0
  23. sweet_tea-0.1.19/sweet_tea/entry.py +48 -0
  24. sweet_tea-0.1.19/sweet_tea/factory.py +189 -0
  25. sweet_tea-0.1.19/sweet_tea/registry.py +225 -0
  26. sweet_tea-0.1.19/sweet_tea/singleton_factory.py +173 -0
  27. sweet_tea-0.1.19/sweet_tea/sweet_tea_error.py +40 -0
  28. sweet_tea-0.1.19/sweet_tea/sweet_tea_warning.py +6 -0
  29. sweet_tea-0.1.19/tests/__init__.py +0 -0
  30. sweet_tea-0.1.19/tests/classes_for_testing/__init__.py +16 -0
  31. sweet_tea-0.1.19/tests/classes_for_testing/asdf/__init__.py +13 -0
  32. sweet_tea-0.1.19/tests/classes_for_testing/asdf/a.py +16 -0
  33. sweet_tea-0.1.19/tests/classes_for_testing/asdf/b.py +18 -0
  34. sweet_tea-0.1.19/tests/classes_for_testing/optional_dep.py +6 -0
  35. sweet_tea-0.1.19/tests/classes_for_testing/stuff/__init__.py +13 -0
  36. sweet_tea-0.1.19/tests/classes_for_testing/stuff/c.py +19 -0
  37. sweet_tea-0.1.19/tests/test_abstract_factory.py +218 -0
  38. sweet_tea-0.1.19/tests/test_entry.py +73 -0
  39. sweet_tea-0.1.19/tests/test_factory.py +205 -0
  40. sweet_tea-0.1.19/tests/test_registry.py +168 -0
  41. sweet_tea-0.1.19/tests/test_singleton_factory.py +236 -0
  42. sweet_tea-0.1.19/tests/test_sweet_tea_error.py +57 -0
  43. sweet_tea-0.1.19/tests/test_sweet_tea_warning.py +73 -0
@@ -0,0 +1,260 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ release:
9
+ types: [published]
10
+
11
+ jobs:
12
+ # Individual lint jobs - must all pass before unit tests run
13
+ lint-black:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v4
18
+ with:
19
+ python-version: "3.12"
20
+ - name: Install Black
21
+ run: pip install black
22
+ - name: Run Black
23
+ run: black --check --diff .
24
+
25
+ lint-isort:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: actions/setup-python@v4
30
+ with:
31
+ python-version: "3.12"
32
+ - name: Install isort
33
+ run: pip install isort
34
+ - name: Run isort
35
+ run: isort --check-only --diff .
36
+
37
+ lint-ruff:
38
+ runs-on: ubuntu-latest
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+ - uses: actions/setup-python@v4
42
+ with:
43
+ python-version: "3.12"
44
+ - name: Install Ruff
45
+ run: pip install ruff
46
+ - name: Run Ruff
47
+ run: ruff check .
48
+
49
+ lint-bandit:
50
+ runs-on: ubuntu-latest
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+ - uses: actions/setup-python@v4
54
+ with:
55
+ python-version: "3.12"
56
+ - name: Install Bandit
57
+ run: pip install bandit[toml]
58
+ - name: Run Bandit
59
+ run: bandit -r sweet_tea
60
+
61
+ lint-mypy:
62
+ runs-on: ubuntu-latest
63
+ steps:
64
+ - uses: actions/checkout@v4
65
+ - uses: actions/setup-python@v4
66
+ with:
67
+ python-version: "3.12"
68
+ - name: Install MyPy and dependencies
69
+ run: |
70
+ pip install mypy
71
+ pip install pydantic
72
+ - name: Run MyPy
73
+ run: mypy sweet_tea
74
+
75
+ lint-mkdocs:
76
+ runs-on: ubuntu-latest
77
+ steps:
78
+ - uses: actions/checkout@v4
79
+ - uses: actions/setup-python@v4
80
+ with:
81
+ python-version: "3.12"
82
+ - name: Install MkDocs and sweet_tea package
83
+ run: |
84
+ pip install mkdocs mkdocs-material mkdocstrings[python]
85
+ pip install -e .
86
+ - name: Build MkDocs
87
+ run: mkdocs build --strict
88
+
89
+ # Unit tests - only run after all lint jobs pass
90
+ test:
91
+ runs-on: ubuntu-latest
92
+ needs: [lint-black, lint-isort, lint-ruff, lint-bandit, lint-mypy, lint-mkdocs]
93
+ strategy:
94
+ matrix:
95
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
96
+
97
+ steps:
98
+ - uses: actions/checkout@v4
99
+
100
+ - name: Install uv
101
+ uses: astral-sh/setup-uv@v3
102
+ with:
103
+ enable-cache: true
104
+ cache-dependency-glob: "pyproject.toml"
105
+
106
+ - name: Set up Python ${{ matrix.python-version }}
107
+ run: uv python install ${{ matrix.python-version }}
108
+
109
+ - name: Install dependencies
110
+ run: uv sync --dev
111
+
112
+ - name: Run unit tests with coverage
113
+ run: uv run pytest tests/ --cov=sweet_tea --cov-report=xml --cov-report=term-missing
114
+
115
+ - name: Upload coverage to Codecov
116
+ if: matrix.python-version == '3.12'
117
+ uses: codecov/codecov-action@v4
118
+ with:
119
+ file: ./coverage.xml
120
+ flags: unittests
121
+ name: codecov-umbrella
122
+ fail_ci_if_error: false
123
+
124
+ build-and-test-package:
125
+ runs-on: ubuntu-latest
126
+ needs: test
127
+ if: github.ref == 'refs/heads/main'
128
+
129
+ steps:
130
+ - uses: actions/checkout@v4
131
+
132
+ - name: Install uv
133
+ uses: astral-sh/setup-uv@v3
134
+ with:
135
+ enable-cache: true
136
+ cache-dependency-glob: "pyproject.toml"
137
+
138
+ - name: Set up Python 3.12
139
+ run: uv python install 3.12
140
+
141
+ - name: Install build dependencies
142
+ run: uv sync --dev
143
+
144
+ - name: Build package
145
+ run: uv build
146
+
147
+ - name: Test package installation
148
+ run: |
149
+ # Create a temporary directory for isolated testing
150
+ mkdir -p /tmp/package_test
151
+ cd /tmp/package_test
152
+
153
+ # Create isolated virtual environment with uv
154
+ uv venv test_env
155
+
156
+ # Install the built package in the isolated environment
157
+ uv pip install --python test_env $GITHUB_WORKSPACE/dist/*.whl
158
+
159
+ # Test import and functionality in the isolated environment
160
+ uv run --python test_env python -c "import sweet_tea; print('Package installed successfully!')"
161
+
162
+ uv run --python test_env python -c "
163
+ from sweet_tea.registry import Registry
164
+ from sweet_tea.factory import Factory
165
+ from sweet_tea.singleton_factory import SingletonFactory
166
+ class TestClass:
167
+ def __init__(self, value='test'): self.value = value
168
+ Registry.register('test', TestClass)
169
+ instance = Factory.create('test')
170
+ print(f'Factory works: {instance.value}')
171
+ SingletonFactory.register('singleton', TestClass('singleton'))
172
+ singleton = SingletonFactory.get('singleton')
173
+ print(f'Singleton works: {singleton.value}')
174
+ "
175
+
176
+ publish-to-testpypi:
177
+ runs-on: ubuntu-latest
178
+ needs: [test, build-and-test-package]
179
+ if: github.ref == 'refs/heads/main'
180
+ outputs:
181
+ version: ${{ steps.version.outputs.version }}
182
+
183
+ env:
184
+ MAJOR_VERSION: 0
185
+ MINOR_VERSION: 1
186
+
187
+ steps:
188
+ - uses: actions/checkout@v4
189
+
190
+ - name: Install uv
191
+ uses: astral-sh/setup-uv@v3
192
+ with:
193
+ enable-cache: true
194
+ cache-dependency-glob: "pyproject.toml"
195
+
196
+ - name: Set up Python 3.12
197
+ run: uv python install 3.12
198
+
199
+ - name: Install build dependencies
200
+ run: uv sync --dev
201
+
202
+ - name: Set semantic version for TestPyPI
203
+ id: version
204
+ run: |
205
+ # Use configured major.minor and run number as patch
206
+ SEMANTIC_VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${GITHUB_RUN_NUMBER}"
207
+ ORIGINAL_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
208
+ sed -i "s/version = \"$ORIGINAL_VERSION\"/version = \"$SEMANTIC_VERSION\"/" pyproject.toml
209
+ echo "Building TestPyPI version: $SEMANTIC_VERSION (major: $MAJOR_VERSION, minor: $MINOR_VERSION, patch: $GITHUB_RUN_NUMBER)"
210
+ echo "version=$SEMANTIC_VERSION" >> $GITHUB_OUTPUT
211
+
212
+ - name: Build package
213
+ run: uv build
214
+
215
+ - name: Publish to TestPyPI
216
+ if: env.TEST_PYPI_API_TOKEN != ''
217
+ env:
218
+ TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
219
+ run: |
220
+ echo "Publishing to TestPyPI for testing..."
221
+ uv publish --token $TEST_PYPI_API_TOKEN dist/*.whl dist/*.tar.gz --publish-url https://test.pypi.org/legacy/
222
+
223
+ publish:
224
+ runs-on: ubuntu-latest
225
+ needs: [test, build-and-test-package, publish-to-testpypi]
226
+ if: github.ref == 'refs/heads/main'
227
+
228
+ steps:
229
+ - uses: actions/checkout@v4
230
+
231
+ - name: Install uv
232
+ uses: astral-sh/setup-uv@v3
233
+ with:
234
+ enable-cache: true
235
+ cache-dependency-glob: "pyproject.toml"
236
+
237
+ - name: Set up Python 3.12
238
+ run: uv python install 3.12
239
+
240
+ - name: Install build dependencies
241
+ run: uv sync --dev
242
+
243
+ - name: Use same version as TestPyPI
244
+ run: |
245
+ # Get the version that was used for TestPyPI
246
+ TESTPYPI_VERSION="${{ needs.publish-to-testpypi.outputs.version }}"
247
+ ORIGINAL_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
248
+ sed -i "s/version = \"$ORIGINAL_VERSION\"/version = \"$TESTPYPI_VERSION\"/" pyproject.toml
249
+ echo "Building PyPI version: $TESTPYPI_VERSION (same as TestPyPI)"
250
+
251
+ - name: Build package
252
+ run: uv build
253
+
254
+ - name: Publish to PyPI
255
+ if: env.PYPI_API_KEY != ''
256
+ env:
257
+ PYPI_API_KEY: ${{ secrets.PYPI_API_KEY }}
258
+ run: |
259
+ echo "Publishing to PyPI..."
260
+ uv publish --token $PYPI_API_KEY
@@ -0,0 +1,209 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by asdf python script from asdf template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For asdf library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates asdf virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ .idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in asdf separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ token
@@ -0,0 +1,56 @@
1
+ repos:
2
+ # Code formatting
3
+ - repo: https://github.com/psf/black
4
+ rev: 25.1.0
5
+ hooks:
6
+ - id: black
7
+ language_version: python3
8
+
9
+ # Import sorting (compatible with black)
10
+ - repo: https://github.com/pycqa/isort
11
+ rev: 6.0.0
12
+ hooks:
13
+ - id: isort
14
+ args: ["--profile", "black", "--check-only", "--diff"]
15
+
16
+ # Fast linter
17
+ - repo: https://github.com/astral-sh/ruff-pre-commit
18
+ rev: v0.14.10
19
+ hooks:
20
+ - id: ruff
21
+ args: [--fix]
22
+ - id: ruff-format
23
+
24
+ # Security scanning
25
+ - repo: https://github.com/pycqa/bandit
26
+ rev: 1.9.2
27
+ hooks:
28
+ - id: bandit
29
+ args: ["-c", "pyproject.toml"]
30
+ exclude: ^tests/
31
+
32
+ # Type checking
33
+ - repo: https://github.com/pre-commit/mirrors-mypy
34
+ rev: v1.19.1
35
+ hooks:
36
+ - id: mypy
37
+ args: [--ignore-missing-imports]
38
+
39
+ # Build documentation
40
+ - repo: local
41
+ hooks:
42
+ - id: mkdocs
43
+ name: mkdocs
44
+ entry: uv run mkdocs build
45
+ language: system
46
+ pass_filenames: false
47
+
48
+ # Run tests
49
+ - repo: local
50
+ hooks:
51
+ - id: pytest
52
+ name: pytest
53
+ entry: uv run pytest
54
+ language: system
55
+ pass_filenames: false
56
+ args: [tests/, --cov=sweet_tea, --cov-report=term-missing]