anyvalue 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.
@@ -0,0 +1,11 @@
1
+ # http://editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ indent_style = space
7
+ indent_size = 4
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+ charset = utf-8
11
+ end_of_line = lf
@@ -0,0 +1,73 @@
1
+ name: Build
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ permissions:
9
+ contents: read
10
+ strategy:
11
+ matrix:
12
+ python_version: ["3.11", "3.12", "3.13", "3.14", "3.14t"]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v5
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v6
18
+ with:
19
+ python-version: ${{ matrix.python_version }}
20
+ - name: Setup Just
21
+ uses: extractions/setup-just@v3
22
+ - name: Install uv and set the Python version
23
+ uses: astral-sh/setup-uv@v7
24
+ with:
25
+ python-version: ${{ matrix.python_version }}
26
+ - name: Install the project
27
+ run: uv sync --all-extras --dev
28
+ - name: Lint and typecheck
29
+ run: |
30
+ just lint-check
31
+ - name: Test
32
+ run: |
33
+ just test-cov-xml
34
+ - uses: codecov/codecov-action@v5
35
+ with:
36
+ token: ${{ secrets.CODECOV_TOKEN }}
37
+ fail_ci_if_error: true
38
+ verbose: true
39
+
40
+ release:
41
+ runs-on: ubuntu-latest
42
+ environment: release
43
+ needs: test
44
+ if: startsWith(github.ref, 'refs/tags/')
45
+ permissions:
46
+ contents: write
47
+ id-token: write
48
+
49
+ steps:
50
+ - uses: actions/checkout@v5
51
+ - name: Set up Python
52
+ uses: actions/setup-python@v6
53
+ with:
54
+ python-version: "3.11"
55
+ - name: Setup Just
56
+ uses: extractions/setup-just@v3
57
+ - name: Install uv and set the Python version
58
+ uses: astral-sh/setup-uv@v7
59
+ with:
60
+ python-version: "3.11"
61
+ - name: Install the project
62
+ run: uv sync --all-extras --dev
63
+ - name: Build and publish on PyPI
64
+ run: |
65
+ uv build
66
+ uv publish
67
+ - name: Create release
68
+ uses: ncipollo/release-action@v1
69
+ with:
70
+ draft: true
71
+ body: ${{ github.event.head_commit.message }}
72
+ artifacts: dist/*.whl,dist/*.tar.gz
73
+ token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,33 @@
1
+ name: "Copilot Setup Steps"
2
+
3
+ # Automatically run the setup steps when they are changed to allow for easy validation, and
4
+ # allow manual testing through the repository's "Actions" tab
5
+ on:
6
+ workflow_dispatch:
7
+ push:
8
+ paths:
9
+ - .github/workflows/copilot-setup-steps.yml
10
+ pull_request:
11
+ paths:
12
+ - .github/workflows/copilot-setup-steps.yml
13
+
14
+ jobs:
15
+ # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
16
+ copilot-setup-steps:
17
+ runs-on: ubuntu-latest
18
+ permissions:
19
+ contents: read
20
+ steps:
21
+ - uses: actions/checkout@v5
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v6
24
+ with:
25
+ python-version: "3.11"
26
+ - name: Setup Just
27
+ uses: extractions/setup-just@v3
28
+ - name: Install uv and set the Python version
29
+ uses: astral-sh/setup-uv@v7
30
+ with:
31
+ python-version: "3.11"
32
+ - name: Install the project
33
+ run: uv sync --all-extras --dev
@@ -0,0 +1,58 @@
1
+ name: Build documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
9
+ permissions:
10
+ contents: read
11
+ pages: write
12
+ id-token: write
13
+
14
+ # Allow one concurrent deployment
15
+ concurrency:
16
+ group: "pages"
17
+ cancel-in-progress: true
18
+
19
+ # Default to bash
20
+ defaults:
21
+ run:
22
+ shell: bash
23
+
24
+ jobs:
25
+ build:
26
+ runs-on: ubuntu-latest
27
+
28
+ steps:
29
+ - uses: actions/checkout@v5
30
+ - name: Set up Python
31
+ uses: actions/setup-python@v6
32
+ with:
33
+ python-version: '3.11'
34
+ - name: Setup Just
35
+ uses: extractions/setup-just@v3
36
+ - name: Install uv and set the Python version
37
+ uses: astral-sh/setup-uv@v7
38
+ with:
39
+ python-version: '3.11'
40
+ - name: Install the project
41
+ run: uv sync --all-extras --dev
42
+ - name: Build
43
+ run: just docs-build
44
+ - name: Upload artifact
45
+ uses: actions/upload-pages-artifact@v4
46
+ with:
47
+ path: ./site
48
+
49
+ deploy:
50
+ environment:
51
+ name: github-pages
52
+ url: ${{ steps.deployment.outputs.page_url }}
53
+ runs-on: ubuntu-latest
54
+ needs: build
55
+ steps:
56
+ - name: Deploy to GitHub Pages
57
+ id: deployment
58
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,111 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ env/
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+
28
+ # PyInstaller
29
+ # Usually these files are written by a python script from a template
30
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ .hypothesis/
48
+ .pytest_cache/
49
+ junit/
50
+ junit.xml
51
+ test.db
52
+
53
+ # Translations
54
+ *.mo
55
+ *.pot
56
+
57
+ # Django stuff:
58
+ *.log
59
+ local_settings.py
60
+
61
+ # Flask stuff:
62
+ instance/
63
+ .webassets-cache
64
+
65
+ # Scrapy stuff:
66
+ .scrapy
67
+
68
+ # Sphinx documentation
69
+ docs/_build/
70
+
71
+ # PyBuilder
72
+ target/
73
+
74
+ # Jupyter Notebook
75
+ .ipynb_checkpoints
76
+
77
+ # pyenv
78
+ .python-version
79
+
80
+ # celery beat schedule file
81
+ celerybeat-schedule
82
+
83
+ # SageMath parsed files
84
+ *.sage.py
85
+
86
+ # dotenv
87
+ .env
88
+
89
+ # virtualenv
90
+ .venv
91
+ venv/
92
+ ENV/
93
+
94
+ # Spyder project settings
95
+ .spyderproject
96
+ .spyproject
97
+
98
+ # Rope project settings
99
+ .ropeproject
100
+
101
+ # mkdocs documentation
102
+ /site
103
+
104
+ # mypy
105
+ .mypy_cache/
106
+
107
+ # ruff
108
+ .ruff_cache/
109
+
110
+ # OS files
111
+ .DS_Store
@@ -0,0 +1,27 @@
1
+ {
2
+ "languages": {
3
+ "Python": {
4
+ "language_servers": ["pyright", "ruff", "!basedpyright", "!pylsp"],
5
+ "format_on_save": "on",
6
+ "wrap_guides": [88],
7
+ "formatter": [
8
+ { "code_action": "source.organizeImports.ruff" },
9
+ { "code_action": "source.fixAll.ruff" },
10
+ {
11
+ "language_server": {
12
+ "name": "ruff",
13
+ },
14
+ },
15
+ ],
16
+ },
17
+ },
18
+ "lsp": {
19
+ "pyright": {
20
+ "settings": {
21
+ "python": {
22
+ "pythonPath": ".venv/bin/python",
23
+ },
24
+ },
25
+ },
26
+ },
27
+ }
anyvalue-0.1.0/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026, François Voron
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: anyvalue
3
+ Version: 0.1.0
4
+ Summary: A better ANY helper for Python testing
5
+ Project-URL: Documentation, https://frankie567.github.io/anyvalue/
6
+ Project-URL: Source, https://github.com/frankie567/anyvalue
7
+ Author-email: anyvalue <hello@fvoron.com>
8
+ License-File: LICENSE
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Python: >=3.11
15
+ Requires-Dist: annotated-types>=0.7.0
16
+ Description-Content-Type: text/markdown
17
+
18
+ # AnyValue
19
+
20
+ <p align="center">
21
+ <em>A better ANY helper for Python testing</em>
22
+ </p>
23
+
24
+ [![build](https://github.com/frankie567/anyvalue/workflows/Build/badge.svg)](https://github.com/frankie567/anyvalue/actions)
25
+ [![codecov](https://codecov.io/gh/frankie567/anyvalue/branch/master/graph/badge.svg)](https://codecov.io/gh/frankie567/anyvalue)
26
+ [![PyPI version](https://badge.fury.io/py/anyvalue.svg)](https://badge.fury.io/py/anyvalue)
27
+
28
+ ---
29
+
30
+ **Documentation**: <a href="https://frankie567.github.io/anyvalue/" target="_blank">https://frankie567.github.io/anyvalue/</a>
31
+
32
+ **Source Code**: <a href="https://github.com/frankie567/anyvalue" target="_blank">https://github.com/frankie567/anyvalue</a>
33
+
34
+ ---
35
+
36
+ ## QuickStart
37
+
38
+ A smarter alternative to `unittest.mock.ANY` that allows type checking and validation constraints.
39
+
40
+ ### Installation
41
+
42
+ ```bash
43
+ pip install anyvalue
44
+ ```
45
+
46
+ ```bash
47
+ uv add anyvalue
48
+ ```
49
+
50
+ ### Basic Usage
51
+
52
+ ```python
53
+ from anyvalue import AnyValue
54
+ from annotated_types import Ge, Le, Len, Predicate
55
+ from datetime import datetime
56
+ from unittest.mock import Mock
57
+
58
+ # Basic type matching
59
+ assert 42 == AnyValue(int)
60
+ assert "hello" == AnyValue(str)
61
+ assert datetime.now() == AnyValue(datetime)
62
+
63
+ # Multiple types with union operator
64
+ assert 42 == AnyValue(int | float)
65
+ assert "test" == AnyValue(str | bytes)
66
+
67
+ # None support
68
+ assert None == AnyValue(None)
69
+ assert None == AnyValue(str | None)
70
+ assert 42 == AnyValue(int | None)
71
+
72
+ # Validation constraints
73
+ assert 42 == AnyValue(int, Ge(0)) # Non-negative integer
74
+ assert "hello" == AnyValue(str, Len(5, 5)) # String of length 5
75
+ assert 99 == AnyValue(int, Ge(0), Le(100)) # Integer between 0 and 100
76
+
77
+ # Predicate validators
78
+ is_even = Predicate(lambda x: x % 2 == 0)
79
+ assert 42 == AnyValue(int, is_even)
80
+
81
+ # Custom callable validators
82
+ def is_palindrome(s: str) -> bool:
83
+ return s == s[::-1]
84
+
85
+ assert "racecar" == AnyValue(str, is_palindrome)
86
+
87
+ # Integration with unittest.mock
88
+ mock_func = Mock()
89
+ mock_func(42, "test", datetime.now())
90
+
91
+ # Verify calls with flexible matching
92
+ mock_func.assert_called_once_with(
93
+ AnyValue(int, Ge(0)),
94
+ AnyValue(str, Len(4, 10)),
95
+ AnyValue(datetime)
96
+ )
97
+ ```
98
+
99
+ ### Key Features
100
+
101
+ - **Type checking**: Accept specific types or union of types
102
+ - **None support**: Explicitly allow or disallow None values
103
+ - **Validation constraints**: Use `annotated-types` for advanced validation (length, ranges, patterns, etc.)
104
+ - **Mock integration**: Works seamlessly with `unittest.mock` for validating call arguments
105
+
106
+ ---
107
+
108
+ ## Development
109
+
110
+ ### Setup environment
111
+
112
+ We use [uv](https://docs.astral.sh/uv/) to manage the development environment and production build, and [just](https://github.com/casey/just) to manage command shortcuts. Ensure they are installed on your system.
113
+
114
+ ### Run unit tests
115
+
116
+ You can run all the tests with:
117
+
118
+ ```bash
119
+ just test
120
+ ```
121
+
122
+ ### Format the code
123
+
124
+ Execute the following command to apply linting and check typing:
125
+
126
+ ```bash
127
+ just lint
128
+ ```
129
+
130
+ ### Publish a new version
131
+
132
+ You can bump the version, create a commit and associated tag with one command:
133
+
134
+ ```bash
135
+ just version patch
136
+ ```
137
+
138
+ ```bash
139
+ just version minor
140
+ ```
141
+
142
+ ```bash
143
+ just version major
144
+ ```
145
+
146
+ Your default Git text editor will open so you can add information about the release.
147
+
148
+ When you push the tag on GitHub, the workflow will automatically publish it on PyPi and a GitHub release will be created as draft.
149
+
150
+ ## Serve the documentation
151
+
152
+ You can serve the Mkdocs documentation with:
153
+
154
+ ```bash
155
+ just docs-serve
156
+ ```
157
+
158
+ It'll automatically watch for changes in your code.
159
+
160
+ ## License
161
+
162
+ This project is licensed under the terms of the MIT license.
@@ -0,0 +1,145 @@
1
+ # AnyValue
2
+
3
+ <p align="center">
4
+ <em>A better ANY helper for Python testing</em>
5
+ </p>
6
+
7
+ [![build](https://github.com/frankie567/anyvalue/workflows/Build/badge.svg)](https://github.com/frankie567/anyvalue/actions)
8
+ [![codecov](https://codecov.io/gh/frankie567/anyvalue/branch/master/graph/badge.svg)](https://codecov.io/gh/frankie567/anyvalue)
9
+ [![PyPI version](https://badge.fury.io/py/anyvalue.svg)](https://badge.fury.io/py/anyvalue)
10
+
11
+ ---
12
+
13
+ **Documentation**: <a href="https://frankie567.github.io/anyvalue/" target="_blank">https://frankie567.github.io/anyvalue/</a>
14
+
15
+ **Source Code**: <a href="https://github.com/frankie567/anyvalue" target="_blank">https://github.com/frankie567/anyvalue</a>
16
+
17
+ ---
18
+
19
+ ## QuickStart
20
+
21
+ A smarter alternative to `unittest.mock.ANY` that allows type checking and validation constraints.
22
+
23
+ ### Installation
24
+
25
+ ```bash
26
+ pip install anyvalue
27
+ ```
28
+
29
+ ```bash
30
+ uv add anyvalue
31
+ ```
32
+
33
+ ### Basic Usage
34
+
35
+ ```python
36
+ from anyvalue import AnyValue
37
+ from annotated_types import Ge, Le, Len, Predicate
38
+ from datetime import datetime
39
+ from unittest.mock import Mock
40
+
41
+ # Basic type matching
42
+ assert 42 == AnyValue(int)
43
+ assert "hello" == AnyValue(str)
44
+ assert datetime.now() == AnyValue(datetime)
45
+
46
+ # Multiple types with union operator
47
+ assert 42 == AnyValue(int | float)
48
+ assert "test" == AnyValue(str | bytes)
49
+
50
+ # None support
51
+ assert None == AnyValue(None)
52
+ assert None == AnyValue(str | None)
53
+ assert 42 == AnyValue(int | None)
54
+
55
+ # Validation constraints
56
+ assert 42 == AnyValue(int, Ge(0)) # Non-negative integer
57
+ assert "hello" == AnyValue(str, Len(5, 5)) # String of length 5
58
+ assert 99 == AnyValue(int, Ge(0), Le(100)) # Integer between 0 and 100
59
+
60
+ # Predicate validators
61
+ is_even = Predicate(lambda x: x % 2 == 0)
62
+ assert 42 == AnyValue(int, is_even)
63
+
64
+ # Custom callable validators
65
+ def is_palindrome(s: str) -> bool:
66
+ return s == s[::-1]
67
+
68
+ assert "racecar" == AnyValue(str, is_palindrome)
69
+
70
+ # Integration with unittest.mock
71
+ mock_func = Mock()
72
+ mock_func(42, "test", datetime.now())
73
+
74
+ # Verify calls with flexible matching
75
+ mock_func.assert_called_once_with(
76
+ AnyValue(int, Ge(0)),
77
+ AnyValue(str, Len(4, 10)),
78
+ AnyValue(datetime)
79
+ )
80
+ ```
81
+
82
+ ### Key Features
83
+
84
+ - **Type checking**: Accept specific types or union of types
85
+ - **None support**: Explicitly allow or disallow None values
86
+ - **Validation constraints**: Use `annotated-types` for advanced validation (length, ranges, patterns, etc.)
87
+ - **Mock integration**: Works seamlessly with `unittest.mock` for validating call arguments
88
+
89
+ ---
90
+
91
+ ## Development
92
+
93
+ ### Setup environment
94
+
95
+ We use [uv](https://docs.astral.sh/uv/) to manage the development environment and production build, and [just](https://github.com/casey/just) to manage command shortcuts. Ensure they are installed on your system.
96
+
97
+ ### Run unit tests
98
+
99
+ You can run all the tests with:
100
+
101
+ ```bash
102
+ just test
103
+ ```
104
+
105
+ ### Format the code
106
+
107
+ Execute the following command to apply linting and check typing:
108
+
109
+ ```bash
110
+ just lint
111
+ ```
112
+
113
+ ### Publish a new version
114
+
115
+ You can bump the version, create a commit and associated tag with one command:
116
+
117
+ ```bash
118
+ just version patch
119
+ ```
120
+
121
+ ```bash
122
+ just version minor
123
+ ```
124
+
125
+ ```bash
126
+ just version major
127
+ ```
128
+
129
+ Your default Git text editor will open so you can add information about the release.
130
+
131
+ When you push the tag on GitHub, the workflow will automatically publish it on PyPi and a GitHub release will be created as draft.
132
+
133
+ ## Serve the documentation
134
+
135
+ You can serve the Mkdocs documentation with:
136
+
137
+ ```bash
138
+ just docs-serve
139
+ ```
140
+
141
+ It'll automatically watch for changes in your code.
142
+
143
+ ## License
144
+
145
+ This project is licensed under the terms of the MIT license.