chunkr-ai 0.3.5__tar.gz → 0.3.6__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 (27) hide show
  1. {chunkr_ai-0.3.5/src/chunkr_ai.egg-info → chunkr_ai-0.3.6}/PKG-INFO +1 -1
  2. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/pyproject.toml +1 -1
  3. chunkr_ai-0.3.6/src/chunkr_ai/api/auth.py +22 -0
  4. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6/src/chunkr_ai.egg-info}/PKG-INFO +1 -1
  5. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai.egg-info/SOURCES.txt +2 -1
  6. chunkr_ai-0.3.6/tests/test_version.py +100 -0
  7. chunkr_ai-0.3.5/src/chunkr_ai/api/auth.py +0 -47
  8. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/LICENSE +0 -0
  9. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/README.md +0 -0
  10. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/setup.cfg +0 -0
  11. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/__init__.py +0 -0
  12. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/api/__init__.py +0 -0
  13. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/api/chunkr.py +0 -0
  14. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/api/chunkr_base.py +0 -0
  15. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/api/configuration.py +0 -0
  16. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/api/decorators.py +0 -0
  17. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/api/misc.py +0 -0
  18. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/api/protocol.py +0 -0
  19. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/api/task_response.py +0 -0
  20. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai/models.py +0 -0
  21. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai.egg-info/dependency_links.txt +0 -0
  22. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai.egg-info/requires.txt +0 -0
  23. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/src/chunkr_ai.egg-info/top_level.txt +0 -0
  24. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/tests/test_chunkr.py +0 -0
  25. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/tests/test_excel.py +0 -0
  26. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/tests/test_file_handling.py +0 -0
  27. {chunkr_ai-0.3.5 → chunkr_ai-0.3.6}/tests/test_pages.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chunkr-ai
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: Python client for Chunkr: open source document intelligence
5
5
  Author-email: Ishaan Kapoor <ishaan@lumina.sh>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chunkr-ai"
7
- version = "0.3.5"
7
+ version = "0.3.6"
8
8
  authors = [{ "name" = "Ishaan Kapoor", "email" = "ishaan@lumina.sh" }]
9
9
  description = "Python client for Chunkr: open source document intelligence"
10
10
  readme = "README.md"
