uw-api 0.2.0__tar.gz → 0.2.1__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 (36) hide show
  1. uw_api-0.2.1/.github/ISSUE_TEMPLATE/bug_report.yml +62 -0
  2. uw_api-0.2.1/.github/ISSUE_TEMPLATE/config.yml +5 -0
  3. uw_api-0.2.1/.github/ISSUE_TEMPLATE/feature_request.yml +34 -0
  4. {uw_api-0.2.0 → uw_api-0.2.1}/.github/workflows/ci.yml +2 -2
  5. uw_api-0.2.1/.release-please-manifest.json +3 -0
  6. {uw_api-0.2.0 → uw_api-0.2.1}/CHANGELOG.md +8 -0
  7. uw_api-0.2.1/LICENSE +21 -0
  8. {uw_api-0.2.0 → uw_api-0.2.1}/PKG-INFO +2 -1
  9. {uw_api-0.2.0 → uw_api-0.2.1}/pyproject.toml +1 -1
  10. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/__init__.py +1 -1
  11. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/client.py +42 -18
  12. {uw_api-0.2.0 → uw_api-0.2.1}/tests/test_client.py +4 -2
  13. uw_api-0.2.0/.release-please-manifest.json +0 -3
  14. {uw_api-0.2.0 → uw_api-0.2.1}/.github/CODEOWNERS +0 -0
  15. {uw_api-0.2.0 → uw_api-0.2.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  16. {uw_api-0.2.0 → uw_api-0.2.1}/.github/dependabot.yml +0 -0
  17. {uw_api-0.2.0 → uw_api-0.2.1}/.github/workflows/release-please.yml +0 -0
  18. {uw_api-0.2.0 → uw_api-0.2.1}/.gitignore +0 -0
  19. {uw_api-0.2.0 → uw_api-0.2.1}/README.md +0 -0
  20. {uw_api-0.2.0 → uw_api-0.2.1}/release-please-config.json +0 -0
  21. {uw_api-0.2.0 → uw_api-0.2.1}/scripts/discover_api.py +0 -0
  22. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/auth.py +0 -0
  23. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/exceptions.py +0 -0
  24. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/graphql/__init__.py +0 -0
  25. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/graphql/queries.py +0 -0
  26. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/models/__init__.py +0 -0
  27. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/models/account.py +0 -0
  28. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/models/bill.py +0 -0
  29. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/models/energy.py +0 -0
  30. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/models/meter.py +0 -0
  31. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/pdf/__init__.py +0 -0
  32. {uw_api-0.2.0 → uw_api-0.2.1}/src/uw_api/pdf/extractor.py +0 -0
  33. {uw_api-0.2.0 → uw_api-0.2.1}/tests/__init__.py +0 -0
  34. {uw_api-0.2.0 → uw_api-0.2.1}/tests/conftest.py +0 -0
  35. {uw_api-0.2.0 → uw_api-0.2.1}/tests/test_bills.py +0 -0
  36. {uw_api-0.2.0 → uw_api-0.2.1}/tests/test_models.py +0 -0
@@ -0,0 +1,62 @@
1
+ name: Bug report
2
+ description: Report a problem with the uw-api Python library.
3
+ labels: ["bug"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for taking the time to report a bug.
9
+ - type: input
10
+ id: version
11
+ attributes:
12
+ label: Library version
13
+ description: Which version of uw-api are you using?
14
+ placeholder: e.g. 0.2.0
15
+ validations:
16
+ required: true
17
+ - type: input
18
+ id: python_version
19
+ attributes:
20
+ label: Python version
21
+ description: Which Python version are you running?
22
+ placeholder: e.g. 3.13
23
+ validations:
24
+ required: true
25
+ - type: textarea
26
+ id: description
27
+ attributes:
28
+ label: Describe the bug
29
+ description: A clear and concise description of what the bug is.
30
+ validations:
31
+ required: true
32
+ - type: textarea
33
+ id: reproduce
34
+ attributes:
35
+ label: Minimal reproduction
36
+ description: A code snippet that reproduces the issue.
37
+ render: python
38
+ validations:
39
+ required: true
40
+ - type: textarea
41
+ id: expected
42
+ attributes:
43
+ label: Expected behaviour
44
+ description: What did you expect to happen instead?
45
+ validations:
46
+ required: false
47
+ - type: textarea
48
+ id: logs
49
+ attributes:
50
+ label: Traceback or error output
51
+ description: |
52
+ Paste the full traceback. **Redact your credentials before posting.**
53
+ render: text
54
+ validations:
55
+ required: false
56
+ - type: textarea
57
+ id: additional
58
+ attributes:
59
+ label: Additional context
60
+ description: Anything else that might help.
61
+ validations:
62
+ required: false
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Questions & discussions
4
+ url: https://github.com/KRoperUK/uw-py/discussions
5
+ about: Ask questions about the library here.
@@ -0,0 +1,34 @@
1
+ name: Feature request
2
+ description: Suggest an idea for the uw-api library.
3
+ labels: ["enhancement"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for sharing your idea.
9
+ - type: textarea
10
+ id: problem
11
+ attributes:
12
+ label: Is your feature request related to a problem?
13
+ description: A clear and concise description of what the problem is.
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ id: solution
18
+ attributes:
19
+ label: Describe the solution you'd like
20
+ description: What should happen?
21
+ validations:
22
+ required: true
23
+ - type: textarea
24
+ id: alternatives
25
+ attributes:
26
+ label: Describe alternatives you've considered
27
+ validations:
28
+ required: false
29
+ - type: textarea
30
+ id: additional
31
+ attributes:
32
+ label: Additional context
33
+ validations:
34
+ required: false
@@ -47,7 +47,7 @@ jobs:
47
47
  with:
48
48
  python-version: "3.13"
49
49
  cache: pip
50
- cache-dependency-path: .github/workflows/ci.yml
50
+ cache-dependency-path: pyproject.toml
51
51
 
52
52
  - name: Install dependencies
53
53
  run: pip install -e ".[dev]"
@@ -71,7 +71,7 @@ jobs:
71
71
  with:
72
72
  python-version: "3.13"
73
73
  cache: pip
74
- cache-dependency-path: .github/workflows/ci.yml
74
+ cache-dependency-path: pyproject.toml
75
75
 
76
76
  - name: Install dependencies
77
77
  run: pip install -e ".[dev]"
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.2.1"
3
+ }
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.1](https://github.com/KRoperUK/uw-py/compare/v0.2.0...v0.2.1) (2026-07-23)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * lazy httpx.AsyncClient creation to avoid blocking SSL init ([ad96276](https://github.com/KRoperUK/uw-py/commit/ad962764820c7f37983ca0fb9f215e1742ae382a))
9
+ * point pip cache at pyproject.toml, not ci.yml ([f94f388](https://github.com/KRoperUK/uw-py/commit/f94f38898ba96bc6ff2eb29f35fc30fc12e4320d))
10
+
3
11
  ## [0.2.0](https://github.com/KRoperUK/uw-py/compare/v0.1.0...v0.2.0) (2026-07-23)
4
12
 
5
13
 
uw_api-0.2.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kieran Roper
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.
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uw-api
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Async Python client for the Utility Warehouse customer portal API
5
5
  Author-email: Kieran <kieran@example.com>
6
6
  License: MIT
7
+ License-File: LICENSE
7
8
  Keywords: energy,home-assistant,utility-warehouse
8
9
  Classifier: Development Status :: 3 - Alpha
9
10
  Classifier: Intended Audience :: Developers
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "uw-api"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "Async Python client for the Utility Warehouse customer portal API"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -10,7 +10,7 @@ from uw_api.exceptions import (
10
10
  UWSessionExpiredError,
11
11
  )
12
12
 
13
- __version__ = "0.2.0"
13
+ __version__ = "0.2.1"
14
14
  __all__ = [
15
15
  "UWApiError",
16
16
  "UWAuthError",
@@ -21,6 +21,7 @@ class UWClient:
21
21
  timeout: float = 30.0,
22
22
  max_retries: int = 3,
23
23
  backoff_base: float = 1.0,
24
+ http_client: httpx.AsyncClient | None = None,
24
25
  ) -> None:
25
26
  self._email = email
26
27
  self._password = password
@@ -28,31 +29,50 @@ class UWClient:
28
29
  self._max_retries = max_retries
29
30
  self._backoff_base = backoff_base
30
31
 
31
- self._http_client = httpx.AsyncClient(
32
- http2=False,
33
- timeout=httpx.Timeout(timeout),
34
- follow_redirects=True,
35
- )
36
-
37
- self._auth = UWAuth(
32
+ self._owns_client = http_client is None
33
+ self._http_client = http_client
34
+
35
+ self._auth_obj: UWAuth | None = None
36
+ self._gql_obj: UWGraphQL | None = None
37
+
38
+ def _ensure_client(self) -> None:
39
+ if self._auth_obj is not None:
40
+ return
41
+ if self._http_client is None:
42
+ self._http_client = httpx.AsyncClient(
43
+ http2=False,
44
+ timeout=httpx.Timeout(self._timeout),
45
+ follow_redirects=True,
46
+ )
47
+ self._auth_obj = UWAuth(
38
48
  self._http_client,
39
49
  email=self._email,
40
50
  password=self._password,
41
- max_retries=max_retries,
42
- backoff_base=backoff_base,
51
+ max_retries=self._max_retries,
52
+ backoff_base=self._backoff_base,
43
53
  )
44
-
45
- self.gql = UWGraphQL(self, self._http_client)
54
+ self._gql_obj = UWGraphQL(self, self._http_client)
46
55
 
47
56
  @property
48
57
  def http_client(self) -> httpx.AsyncClient:
58
+ self._ensure_client()
59
+ assert self._http_client is not None
49
60
  return self._http_client
50
61
 
62
+ @property
63
+ def gql(self) -> UWGraphQL:
64
+ self._ensure_client()
65
+ assert self._gql_obj is not None
66
+ return self._gql_obj
67
+
51
68
  async def login(self) -> None:
52
- await self._auth.login()
69
+ self._ensure_client()
70
+ assert self._auth_obj is not None
71
+ await self._auth_obj.login()
53
72
 
54
73
  async def close(self) -> None:
55
- await self._http_client.aclose()
74
+ if self._owns_client and self._http_client is not None:
75
+ await self._http_client.aclose()
56
76
 
57
77
  async def __aenter__(self) -> UWClient:
58
78
  return self
@@ -66,7 +86,11 @@ class UWClient:
66
86
  query: str,
67
87
  variables: dict[str, Any] | None = None,
68
88
  ) -> dict[str, Any]:
69
- await self._auth.ensure_authenticated()
89
+ self._ensure_client()
90
+ assert self._auth_obj is not None
91
+ assert self._http_client is not None
92
+
93
+ await self._auth_obj.ensure_authenticated()
70
94
 
71
95
  body: dict[str, Any] = {
72
96
  "operationName": operation_name,
@@ -77,17 +101,17 @@ class UWClient:
77
101
  for attempt in range(self._max_retries):
78
102
  try:
79
103
  response = await self._http_client.post(
80
- self._auth.graphql_url,
104
+ self._auth_obj.graphql_url,
81
105
  json=body,
82
106
  headers={
83
107
  "Content-Type": "application/json",
84
- "x-csrf-token": self._auth.csrf_token or "1",
108
+ "x-csrf-token": self._auth_obj.csrf_token or "1",
85
109
  },
86
110
  )
87
111
 
88
112
  if response.status_code == 401:
89
113
  _LOGGER.warning("Session expired, re-authenticating")
90
- await self._auth.re_auth()
114
+ await self._auth_obj.re_auth()
91
115
  continue
92
116
 
93
117
  if response.status_code == 429:
@@ -126,7 +150,7 @@ class UWClient:
126
150
  except httpx.HTTPStatusError as exc:
127
151
  if exc.response.status_code == 401:
128
152
  _LOGGER.warning("Session expired, re-authenticating")
129
- await self._auth.re_auth()
153
+ await self._auth_obj.re_auth()
130
154
  continue
131
155
  if exc.response.status_code == 429:
132
156
  retry_after = int(
@@ -53,8 +53,10 @@ def graphql_bills() -> dict:
53
53
 
54
54
 
55
55
  def _mock_authenticated(client: UWClient) -> None:
56
- client._auth._authenticated = True
57
- client._auth._session_expires_at = time.monotonic() + 3600
56
+ client._ensure_client()
57
+ assert client._auth_obj is not None
58
+ client._auth_obj._authenticated = True
59
+ client._auth_obj._session_expires_at = time.monotonic() + 3600
58
60
 
59
61
 
60
62
  class TestGraphQL:
@@ -1,3 +0,0 @@
1
- {
2
- ".": "0.2.0"
3
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes