tempestwx 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.
Files changed (95) hide show
  1. tempestwx-0.0.2/.editorconfig +29 -0
  2. tempestwx-0.0.2/.env.example +1 -0
  3. tempestwx-0.0.2/.github/SECURITY.md +13 -0
  4. tempestwx-0.0.2/.github/actions/setup/action.yml +15 -0
  5. tempestwx-0.0.2/.github/dependabot.yml +11 -0
  6. tempestwx-0.0.2/.github/workflows/check.yml +17 -0
  7. tempestwx-0.0.2/.github/workflows/release.yml +39 -0
  8. tempestwx-0.0.2/.gitignore +223 -0
  9. tempestwx-0.0.2/.pre-commit-config.yaml +32 -0
  10. tempestwx-0.0.2/.python-version +1 -0
  11. tempestwx-0.0.2/CHANGELOG.md +11 -0
  12. tempestwx-0.0.2/LICENSE +21 -0
  13. tempestwx-0.0.2/PKG-INFO +213 -0
  14. tempestwx-0.0.2/README.md +189 -0
  15. tempestwx-0.0.2/THIRD_PARTY_NOTICES.md +38 -0
  16. tempestwx-0.0.2/config.example.json +11 -0
  17. tempestwx-0.0.2/justfile +38 -0
  18. tempestwx-0.0.2/pyproject.toml +157 -0
  19. tempestwx-0.0.2/src/tempestwx/__init__.py +30 -0
  20. tempestwx-0.0.2/src/tempestwx/_auth/__init__.py +14 -0
  21. tempestwx-0.0.2/src/tempestwx/_auth/token.py +60 -0
  22. tempestwx-0.0.2/src/tempestwx/_client/__init__.py +9 -0
  23. tempestwx-0.0.2/src/tempestwx/_client/api/__init__.py +23 -0
  24. tempestwx-0.0.2/src/tempestwx/_client/api/tempest_home/better_forecast/__init__.py +7 -0
  25. tempestwx-0.0.2/src/tempestwx/_client/api/tempest_home/better_forecast/better_forecast.py +93 -0
  26. tempestwx-0.0.2/src/tempestwx/_client/api/tempest_home/observations/__init__.py +7 -0
  27. tempestwx-0.0.2/src/tempestwx/_client/api/tempest_home/observations/observations.py +241 -0
  28. tempestwx-0.0.2/src/tempestwx/_client/api/tempest_home/stations/__init__.py +7 -0
  29. tempestwx-0.0.2/src/tempestwx/_client/api/tempest_home/stations/stations.py +58 -0
  30. tempestwx-0.0.2/src/tempestwx/_client/api/tempest_home/stats/__init__.py +7 -0
  31. tempestwx-0.0.2/src/tempestwx/_client/api/tempest_home/stats/stats.py +48 -0
  32. tempestwx-0.0.2/src/tempestwx/_client/base.py +273 -0
  33. tempestwx-0.0.2/src/tempestwx/_client/client.py +182 -0
  34. tempestwx-0.0.2/src/tempestwx/_client/decorators/__init__.py +16 -0
  35. tempestwx-0.0.2/src/tempestwx/_client/decorators/error_handler.py +61 -0
  36. tempestwx-0.0.2/src/tempestwx/_client/decorators/request_handler.py +58 -0
  37. tempestwx-0.0.2/src/tempestwx/_client/processor.py +68 -0
  38. tempestwx-0.0.2/src/tempestwx/_http/__init__.py +64 -0
  39. tempestwx-0.0.2/src/tempestwx/_http/base.py +110 -0
  40. tempestwx-0.0.2/src/tempestwx/_http/client.py +251 -0
  41. tempestwx-0.0.2/src/tempestwx/_http/concrete.py +153 -0
  42. tempestwx-0.0.2/src/tempestwx/_http/error.py +151 -0
  43. tempestwx-0.0.2/src/tempestwx/_http/wrapper.py +52 -0
  44. tempestwx-0.0.2/src/tempestwx/_models/__init__.py +35 -0
  45. tempestwx-0.0.2/src/tempestwx/_models/_serializer.py +191 -0
  46. tempestwx-0.0.2/src/tempestwx/_models/better_forecast.py +40 -0
  47. tempestwx-0.0.2/src/tempestwx/_models/better_forecast_current_conditions.py +60 -0
  48. tempestwx-0.0.2/src/tempestwx/_models/better_forecast_daily_forecast.py +38 -0
  49. tempestwx-0.0.2/src/tempestwx/_models/better_forecast_forecast.py +24 -0
  50. tempestwx-0.0.2/src/tempestwx/_models/better_forecast_hourly_forecast.py +46 -0
  51. tempestwx-0.0.2/src/tempestwx/_models/better_forecast_units.py +41 -0
  52. tempestwx-0.0.2/src/tempestwx/_models/device.py +40 -0
  53. tempestwx-0.0.2/src/tempestwx/_models/device_meta.py +26 -0
  54. tempestwx-0.0.2/src/tempestwx/_models/device_observation.py +32 -0
  55. tempestwx-0.0.2/src/tempestwx/_models/device_observation_summary.py +40 -0
  56. tempestwx-0.0.2/src/tempestwx/_models/device_settings.py +22 -0
  57. tempestwx-0.0.2/src/tempestwx/_models/lightning_event.py +59 -0
  58. tempestwx-0.0.2/src/tempestwx/_models/obs_air.py +83 -0
  59. tempestwx-0.0.2/src/tempestwx/_models/obs_air_ext.py +110 -0
  60. tempestwx-0.0.2/src/tempestwx/_models/obs_sky.py +119 -0
  61. tempestwx-0.0.2/src/tempestwx/_models/obs_sky_ext.py +151 -0
  62. tempestwx-0.0.2/src/tempestwx/_models/obs_st.py +143 -0
  63. tempestwx-0.0.2/src/tempestwx/_models/obs_st_ext.py +191 -0
  64. tempestwx-0.0.2/src/tempestwx/_models/observation.py +92 -0
  65. tempestwx-0.0.2/src/tempestwx/_models/rapid_wind.py +59 -0
  66. tempestwx-0.0.2/src/tempestwx/_models/station.py +60 -0
  67. tempestwx-0.0.2/src/tempestwx/_models/station_item.py +28 -0
  68. tempestwx-0.0.2/src/tempestwx/_models/station_meta.py +23 -0
  69. tempestwx-0.0.2/src/tempestwx/_models/station_observation_latest.py +36 -0
  70. tempestwx-0.0.2/src/tempestwx/_models/station_observations.py +33 -0
  71. tempestwx-0.0.2/src/tempestwx/_models/station_set.py +24 -0
  72. tempestwx-0.0.2/src/tempestwx/_models/station_units.py +43 -0
  73. tempestwx-0.0.2/src/tempestwx/_models/stats_day.py +179 -0
  74. tempestwx-0.0.2/src/tempestwx/_models/stats_set.py +55 -0
  75. tempestwx-0.0.2/src/tempestwx/_models/status.py +38 -0
  76. tempestwx-0.0.2/src/tempestwx/_models/units_default.py +191 -0
  77. tempestwx-0.0.2/src/tempestwx/py.typed +1 -0
  78. tempestwx-0.0.2/src/tempestwx/settings.py +175 -0
  79. tempestwx-0.0.2/src/tempestwx/settings_loader.py +210 -0
  80. tempestwx-0.0.2/src/tempestwx/version.py +15 -0
  81. tempestwx-0.0.2/tasks/check.just +33 -0
  82. tempestwx-0.0.2/tasks/clean.just +40 -0
  83. tempestwx-0.0.2/tasks/format.just +13 -0
  84. tempestwx-0.0.2/tasks/install.just +15 -0
  85. tempestwx-0.0.2/tasks/package.just +8 -0
  86. tempestwx-0.0.2/tasks/release.just +28 -0
  87. tempestwx-0.0.2/tests/__init__.py +1 -0
  88. tempestwx-0.0.2/tests/conftest.py +24 -0
  89. tempestwx-0.0.2/tests/smoke_test.py +100 -0
  90. tempestwx-0.0.2/tests/unit/__init__.py +1 -0
  91. tempestwx-0.0.2/tests/unit/api_endpoints_test.py +175 -0
  92. tempestwx-0.0.2/tests/unit/context_manager_test.py +82 -0
  93. tempestwx-0.0.2/tests/unit/dotenv_test.py +35 -0
  94. tempestwx-0.0.2/tests/unit/settings_test.py +42 -0
  95. tempestwx-0.0.2/uv.lock +753 -0
