atlan-application-sdk-api 3.57.0__tar.gz → 3.58.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 (92) hide show
  1. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/.gitignore +10 -3
  2. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/PKG-INFO +4 -4
  3. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/api-files.txt +2 -0
  4. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_context_errors.py +25 -15
  5. atlan_application_sdk_api-3.58.1/application_sdk/_deprecation.py +195 -0
  6. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_env.py +50 -0
  7. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_obstore_config.py +4 -4
  8. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_runtime/cgroup.py +1 -1
  9. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_runtime/offload.py +7 -3
  10. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/base.py +94 -9
  11. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/sql.py +1 -1
  12. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/sql_errors.py +38 -15
  13. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/sql_typecasters.py +3 -3
  14. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/__init__.py +5 -1
  15. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/_listing.py +1 -1
  16. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/aws_utils.py +50 -5
  17. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/backoff.py +4 -2
  18. atlan_application_sdk_api-3.58.1/application_sdk/common/concurrency.py +53 -0
  19. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/errors.py +13 -1
  20. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/models.py +16 -0
  21. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/sql_filters.py +2 -2
  22. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/utils.py +8 -15
  23. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/constants.py +43 -29
  24. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/contracts/__init__.py +2 -0
  25. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/contracts/base.py +94 -56
  26. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/contracts/events.py +27 -0
  27. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/contracts/types.py +17 -11
  28. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/credentials/errors.py +63 -87
  29. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/credentials/types.py +7 -7
  30. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/credentials/utils.py +10 -9
  31. atlan_application_sdk_api-3.58.1/application_sdk/errors/__init__.py +413 -0
  32. atlan_application_sdk_api-3.58.1/application_sdk/errors/_legacy_codes.py +181 -0
  33. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/errors/base.py +100 -3
  34. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/_dispatch.py +1 -1
  35. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/base.py +32 -21
  36. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/contracts.py +40 -90
  37. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/metadata_routes.py +7 -7
  38. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/object_routes.py +2 -1
  39. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/request_contract.py +37 -7
  40. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/routes.py +7 -4
  41. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/templates/contracts/incremental_sql.py +1 -1
  42. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/version.py +1 -1
  43. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/pyproject.toml +4 -4
  44. atlan_application_sdk_api-3.57.0/application_sdk/common/concurrency.py +0 -45
  45. atlan_application_sdk_api-3.57.0/application_sdk/errors/__init__.py +0 -228
  46. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/README.md +0 -0
  47. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/__init__.py +0 -0
  48. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_build_info.py +0 -0
  49. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_install.py +0 -0
  50. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_logging.py +0 -0
  51. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_runtime/__init__.py +0 -0
  52. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/_runtime/progress.py +0 -0
  53. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/__init__.py +0 -0
  54. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/_interface.py +0 -0
  55. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/_sql_failure_classifier.py +0 -0
  56. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/http_errors.py +0 -0
  57. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/models.py +0 -0
  58. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/clients/ssl_utils.py +0 -0
  59. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/_generated_tree.py +0 -0
  60. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/aws_utils_errors.py +0 -0
  61. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/build_identity.py +0 -0
  62. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/filter_matching.py +0 -0
  63. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/logger.py +0 -0
  64. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/sql_filters_errors.py +0 -0
  65. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/ssl_utils.py +0 -0
  66. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/task_queue.py +0 -0
  67. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/common/types.py +0 -0
  68. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/contracts/types_errors.py +0 -0
  69. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/credentials/__init__.py +0 -0
  70. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/credentials/extra.py +0 -0
  71. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/credentials/ingress.py +0 -0
  72. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/credentials/ref.py +0 -0
  73. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/credentials/requirements.py +0 -0
  74. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/credentials/spec.py +0 -0
  75. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/errors/categories.py +0 -0
  76. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/errors/http.py +0 -0
  77. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/errors/leaves.py +0 -0
  78. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/errors/wire.py +0 -0
  79. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/__init__.py +0 -0
  80. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/_warmup.py +0 -0
  81. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/asgi.py +0 -0
  82. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/context.py +0 -0
  83. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/manifest.py +0 -0
  84. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/handler/service_errors.py +0 -0
  85. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/server/__init__.py +0 -0
  86. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/server/fastapi/models.py +0 -0
  87. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/templates/__init__.py +0 -0
  88. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/templates/contracts/__init__.py +0 -0
  89. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/templates/contracts/base_metadata_extraction.py +0 -0
  90. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/templates/contracts/sql_metadata.py +0 -0
  91. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/application_sdk/templates/contracts/sql_query.py +0 -0
  92. {atlan_application_sdk_api-3.57.0 → atlan_application_sdk_api-3.58.1}/hatch_build.py +0 -0