@@ -0,0 +1,22 @@
1
+ import platform
2
+ import sys
3
+
4
+ class HeadersMixin:
5
+ """Mixin class for handling authorization headers"""
6
+ _api_key: str = ""
7
+
8
+ def get_api_key(self) -> str:
9
+ """Get the API key"""
10
+ if not hasattr(self, "_api_key") or not self._api_key:
11
+ raise ValueError("API key not set")
12
+ return self._api_key
13
+
14
+ def _headers(self) -> dict:
15
+ """Generate authorization headers and version information"""
16
+ # Import version from the main package to avoid duplication
17
+ from .. import __version__
18
+ user_agent = f"chunkr-ai/{__version__} (Python/{sys.version.split()[0]}; {platform.system()}/{platform.release()})"
19
+ return {
20
+ "Authorization": self.get_api_key(),
21
+ "User-Agent": user_agent
22
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chunkr-ai
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: Python client for Chunkr: open source document intelligence
5
5
  Author-email: Ishaan Kapoor <ishaan@lumina.sh>
6
6
  License: MIT License
@@ -20,4 +20,5 @@ src/chunkr_ai/api/task_response.py
20
20
  tests/test_chunkr.py
21
21
  tests/test_excel.py
22
22
  tests/test_file_handling.py
23
- tests/test_pages.py
23
+ tests/test_pages.py
24
+ tests/test_version.py
@@ -0,0 +1,100 @@
1
+ """
2
+ Test suite for version detection and User-Agent header generation
3
+ """
4
+ import pytest
5
+ import sys
6
+ from pathlib import Path
7
+
8
+
9
+ def test_package_version_import():
10
+ """Test that the package version can be imported correctly"""
11
+ import chunkr_ai
12
+
13
+ # Version should be a string and not "unknown"
14
+ assert isinstance(chunkr_ai.__version__, str)
15
+ assert chunkr_ai.__version__ != "unknown"
16
+ # Version should be a valid semver format
17
+ import re
18
+ assert re.match(r"^\d+\.\d+\.\d+", chunkr_ai.__version__), f"Invalid version format: {chunkr_ai.__version__}"
19
+
20
+
21
+ def test_auth_headers_contain_correct_version():
22
+ """Test that the HeadersMixin generates correct User-Agent with version"""
23
+ import chunkr_ai
24
+ from chunkr_ai.api.auth import HeadersMixin
25
+
26
+ class TestClient(HeadersMixin):
27
+ def __init__(self):
28
+ self._api_key = "test-key"
29
+
30
+ client = TestClient()
31
+ headers = client._headers()
32
+
33
+ # Check headers exist
34
+ assert "User-Agent" in headers
35
+ assert "Authorization" in headers
36
+
37
+ # Check User-Agent format
38
+ user_agent = headers["User-Agent"]
39
+ expected_version = chunkr_ai.__version__
40
+ assert f"chunkr-ai/{expected_version}" in user_agent
41
+ assert "Python/" in user_agent
42
+
43
+ # Verify it's not the wrong version (0.1.0 was the bug)
44
+ assert "chunkr-ai/0.1.0" not in user_agent
45
+
46
+
47
+ def test_version_consistency():
48
+ """Test that all version sources are consistent"""
49
+ import chunkr_ai
50
+ from chunkr_ai.api.auth import HeadersMixin
51
+
52
+ # Get version from main package
53
+ package_version = chunkr_ai.__version__
54
+
55
+ # Get version from auth headers
56
+ class TestClient(HeadersMixin):
57
+ def __init__(self):
58
+ self._api_key = "test-key"
59
+
60
+ client = TestClient()
61
+ headers = client._headers()
62
+ user_agent = headers["User-Agent"]
63
+
64
+ # Extract version from User-Agent
65
+ import re
66
+ version_match = re.search(r"chunkr-ai/(\d+\.\d+\.\d+)", user_agent)
67
+ assert version_match is not None
68
+ auth_version = version_match.group(1)
69
+
70
+ # Versions should match
71
+ assert package_version == auth_version
72
+
73
+
74
+ def test_pyproject_toml_version():
75
+ """Test that pyproject.toml version matches package version"""
76
+ import chunkr_ai
77
+ try:
78
+ import tomllib
79
+ except ImportError:
80
+ import tomli as tomllib
81
+
82
+ # Find pyproject.toml relative to test file
83
+ pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
84
+ assert pyproject_path.exists(), f"pyproject.toml not found at {pyproject_path}"
85
+
86
+ with open(pyproject_path, "rb") as f:
87
+ data = tomllib.load(f)
88
+
89
+ pyproject_version = data["project"]["version"]
90
+ package_version = chunkr_ai.__version__
91
+
92
+ # Both should match and be valid
93
+ assert pyproject_version == package_version
94
+ import re
95
+ assert re.match(r"^\d+\.\d+\.\d+", pyproject_version), f"Invalid version format: {pyproject_version}"
96
+
97
+
98
+ if __name__ == "__main__":
99
+ # Run tests directly if called as script
100
+ pytest.main([__file__, "-v"])
@@ -1,47 +0,0 @@
1
- import platform
2
- import sys
3
- from pathlib import Path
4
-
5
- # Handle tomllib import for Python 3.10 compatibility
6
- try:
7
- import tomllib
8
- except ImportError:
9
- import tomli as tomllib
10
-
11
- def _find_pyproject_toml(start_path: Path) -> Path | None:
12
- """Search for pyproject.toml in current and parent directories."""
13
- for parent in [start_path, *start_path.parents]:
14
- candidate = parent / "pyproject.toml"
15
- if candidate.is_file():
16
- return candidate
17
- return None
18
-
19
- # Read version from pyproject.toml
20
- try:
21
- pyproject_path = _find_pyproject_toml(Path(__file__).resolve().parent)
22
- if pyproject_path is not None:
23
- with open(pyproject_path, "rb") as f:
24
- pyproject_data = tomllib.load(f)
25
- __version__ = pyproject_data["project"]["version"]
26
- else:
27
- __version__ = "unknown"
28
- except Exception:
29
- __version__ = "unknown"
30
-
31
- class HeadersMixin:
32
- """Mixin class for handling authorization headers"""
33
- _api_key: str = ""
34
-
35
- def get_api_key(self) -> str:
36
- """Get the API key"""
37
- if not hasattr(self, "_api_key") or not self._api_key:
38
- raise ValueError("API key not set")
39
- return self._api_key
40
-
41
- def _headers(self) -> dict:
42
- """Generate authorization headers and version information"""
43
- user_agent = f"chunkr-ai/{__version__} (Python/{sys.version.split()[0]}; {platform.system()}/{platform.release()})"
44
- return {
45
- "Authorization": self.get_api_key(),
46
- "User-Agent": user_agent
47
- }
File without changes
File without changes
File without changes
File without changes
File without changes