@@ -0,0 +1,29 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+ [*]
8
+ # Change these settings to your own preference
9
+ indent_style = space
10
+ indent_size = 2
11
+ max_line_length = 80
12
+
13
+ # We recommend you to keep these unchanged
14
+ end_of_line = lf
15
+ charset = utf-8
16
+ trim_trailing_whitespace = true
17
+ insert_final_newline = true
18
+
19
+ [*.md]
20
+ trim_trailing_whitespace = false
21
+
22
+ [*.py]
23
+ indent_size = 4
24
+
25
+ [*.toml]
26
+ indent_size = 4
27
+
28
+ [{*.just, justfile}]
29
+ indent_size = 4
@@ -0,0 +1 @@
1
+ TEMPEST_ACCESS_TOKEN="<personal_access_token>"
@@ -0,0 +1,13 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 0.x | :white_check_mark: |
8
+
9
+ ## Reporting a Vulnerability
10
+
11
+ Report via <https://github.com/greylabel/tempestwx/security/advisories>.
12
+
13
+ Guidance: [Privately reporting a security vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability).
@@ -0,0 +1,15 @@
1
+ name: Setup
2
+ description: Setup for python + uv project workflows
3
+ runs:
4
+ using: composite
5
+ steps:
6
+ - name: Setup Python
7
+ uses: actions/setup-python@v6
8
+ with:
9
+ python-version-file: .python-version
10
+
11
+ - name: Install uv
12
+ uses: astral-sh/setup-uv@v7
13
+ with:
14
+ enable-cache: true
15
+ version: "0.9.13"
@@ -0,0 +1,11 @@
1
+ # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference
2
+ version: 2
3
+ updates:
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ - package-ecosystem: "uv"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
@@ -0,0 +1,17 @@
1
+ name: Check
2
+ on: [push, pull_request]
3
+ concurrency:
4
+ cancel-in-progress: true
5
+ group: ${{ github.workflow }}-${{ github.ref }}
6
+ jobs:
7
+ checks:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v6
11
+ - uses: ./.github/actions/setup
12
+ - run: uv sync --group=check
13
+ - run: uv run just check-code
14
+ - run: uv run just check-type
15
+ - run: uv run just check-format
16
+ - run: uv run just check-security
17
+ - run: uv run just check-coverage
@@ -0,0 +1,39 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ # Publish on any tag starting with a `v`, e.g., v1.2.3
7
+ - v*
8
+
9
+ jobs:
10
+ pypi:
11
+ name: Publish to PyPI
12
+ runs-on: ubuntu-latest
13
+ # Environment and permissions trusted publishing.
14
+ environment:
15
+ # Environment must exist in the GitHub repository under Settings -> Environments
16
+ name: pypi
17
+ permissions:
18
+ id-token: write
19
+ contents: read
20
+ steps:
21
+ - uses: actions/checkout@v6
22
+ - uses: ./.github/actions/setup
23
+ # Verify tag matches pyproject.toml version
24
+ - name: Verify version
25
+ run: |
26
+ TAG_VERSION=${GITHUB_REF#refs/tags/v}
27
+ PROJECT_VERSION=$(uv version --short)
28
+ if [ "$TAG_VERSION" != "$PROJECT_VERSION" ]; then
29
+ echo "Tag version ($TAG_VERSION) doesn't match project version ($PROJECT_VERSION)"
30
+ exit 1
31
+ fi
32
+ - name: Package
33
+ run: uv run just package
34
+ - name: Smoke test wheel artifact
35
+ run: uv run just test-wheel
36
+ - name: Smoke test sdist artifact
37
+ run: uv run just test-source
38
+ - name: Release
39
+ run: uv run just release-package
@@ -0,0 +1,223 @@
1
+ config.json
2
+ x.py
3
+
4
+ ###
5
+ ### https://github.com/github/gitignore/blob/main/Python.gitignore
6
+ ###
7
+
8
+ # Byte-compiled / optimized / DLL files
9
+ __pycache__/
10
+ *.py[codz]
11
+ *$py.class
12
+
13
+ # C extensions
14
+ *.so
15
+
16
+ # Distribution / packaging
17
+ .Python
18
+ build/
19
+ develop-eggs/
20
+ dist/
21
+ downloads/
22
+ eggs/
23
+ .eggs/
24
+ lib/
25
+ lib64/
26
+ parts/
27
+ sdist/
28
+ var/
29
+ wheels/
30
+ share/python-wheels/
31
+ *.egg-info/
32
+ .installed.cfg
33
+ *.egg
34
+ MANIFEST
35
+
36
+ # PyInstaller
37
+ # Usually these files are written by a python script from a template
38
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
39
+ *.manifest
40
+ *.spec
41
+
42
+ # Installer logs
43
+ pip-log.txt
44
+ pip-delete-this-directory.txt
45
+
46
+ # Unit test / coverage reports
47
+ htmlcov/
48
+ .tox/
49
+ .nox/
50
+ .coverage
51
+ .coverage.*
52
+ .cache
53
+ nosetests.xml
54
+ coverage.xml
55
+ *.cover
56
+ *.py.cover
57
+ .hypothesis/
58
+ .pytest_cache/
59
+ cover/
60
+
61
+ # Translations
62
+ *.mo
63
+ *.pot
64
+
65
+ # Django stuff:
66
+ *.log
67
+ local_settings.py
68
+ db.sqlite3
69
+ db.sqlite3-journal
70
+
71
+ # Flask stuff:
72
+ instance/
73
+ .webassets-cache
74
+
75
+ # Scrapy stuff:
76
+ .scrapy
77
+
78
+ # Sphinx documentation
79
+ docs/_build/
80
+
81
+ # PyBuilder
82
+ .pybuilder/
83
+ target/
84
+
85
+ # Jupyter Notebook
86
+ .ipynb_checkpoints
87
+
88
+ # IPython
89
+ profile_default/
90
+ ipython_config.py
91
+
92
+ # pyenv
93
+ # For a library or package, you might want to ignore these files since the code is
94
+ # intended to run in multiple environments; otherwise, check them in:
95
+ # .python-version
96
+
97
+ # pipenv
98
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
99
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
100
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
101
+ # install all needed dependencies.
102
+ # Pipfile.lock
103
+
104
+ # UV
105
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # uv.lock
109
+
110
+ # poetry
111
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
112
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
113
+ # commonly ignored for libraries.
114
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
115
+ # poetry.lock
116
+ # poetry.toml
117
+
118
+ # pdm
119
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
120
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
121
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
122
+ # pdm.lock
123
+ # pdm.toml
124
+ .pdm-python
125
+ .pdm-build/
126
+
127
+ # pixi
128
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
129
+ # pixi.lock
130
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
131
+ # in the .venv directory. It is recommended not to include this directory in version control.
132
+ .pixi
133
+
134
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
135
+ __pypackages__/
136
+
137
+ # Celery stuff
138
+ celerybeat-schedule
139
+ celerybeat.pid
140
+
141
+ # Redis
142
+ *.rdb
143
+ *.aof
144
+ *.pid
145
+
146
+ # RabbitMQ
147
+ mnesia/
148
+ rabbitmq/
149
+ rabbitmq-data/
150
+
151
+ # ActiveMQ
152
+ activemq-data/
153
+
154
+ # SageMath parsed files
155
+ *.sage.py
156
+
157
+ # Environments
158
+ .env
159
+ .envrc
160
+ .venv
161
+ env/
162
+ venv/
163
+ ENV/
164
+ env.bak/
165
+ venv.bak/
166
+
167
+ # Spyder project settings
168
+ .spyderproject
169
+ .spyproject
170
+
171
+ # Rope project settings
172
+ .ropeproject
173
+
174
+ # mkdocs documentation
175
+ /site
176
+
177
+ # mypy
178
+ .mypy_cache/
179
+ .dmypy.json
180
+ dmypy.json
181
+
182
+ # Pyre type checker
183
+ .pyre/
184
+
185
+ # pytype static type analyzer
186
+ .pytype/
187
+
188
+ # Cython debug symbols
189
+ cython_debug/
190
+
191
+ # PyCharm
192
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
193
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
194
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
195
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
196
+ # .idea/
197
+
198
+ # Abstra
199
+ # Abstra is an AI-powered process automation framework.
200
+ # Ignore directories containing user credentials, local state, and settings.
201
+ # Learn more at https://abstra.io/docs
202
+ .abstra/
203
+
204
+ # Visual Studio Code
205
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
206
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
207
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
208
+ # you could uncomment the following to ignore the entire vscode folder
209
+ # .vscode/
210
+
211
+ # Ruff stuff:
212
+ .ruff_cache/
213
+
214
+ # PyPI configuration file
215
+ .pypirc
216
+
217
+ # Marimo
218
+ marimo/_static/
219
+ marimo/_lsp/
220
+ __marimo__/
221
+
222
+ # Streamlit
223
+ .streamlit/secrets.toml
@@ -0,0 +1,32 @@
1
+ # https://pre-commit.com
2
+ # https://pre-commit.com/hooks.html
3
+
4
+ default_language_version:
5
+ python: python3.13
6
+ repos:
7
+ - repo: https://github.com/pre-commit/pre-commit-hooks
8
+ rev: 'v6.0.0'
9
+ hooks:
10
+ - id: check-added-large-files
11
+ - id: check-case-conflict
12
+ - id: check-merge-conflict
13
+ - id: check-toml
14
+ - id: check-yaml
15
+ - id: debug-statements
16
+ - id: end-of-file-fixer
17
+ - id: mixed-line-ending
18
+ - id: trailing-whitespace
19
+ - repo: https://github.com/astral-sh/ruff-pre-commit
20
+ rev: 'v0.14.7'
21
+ hooks:
22
+ # Run the linter (check only, no fixes)
23
+ - id: ruff-check
24
+ # Run the formatter (check only, no fixes)
25
+ - id: ruff-format
26
+ args: [ --check ]
27
+ - repo: https://github.com/PyCQA/bandit
28
+ rev: '1.9.2'
29
+ hooks:
30
+ - id: bandit
31
+ args: ["--recursive", "--configfile", "pyproject.toml", "src"]
32
+ pass_filenames: false
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## v0.0.1
6
+
7
+ - Initial open source version.
8
+
9
+ ## v0.0.2
10
+
11
+ - Fix GH Actions Release workflow.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Grant Gaudet
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.
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: tempestwx
3
+ Version: 0.0.2
4
+ Summary: Tempest SDK for Python
5
+ Project-URL: repository, https://github.com/greylabel/tempestwx
6
+ Author-email: Grant Gaudet <grant@greylabel.net>
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: api,tempest,weather
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.13
19
+ Requires-Dist: httpx>=0.28.1
20
+ Requires-Dist: pydantic-settings>=2.11.0
21
+ Requires-Dist: pydantic>=2.12.3
22
+ Requires-Dist: python-dotenv>=1.1.1
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Tempest
26
+
27
+ Python SDK for the [Tempest API](https://apidocs.tempestwx.com/reference).
28
+
29
+ ## Installation
30
+
31
+ Requires Python 3.13+.
32
+
33
+ - From PyPI:
34
+
35
+ ```bash
36
+ pip install tempestwx
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ Ensure `TEMPEST_ACCESS_TOKEN` is set (via environment or `.env`).
42
+
43
+ ```python
44
+ from tempestwx import Tempest
45
+
46
+ # Recommended: Use context manager for automatic resource cleanup
47
+ with Tempest() as twx:
48
+ stations = twx.stations()
49
+ print(stations)
50
+
51
+ # Alternative: Manual resource management
52
+ twx = Tempest()
53
+ try:
54
+ stations = twx.stations()
55
+ print(stations)
56
+ finally:
57
+ twx.close()
58
+ ```
59
+
60
+ The client returns Pydantic models. Use `.model_dump()` to convert to `dict` when needed.
61
+
62
+ ### Configuration & Settings
63
+
64
+ The client uses a deterministic cascade to resolve configuration:
65
+
66
+ 1. Library defaults (built‑in constants)
67
+ 2. `config.json` (first existing among: `$TEMPEST_CONFIG_PATH`, `./config.json`)
68
+ 3. `.env` file (loaded automatically once, without overriding already exported environment vars)
69
+ 4. Live environment variables (take precedence over `.env` values)
70
+ 5. Explicit parameters passed to `Tempest(...)` (highest precedence)
71
+
72
+ Resolved values are materialized into an immutable `Settings` instance:
73
+
74
+ ```python
75
+ from tempestwx.settings_loader import load_settings
76
+ settings = load_settings()
77
+ print(settings.api_uri, settings.token)
78
+ ```
79
+
80
+ You can explicitly override when constructing the client:
81
+
82
+ ```python
83
+ from tempestwx import Tempest
84
+
85
+ with Tempest(token="OVERRIDE_TOKEN") as twx:
86
+ stations = twx.stations()
87
+ ```
88
+
89
+ Or derive a modified settings object:
90
+
91
+ ```python
92
+ from tempestwx.settings_loader import load_settings
93
+
94
+ base = load_settings()
95
+ custom = base.with_overrides(api_uri="https://example.test/api/")
96
+
97
+ with Tempest(settings=custom) as twx:
98
+ stations = twx.stations()
99
+ ```
100
+
101
+ ### Environment Variables
102
+
103
+ Supported variables:
104
+
105
+ - `TEMPEST_ACCESS_TOKEN` – API auth token
106
+ - `TEMPEST_API_URI` – Base API URI (defaults to `https://swd.weatherflow.com/swd/rest/`)
107
+ - `TEMPEST_CONFIG_PATH` – Optional path to a JSON config file (fallbacks to `./config.json`)
108
+ - Unit overrides (optional):
109
+ - `TEMPEST_DEFAULT_UNIT_TEMPERATURE`
110
+ - `TEMPEST_DEFAULT_UNIT_PRESSURE`
111
+ - `TEMPEST_DEFAULT_UNIT_WIND`
112
+ - `TEMPEST_DEFAULT_UNIT_DISTANCE`
113
+ - `TEMPEST_DEFAULT_UNIT_PRECIP`
114
+ - `TEMPEST_DEFAULT_UNIT_BRIGHTNESS`
115
+ - `TEMPEST_DEFAULT_UNIT_SOLAR_RADIATION`
116
+ - `TEMPEST_DEFAULT_UNIT_BUCKET_STEP_MINUTES`
117
+
118
+ ### .env Support
119
+
120
+ If a `.env` file exists in the working directory, it is loaded automatically (without overriding already exported variables) the first time `load_settings()` runs.
121
+
122
+ Example `.env`:
123
+
124
+ ```dotenv
125
+ TEMPEST_ACCESS_TOKEN=your-token-here
126
+ ```
127
+
128
+ ### config.json example
129
+
130
+ If present, values provide defaults that can be overridden by environment variables:
131
+
132
+ ```json
133
+ {
134
+ "api_uri": "https://swd.weatherflow.com/swd/rest/",
135
+ "default_unit_temperature": "c",
136
+ "default_unit_pressure": "mb",
137
+ "default_unit_wind": "mps",
138
+ "default_unit_distance": "km",
139
+ "default_units_precip": "mm",
140
+ "default_units_brightness": "lux",
141
+ "default_units_solar_radiation": "w/m2",
142
+ "default_units_bucket_step_minutes": 1
143
+ }
144
+ ```
145
+
146
+ Note: tokens are not read from `config.json`. Use environment variables or `.env` for `TEMPEST_ACCESS_TOKEN`.
147
+
148
+ ### Reloading Settings
149
+
150
+ Caching avoids repeated disk & env parsing. To pick up changes at runtime:
151
+
152
+ ```python
153
+ from tempestwx.settings_loader import reload_settings
154
+ reload_settings() # clears cache and re-evaluates cascade
155
+ ```
156
+
157
+ ### Units Overrides
158
+
159
+ You can supply partial unit overrides via `UnitsOverrides` (only fields you specify are changed):
160
+
161
+ ```python
162
+ from tempestwx import Tempest
163
+ from tempestwx.settings import UnitsOverrides
164
+ from tempestwx.settings_loader import load_settings
165
+
166
+ base = load_settings()
167
+ custom = base.with_overrides(units_overrides=UnitsOverrides(temp="f", wind="mph"))
168
+
169
+ with Tempest(settings=custom) as twx:
170
+ forecast = twx.better_forecast(station_id=12345)
171
+ ```
172
+
173
+ ### Token Context Override
174
+
175
+ Temporarily swap tokens within a context:
176
+
177
+ ```python
178
+ from tempestwx import Tempest
179
+
180
+ with Tempest() as twx:
181
+ # Use default token
182
+ stations = twx.stations()
183
+
184
+ # Temporarily use different token
185
+ with twx.token_as("temporary-token"):
186
+ other_stations = twx.stations()
187
+
188
+ # Back to default token
189
+ more_stations = twx.stations()
190
+ ```
191
+
192
+ ### Async Usage
193
+
194
+ All endpoints support async when the client is created with `asynchronous=True`:
195
+
196
+ ```python
197
+ import asyncio
198
+ from tempestwx import Tempest
199
+
200
+ async def main():
201
+ # Use async context manager for proper cleanup
202
+ async with Tempest(asynchronous=True) as twx:
203
+ stations = await twx.stations()
204
+ print(stations)
205
+
206
+ asyncio.run(main())
207
+ ```
208
+
209
+ ## Roadmap
210
+
211
+ - OAuth Authorization Code (with PKCE) grant types
212
+ - Additional Tempest APIs, e.g. TempestOne
213
+ - Standalone documentation with MkDocs