@@ -167,8 +167,10 @@ docstring-cov.md
167
167
  # vscode settings
168
168
  .vscode
169
169
 
170
- # local
171
- local/
170
+ # local (local/temporal-auth/ is the tracked Docker JWT-auth Temporal stack;
171
+ # its keys stay ignored by its own .gitignore)
172
+ local/*
173
+ !local/temporal-auth/
172
174
  temporal.db
173
175
 
174
176
  # Claude Code worktrees
@@ -188,9 +190,14 @@ temporal.db
188
190
  .claude/scheduled_tasks.lock
189
191
 
190
192
  # Remediation run artifacts
191
- remediation/node_modules/
192
193
  remediation/runs/
193
194
 
195
+ # npm installs at any depth. The remediate skill's optional Reactor path has
196
+ # readers `npm i` into their own checkout, and one left under
197
+ # packages/conformance/conformance/ would otherwise ship in the next wheel:
198
+ # hatch builds from the git-ignore-filtered tree.
199
+ node_modules/
200
+
194
201
  # Renovate setup
195
202
  renovate-config/README.md
196
203
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: atlan-application-sdk-api
3
- Version: 3.57.0
3
+ Version: 3.58.1
4
4
  Summary: Experimental: the handler surface of the Atlan Application SDK, for the consolidated API host
5
5
  Project-URL: Homepage, https://github.com/atlanhq/application-sdk
6
6
  Project-URL: Source, https://github.com/atlanhq/application-sdk/tree/main/packages/api
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Programming Language :: Python :: 3.14
20
20
  Requires-Python: >=3.11
21
21
  Requires-Dist: certifi>=2026.10.19
22
- Requires-Dist: fastapi<0.163.0,>=0.162.0
22
+ Requires-Dist: fastapi<0.166.0,>=0.165.0
23
23
  Requires-Dist: httpx<0.29.0,>=0.27.0
24
24
  Requires-Dist: orjson<4.0.0,>=3.11.6
25
25
  Requires-Dist: pydantic<3.0.0,>=2.10.6
@@ -34,8 +34,8 @@ Requires-Dist: obstore<0.13.0,>=0.12.0; extra == 'obstore'
34
34
  Provides-Extra: pandas
35
35
  Requires-Dist: pandas<4.0.0,>=2.2.3; extra == 'pandas'
36
36
  Provides-Extra: pyatlan
37
- Requires-Dist: authlib<2,>=1.9.5; extra == 'pyatlan'
38
- Requires-Dist: pyatlan<12,>=11.7.0; extra == 'pyatlan'
37
+ Requires-Dist: authlib<2,>=1.9.9; extra == 'pyatlan'
38
+ Requires-Dist: pyatlan<12,>=11.7.1; extra == 'pyatlan'
39
39
  Provides-Extra: sql
40
40
  Requires-Dist: httpx<0.29.0,>=0.27.0; extra == 'sql'
41
41
  Requires-Dist: python-dotenv<2.0.0,>=1.2.2; extra == 'sql'
@@ -4,6 +4,7 @@
4
4
  application_sdk/__init__.py
5
5
  application_sdk/_build_info.py
6
6
  application_sdk/_context_errors.py
7
+ application_sdk/_deprecation.py
7
8
  application_sdk/_env.py
8
9
  application_sdk/_install.py
9
10
  application_sdk/_logging.py
@@ -56,6 +57,7 @@ application_sdk/credentials/spec.py
56
57
  application_sdk/credentials/types.py
57
58
  application_sdk/credentials/utils.py
58
59
  application_sdk/errors/__init__.py
60
+ application_sdk/errors/_legacy_codes.py
59
61
  application_sdk/errors/base.py
60
62
  application_sdk/errors/categories.py
61
63
  application_sdk/errors/http.py
@@ -10,7 +10,10 @@ from __future__ import annotations
10
10
  from dataclasses import dataclass
11
11
  from typing import ClassVar
12
12
 
13
- from application_sdk.errors import APP_CONTEXT_ERROR, ErrorCode
13
+ from application_sdk import _deprecation
14
+ from application_sdk.errors import _legacy_codes
15
+ from application_sdk.errors._legacy_codes import ErrorCode
16
+ from application_sdk.errors.base import _LegacyErrorCodeMixin
14
17
  from application_sdk.errors.leaves import InternalError as _InternalError
15
18
  from application_sdk.errors.leaves import PreconditionError
16
19
 
@@ -38,7 +41,8 @@ class SecretStoreNotConfiguredError(PreconditionError):
38
41
  expected_state: str | None = "configured"
39
42
 
40
43
 
41
- class AppContextError(_InternalError):
44
+ @dataclass(kw_only=True)
45
+ class AppContextError(_LegacyErrorCodeMixin, _InternalError):
42
46
  """Raised when App or task context is accessed outside of valid execution scope.
43
47
 
44
48
  This is a programming error — it indicates that context-dependent methods
@@ -46,20 +50,26 @@ class AppContextError(_InternalError):
46
50
  workflow run or @task execution.
47
51
  """
48
52
 
49
- DEFAULT_ERROR_CODE: ClassVar[ErrorCode] = APP_CONTEXT_ERROR
50
53
  code: ClassVar[str] = "INTERNAL_APP_CONTEXT"
51
54
 
52
55
  def __init__(self, message: str, *, error_code: ErrorCode | None = None) -> None:
53
56
  _InternalError.__init__(self, message=message)
54
- self._legacy_error_code = error_code
55
-
56
- @property
57
- def error_code(self) -> ErrorCode:
58
- return (
59
- self._legacy_error_code
60
- if self._legacy_error_code is not None
61
- else self.DEFAULT_ERROR_CODE
62
- )
63
-
64
- def __str__(self) -> str:
65
- return f"[{self.error_code.code}] {self.message}"
57
+ self._set_legacy_error_code(error_code)
58
+
59
+
60
+ #: The AAF-* constants this module imported before FND-4299, kept importable
61
+ #: from here with a warning until v4.0.0. Literal per entry: the surface gate
62
+ #: and gen-deprecations read this table statically.
63
+ _DEPRECATED_CONSTANTS: dict[str, tuple[str, str]] = {
64
+ "APP_CONTEXT_ERROR": (
65
+ "the code ClassVar of a typed application_sdk.errors.AppError subclass",
66
+ "AAF-* codes are a second error vocabulary beside code",
67
+ ),
68
+ }
69
+
70
+ __getattr__ = _deprecation.deprecated_module_getattr(
71
+ __name__,
72
+ _DEPRECATED_CONSTANTS,
73
+ remove_in="4.0.0",
74
+ resolve=lambda name: getattr(_legacy_codes, name),
75
+ )
@@ -0,0 +1,195 @@
1
+ """The one deprecation mechanism the SDK uses.
2
+
3
+ Three shapes cover every deprecation, and each has one helper here:
4
+
5
+ * **A def or a class** — :func:`deprecated` (PEP 702, re-exported from
6
+ ``typing_extensions``). Type checkers flag the call site and Python warns on
7
+ use.
8
+ * **A deprecated way of calling something** (a parameter, a default, a mode) —
9
+ :func:`warn_deprecated`. It builds the notice in one fixed format, so every
10
+ notice names a replacement and a removal version.
11
+ * **A module-level name** (a moved or removed constant, a re-export) —
12
+ :func:`deprecated_module_getattr`, a PEP 562 ``__getattr__`` built from a
13
+ ``_DEPRECATED_CONSTANTS`` table.
14
+
15
+ Standard library and ``typing_extensions`` only: ``application_sdk.constants``
16
+ uses the module-level shim, so nothing here may import from the SDK.
17
+
18
+ The conformance suite reads these statically. A ``warn_deprecated(...)`` call
19
+ and a ``__getattr__ = deprecated_module_getattr(...)`` assignment are both
20
+ graded by B002/B003 and recorded in the deprecated-symbol manifest, so pass the
21
+ name, replacement and ``remove_in`` as literals. A value held in a variable
22
+ cannot be read without running the code. See ``docs/standards/symbols.md``.
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ import importlib
28
+ import re
29
+ import warnings
30
+ from collections.abc import Callable, Mapping
31
+
32
+ from typing_extensions import deprecated
33
+
34
+ __all__ = [
35
+ "deprecated",
36
+ "deprecated_module_getattr",
37
+ "deprecation_message",
38
+ "lazy_resolver",
39
+ "warn_deprecated",
40
+ ]
41
+
42
+ #: A removal version is a full ``major.minor.patch``. ``4.0`` and ``4.0.0``
43
+ #: name the same release, and allowing both made the SDK use both.
44
+ _VERSION_RE = re.compile(r"\d+\.\d+\.\d+")
45
+
46
+ #: One ``_DEPRECATED_CONSTANTS`` entry: ``(replacement, why)``, or a complete
47
+ #: notice string for a name with no replacement to point at.
48
+ DeprecatedName = tuple[str, str] | str
49
+
50
+
51
+ def _check_version(remove_in: str) -> None:
52
+ if not _VERSION_RE.fullmatch(remove_in):
53
+ raise ValueError(
54
+ f"remove_in must be a full major.minor.patch version such as "
55
+ f"'4.0.0', not {remove_in!r}"
56
+ )
57
+
58
+
59
+ def deprecation_message(
60
+ name: str, replacement: str, remove_in: str, *, note: str | None = None
61
+ ) -> str:
62
+ """The notice text :func:`warn_deprecated` emits.
63
+
64
+ Args:
65
+ name: What is deprecated, as the caller wrote it.
66
+ replacement: What to use instead.
67
+ remove_in: The release that removes it, as ``major.minor.patch``.
68
+ note: Why, or what changes; appended after the replacement.
69
+
70
+ Raises:
71
+ ValueError: *remove_in* is not a ``major.minor.patch`` version.
72
+ """
73
+ _check_version(remove_in)
74
+ why = f" — {note.rstrip(' .')}" if note else ""
75
+ return (
76
+ f"{name} is deprecated; use {replacement} instead{why}. "
77
+ f"Will be removed in v{remove_in}."
78
+ )
79
+
80
+
81
+ def _emit(message: str, stacklevel: int) -> None:
82
+ # The notice is graded where warn_deprecated / deprecated_module_getattr is
83
+ # called with literals; this call only forwards it.
84
+ # conformance: ignore[B002] forwards a notice graded at its call site
85
+ warnings.warn(message, DeprecationWarning, stacklevel=stacklevel + 1)
86
+
87
+
88
+ def warn_deprecated(
89
+ name: str,
90
+ replacement: str,
91
+ remove_in: str,
92
+ *,
93
+ note: str | None = None,
94
+ stacklevel: int = 2,
95
+ ) -> None:
96
+ """Emit a ``DeprecationWarning`` in the SDK's one notice format.
97
+
98
+ *stacklevel* means what it means to :func:`warnings.warn` called from the
99
+ same place: the default ``2`` points at the caller of the function that
100
+ calls this.
101
+
102
+ Raises:
103
+ ValueError: *remove_in* is not a ``major.minor.patch`` version.
104
+ """
105
+ _emit(deprecation_message(name, replacement, remove_in, note=note), stacklevel + 1)
106
+
107
+
108
+ def _import_dotted(path: str) -> object:
109
+ """Resolve ``package.module.Attr[.attr]`` by importing the longest module prefix."""
110
+ parts = path.split(".")
111
+ for split in range(len(parts) - 1, 0, -1):
112
+ candidate = ".".join(parts[:split])
113
+ try:
114
+ target: object = importlib.import_module(candidate)
115
+ except ModuleNotFoundError as exc:
116
+ # Only the candidate (or a package above it) being absent means
117
+ # "try a shorter prefix"; a missing dependency of a module that
118
+ # exists is the real error.
119
+ if exc.name is None or not (
120
+ candidate == exc.name or candidate.startswith(exc.name + ".")
121
+ ):
122
+ raise
123
+ continue
124
+ for attr in parts[split:]:
125
+ target = getattr(target, attr)
126
+ return target
127
+ raise ImportError(f"cannot resolve {path!r} to an importable object")
128
+
129
+
130
+ def lazy_resolver(lazy: Mapping[str, tuple[str, str]]) -> Callable[[str], object]:
131
+ """A *resolve* for :func:`deprecated_module_getattr` that reads a ``_LAZY`` map.
132
+
133
+ *lazy* maps each name to ``(module, attribute)``; the module is imported on
134
+ first access, so serving a deprecated name costs nothing until it is used.
135
+ """
136
+
137
+ def resolve(name: str) -> object:
138
+ module, attr = lazy[name]
139
+ return getattr(importlib.import_module(module), attr)
140
+
141
+ return resolve
142
+
143
+
144
+ def deprecated_module_getattr(
145
+ module: str,
146
+ table: Mapping[str, DeprecatedName],
147
+ *,
148
+ remove_in: str,
149
+ resolve: Callable[[str], object] | None = None,
150
+ fallback: Callable[[str], object] | None = None,
151
+ ) -> Callable[[str], object]:
152
+ """Build a module ``__getattr__`` (PEP 562) that serves deprecated names.
153
+
154
+ Use it as ``__getattr__ = deprecated_module_getattr(__name__,
155
+ _DEPRECATED_CONSTANTS, remove_in="4.0.0")``. Each access to a name in
156
+ *table* warns at the caller's line and returns the value. A real binding of
157
+ the same name at module scope would resolve first and never warn, so do not
158
+ keep one.
159
+
160
+ Args:
161
+ module: The module's ``__name__``, for the ``AttributeError`` message.
162
+ table: ``_DEPRECATED_CONSTANTS``. A ``(replacement, why)`` entry is
163
+ formatted by :func:`deprecation_message`. A string entry is the
164
+ complete notice, for a name with nothing to replace it; it starts
165
+ with the name, and is emitted qualified by *module*.
166
+ remove_in: The release that removes every name in *table*.
167
+ resolve: Returns the value for a name. Defaults to importing the
168
+ entry's replacement as a dotted path, which fits a name that moved.
169
+ fallback: Called for a name not in *table*, for a module whose
170
+ ``__getattr__`` also serves lazy imports. Without one, such a
171
+ name raises ``AttributeError``.
172
+
173
+ Raises:
174
+ ValueError: *remove_in* is not a ``major.minor.patch`` version.
175
+ """
176
+ _check_version(remove_in)
177
+
178
+ def __getattr__(name: str) -> object:
179
+ entry = table.get(name)
180
+ if entry is None:
181
+ if fallback is not None:
182
+ return fallback(name)
183
+ raise AttributeError(f"module {module!r} has no attribute {name!r}")
184
+ if isinstance(entry, str):
185
+ _emit(f"{module}.{entry}", 2)
186
+ if resolve is None:
187
+ raise AssertionError(f"{module}.{name} has no resolver")
188
+ return resolve(name)
189
+ replacement, note = entry
190
+ _emit(deprecation_message(name, replacement, remove_in, note=note), 2)
191
+ if resolve is not None:
192
+ return resolve(name)
193
+ return _import_dotted(replacement)
194
+
195
+ return __getattr__
@@ -23,12 +23,19 @@ logging is not configured yet. A caller that runs after logging is up passes
23
23
  ``report`` to route the message to its logger instead;
24
24
  :mod:`application_sdk.common._env` does that for SDK modules that can import the
25
25
  logger.
26
+
27
+ A warning alone would bypass OTel, and Python shows each one once per process.
28
+ So every default-path message is also handed to the SDK logger: the logger
29
+ module installs itself with :func:`set_log_sink` once it exists, and the
30
+ messages from before that (``constants``' import-time reads) are held until
31
+ then and logged in order.
26
32
  """
27
33
 
28
34
  from __future__ import annotations
29
35
 
30
36
  import math
31
37
  import os
38
+ import threading
32
39
  import warnings
33
40
  from collections.abc import Callable, Collection
34
41
 
@@ -50,6 +57,48 @@ def _raw(key: str) -> str | None:
50
57
  return stripped or None
51
58
 
52
59
 
60
+ #: Default-path messages from before :func:`set_log_sink` ran, oldest first.
61
+ _pending: list[str] = []
62
+ _log_sink: Reporter | None = None
63
+ #: Held while reading the sink and holding a message, and while installing the
64
+ #: sink and draining, so a message held during installation is still drained.
65
+ _sink_lock = threading.Lock()
66
+
67
+
68
+ def set_log_sink(sink: Reporter) -> None:
69
+ """Log every default-path rejection through *sink*, starting with the held ones.
70
+
71
+ Called once by the SDK logger module when it is imported, so a malformed
72
+ value read while ``constants`` was importing still reaches the logs.
73
+ """
74
+ global _log_sink
75
+ with _sink_lock:
76
+ _log_sink = sink
77
+ held = list(_pending)
78
+ _pending.clear()
79
+ for message in held:
80
+ sink(message)
81
+
82
+
83
+ def _to_log(message: str) -> None:
84
+ with _sink_lock:
85
+ sink = _log_sink
86
+ if sink is None:
87
+ _pending.append(message)
88
+ return
89
+ sink(message)
90
+
91
+
92
+ def warn_rejected(message: str, category: type[Warning] = RuntimeWarning) -> None:
93
+ """Report a rejected setting the way the ``env_*`` readers do.
94
+
95
+ For a module that parses a value itself: warns at the caller's caller (as
96
+ ``warnings.warn(stacklevel=2)`` from the caller would) and logs it.
97
+ """
98
+ warnings.warn(message, category, stacklevel=3)
99
+ _to_log(message)
100
+
101
+
53
102
  def _reject(message: str, report: Reporter | None) -> None:
54
103
  if report is not None:
55
104
  report(message)
@@ -57,6 +106,7 @@ def _reject(message: str, report: Reporter | None) -> None:
57
106
  # stacklevel 3: point at the line that called env_int/env_float/..., not
58
107
  # at this helper or the env_* function itself.
59
108
  warnings.warn(message, RuntimeWarning, stacklevel=3)
109
+ _to_log(message)
60
110
 
61
111
 
62
112
  def env_int(
@@ -101,7 +101,7 @@ def _default_user_agent() -> str:
101
101
  module into circular-import paths during package init.
102
102
  """
103
103
  try:
104
- from application_sdk.version import ( # type: ignore[import] # noqa: PLC0415
104
+ from application_sdk.version import ( # noqa: PLC0415
105
105
  __version__,
106
106
  )
107
107
 
@@ -236,7 +236,7 @@ def make_s3_store(
236
236
  )
237
237
  if credential_provider is not None:
238
238
  kw["credential_provider"] = credential_provider
239
- return S3Store(**kw) # type: ignore[arg-type]
239
+ return S3Store(**kw) # pyright: ignore[reportArgumentType]
240
240
 
241
241
 
242
242
  # obstore-rs reads ``AZURE_*`` from the environment at AzureStore construction
@@ -335,7 +335,7 @@ def make_azure_store(
335
335
  _azure_config_has_explicit_credential(config) or credential_provider is not None
336
336
  )
337
337
  with _suppress_ambient_azure_env(isolate):
338
- return AzureStore(**kw) # type: ignore[arg-type]
338
+ return AzureStore(**kw) # pyright: ignore[reportArgumentType]
339
339
 
340
340
 
341
341
  def make_gcs_store(
@@ -365,7 +365,7 @@ def make_gcs_store(
365
365
  )
366
366
  if credential_provider is not None:
367
367
  kw["credential_provider"] = credential_provider
368
- return GCSStore(**kw) # type: ignore[arg-type]
368
+ return GCSStore(**kw) # pyright: ignore[reportArgumentType]
369
369
 
370
370
 
371
371
  def log_obstore_config(
@@ -77,7 +77,7 @@ def cpu_quota_cores(cpu_max_v2: str, quota_v1: str, period_v1: str) -> float | N
77
77
  def _affinity_count() -> int:
78
78
  """CPUs in this process's affinity mask, or the node's count without one."""
79
79
  try:
80
- return len(os.sched_getaffinity(0)) or 1 # type: ignore[attr-defined]
80
+ return len(os.sched_getaffinity(0)) or 1
81
81
  except AttributeError:
82
82
  # No affinity API (macOS, Windows): the node's count is all there is.
83
83
  return os.cpu_count() or 1
@@ -239,7 +239,7 @@ class CancelHandle:
239
239
  if not self._requested and self._action is action:
240
240
  self._action = previous
241
241
  if fire_previous:
242
- _fire_cancel_action(previous) # type: ignore[arg-type]
242
+ _fire_cancel_action(previous) # pyright: ignore[reportArgumentType]
243
243
 
244
244
  def request(self) -> None:
245
245
  """Request a cancel: fire the registered action, if any, at most once.
@@ -762,7 +762,11 @@ def _ensure_stranded_gauge() -> None:
762
762
  _INSTRUMENTS["stranded"] = None
763
763
  except Exception:
764
764
  _INSTRUMENTS["stranded"] = None
765
- logger.debug("Could not register offload.stranded_threads", exc_info=True)
765
+ logger.warning(
766
+ "Could not register offload.stranded_threads; stranded "
767
+ "run_in_thread calls will be logged but not gauged",
768
+ exc_info=True,
769
+ )
766
770
 
767
771
 
768
772
  def _on_offload_done(slot: _OffloadSlot) -> None:
@@ -1686,7 +1690,7 @@ async def run_best_effort(
1686
1690
  timeout,
1687
1691
  exc_info=True,
1688
1692
  )
1689
- except Exception: # noqa: BLE001 — best-effort work must never break the caller
1693
+ except Exception: # best-effort work must never break the caller
1690
1694
  logger.warning("%s skipped due to an unexpected error", label, exc_info=True)
1691
1695
  return None
1692
1696
 
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ import urllib.request
2
3
  import warnings
3
4
  from typing import Any, Literal, overload
4
5
 
@@ -12,6 +13,7 @@ from httpx._types import (
12
13
  RequestFiles,
13
14
  )
14
15
 
16
+ from application_sdk import _deprecation
15
17
  from application_sdk._logging import get_logger
16
18
  from application_sdk.clients._interface import ClientInterface
17
19
  from application_sdk.clients.http_errors import HttpClientSourceUnavailableError
@@ -56,6 +58,86 @@ class _SharedTransport(httpx.AsyncBaseTransport):
56
58
  return None
57
59
 
58
60
 
61
+ class _EnvProxyHTTPTransport(httpx.AsyncHTTPTransport):
62
+ """``AsyncHTTPTransport`` that applies the environment's proxy settings.
63
+
64
+ httpx only honors ``HTTP(S)_PROXY`` / ``ALL_PROXY`` / ``NO_PROXY`` when the
65
+ client builds its own transport (``allow_env_proxies = trust_env and
66
+ transport is None``). ``BaseClient`` always passes ``transport=``, so
67
+ without this every request connects directly, and on hosts whose egress
68
+ is proxy-only it times out with no HTTP response.
69
+
70
+ The proxy is chosen per request URL: hosts matching ``NO_PROXY`` (and
71
+ every request when no proxy is configured) go through this transport's
72
+ own pool, others through a lazily created proxied transport built with
73
+ the same keyword arguments (TLS context, pool limits, connect retries).
74
+ Proxy settings are read once, at construction, as httpx does.
75
+ """
76
+
77
+ def __init__(self, **kwargs: Any) -> None:
78
+ super().__init__(**kwargs)
79
+ self._transport_kwargs = kwargs
80
+ self._env_proxies = urllib.request.getproxies_environment()
81
+ self._proxied: dict[str, httpx.AsyncBaseTransport] = {}
82
+
83
+ def _proxy_for(self, url: httpx.URL) -> str | None:
84
+ proxy = self._env_proxies.get(url.scheme) or self._env_proxies.get("all")
85
+ if not proxy or not url.host:
86
+ return None
87
+ # Stdlib NO_PROXY matcher (suffix, exact host, "*"); missing from typeshed.
88
+ if urllib.request.proxy_bypass_environment( # pyright: ignore[reportAttributeAccessIssue]
89
+ url.host, self._env_proxies
90
+ ):
91
+ return None
92
+ return proxy
93
+
94
+ async def handle_async_request(self, request: httpx.Request) -> httpx.Response:
95
+ proxy = self._proxy_for(request.url)
96
+ if proxy is None:
97
+ return await super().handle_async_request(request)
98
+ transport = self._proxied.get(proxy)
99
+ if transport is None:
100
+ transport = self._make_proxied_transport(proxy)
101
+ self._proxied[proxy] = transport
102
+ return await transport.handle_async_request(request)
103
+
104
+ def _make_proxied_transport(self, proxy: str) -> httpx.AsyncBaseTransport:
105
+ return httpx.AsyncHTTPTransport(**self._transport_kwargs, proxy=proxy)
106
+
107
+ async def _close_proxied(self) -> BaseException | None:
108
+ """Close every proxied pool, even when one close raises or is cancelled.
109
+
110
+ The owning ``BaseClient`` drops its reference before closing, so a pool
111
+ skipped here would never be closed. Returns the first failure for the
112
+ caller to raise once the direct pool is closed too.
113
+ """
114
+ proxied, self._proxied = list(self._proxied.values()), {}
115
+ first_error: BaseException | None = None
116
+ for transport in proxied:
117
+ try:
118
+ await transport.aclose()
119
+ except BaseException as exc: # noqa: BLE001 — includes CancelledError; the first close error is returned to __aexit__, which re-raises it
120
+ if first_error is None:
121
+ first_error = exc
122
+ return first_error
123
+
124
+ async def __aexit__(self, *args: Any) -> None:
125
+ error = await self._close_proxied()
126
+ try:
127
+ await super().__aexit__(*args)
128
+ finally:
129
+ if error is not None:
130
+ raise error
131
+
132
+ async def aclose(self) -> None:
133
+ error = await self._close_proxied()
134
+ try:
135
+ await super().aclose()
136
+ finally:
137
+ if error is not None:
138
+ raise error
139
+
140
+
59
141
  class BaseClient(ClientInterface):
60
142
  """
61
143
  Base client for non-SQL based applications.
@@ -161,7 +243,9 @@ class BaseClient(ClientInterface):
161
243
  # TLS verification lives on the transport: httpx ignores
162
244
  # ``AsyncClient(verify=...)`` whenever ``transport=`` is also passed,
163
245
  # so the SDK context (default CAs plus SSL_CERT_DIR) must be set here.
164
- self.http_retry_transport: httpx.AsyncBaseTransport = httpx.AsyncHTTPTransport(
246
+ # Passing ``transport=`` also disables httpx's env-proxy handling, so
247
+ # the default transport applies HTTP(S)_PROXY / NO_PROXY itself.
248
+ self.http_retry_transport: httpx.AsyncBaseTransport = _EnvProxyHTTPTransport(
165
249
  verify=get_ssl_context(),
166
250
  limits=_HTTP_POOL_LIMITS,
167
251
  retries=_HTTP_CONNECT_RETRIES,
@@ -373,7 +457,7 @@ class BaseClient(ClientInterface):
373
457
  auth=auth if auth is not None else httpx.USE_CLIENT_DEFAULT,
374
458
  )
375
459
  return response
376
- except Exception as exc: # conformance: ignore[E004] _request_failed logs with exc_info or raises typed
460
+ except Exception as exc: # noqa: BLE001 — _request_failed logs with exc_info or raises typed
377
461
  # conformance: ignore[E007] deprecated None-on-failure contract until v4.0
378
462
  return _request_failed("GET", url, exc, raise_on_error)
379
463
 
@@ -514,7 +598,7 @@ class BaseClient(ClientInterface):
514
598
  follow_redirects=follow_redirects,
515
599
  )
516
600
  return response
517
- except Exception as exc: # conformance: ignore[E004] _request_failed logs with exc_info or raises typed
601
+ except Exception as exc: # noqa: BLE001 — _request_failed logs with exc_info or raises typed
518
602
  # conformance: ignore[E007] deprecated None-on-failure contract until v4.0
519
603
  return _request_failed("POST", url, exc, raise_on_error)
520
604
 
@@ -524,12 +608,13 @@ def _warn_if_raise_on_error_unset(
524
608
  ) -> None:
525
609
  """Warn a caller still relying on the deprecated ``None``-on-failure default."""
526
610
  if raise_on_error is None:
527
- warnings.warn(
528
- f"BaseClient.{method_name} returns None when a request fails unless "
529
- "raise_on_error=True is passed, which raises SourceUnavailableError "
530
- "instead. The default becomes raise_on_error=True in v4.0; pass "
531
- "raise_on_error=True (or False to keep None) explicitly.",
532
- DeprecationWarning,
611
+ _deprecation.warn_deprecated(
612
+ f"BaseClient.{method_name} without raise_on_error",
613
+ "raise_on_error=True, which raises SourceUnavailableError when a "
614
+ "request fails (or raise_on_error=False to keep None)",
615
+ "4.0.0",
616
+ note="it returns None when a request fails; the None default goes "
617
+ "and raise_on_error=True becomes the default",
533
618
  stacklevel=3,
534
619
  )
535
620
 
@@ -1328,7 +1328,7 @@ class BaseSQLClient(ClientInterface):
1328
1328
  async def get_batched_results(
1329
1329
  self,
1330
1330
  query: str,
1331
- ) -> AsyncIterator["pd.DataFrame"] | Iterator["pd.DataFrame"]: # type: ignore
1331
+ ) -> AsyncIterator["pd.DataFrame"] | Iterator["pd.DataFrame"]:
1332
1332
  """Get query results as batched pandas DataFrames asynchronously.
1333
1333
 
1334
1334
  The result is iterable both ways. ``async for frame in results`` reads