deeprails 1.0.0__py3-none-any.whl → 1.3.0__py3-none-any.whl

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.

Potentially problematic release.


This version of deeprails might be problematic. Click here for more details.

deeprails/__init__.py CHANGED
@@ -6,7 +6,6 @@ from . import types
6
6
  from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
7
7
  from ._utils import file_from_path
8
8
  from ._client import (
9
- ENVIRONMENTS,
10
9
  Client,
11
10
  Stream,
12
11
  Timeout,
@@ -74,7 +73,6 @@ __all__ = [
74
73
  "AsyncStream",
75
74
  "Deeprails",
76
75
  "AsyncDeeprails",
77
- "ENVIRONMENTS",
78
76
  "file_from_path",
79
77
  "BaseModel",
80
78
  "DEFAULT_TIMEOUT",
deeprails/_client.py CHANGED
@@ -3,8 +3,8 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import os
6
- from typing import Any, Dict, Mapping, cast
7
- from typing_extensions import Self, Literal, override
6
+ from typing import Any, Mapping
7
+ from typing_extensions import Self, override
8
8
 
9
9
  import httpx
10
10
 
@@ -21,7 +21,7 @@ from ._types import (
21
21
  )
22
22
  from ._utils import is_given, get_async_library
23
23
  from ._version import __version__
24
- from .resources import monitor, evaluate
24
+ from .resources import defend, monitor, evaluate
25
25
  from ._streaming import Stream as Stream, AsyncStream as AsyncStream
26
26
  from ._exceptions import APIStatusError, DeeprailsError
27
27
  from ._base_client import (
@@ -29,10 +29,8 @@ from ._base_client import (
29
29
  SyncAPIClient,
30
30
  AsyncAPIClient,
31
31
  )
32
- from .resources.defend import defend
33
32
 
34
33
  __all__ = [
35
- "ENVIRONMENTS",
36
34
  "Timeout",
37
35
  "Transport",
38
36
  "ProxiesTypes",
@@ -43,11 +41,6 @@ __all__ = [
43
41
  "AsyncClient",
44
42
  ]
45
43
 
46
- ENVIRONMENTS: Dict[str, str] = {
47
- "production": "https://api.deeprails.com",
48
- "environment_1": "https://dev-api.deeprails",
49
- }
50
-
51
44
 
52
45
  class Deeprails(SyncAPIClient):
53
46
  defend: defend.DefendResource
@@ -59,14 +52,11 @@ class Deeprails(SyncAPIClient):
59
52
  # client options
60
53
  api_key: str
61
54
 
62
- _environment: Literal["production", "environment_1"] | NotGiven
63
-
64
55
  def __init__(
65
56
  self,
66
57
  *,
67
58
  api_key: str | None = None,
68
- environment: Literal["production", "environment_1"] | NotGiven = not_given,
69
- base_url: str | httpx.URL | None | NotGiven = not_given,
59
+ base_url: str | httpx.URL | None = None,
70
60
  timeout: float | Timeout | None | NotGiven = not_given,
71
61
  max_retries: int = DEFAULT_MAX_RETRIES,
72
62
  default_headers: Mapping[str, str] | None = None,
@@ -97,31 +87,10 @@ class Deeprails(SyncAPIClient):
97
87
  )
98
88
  self.api_key = api_key
99
89
 
100
- self._environment = environment
101
-
102
- base_url_env = os.environ.get("DEEPRAILS_BASE_URL")
103
- if is_given(base_url) and base_url is not None:
104
- # cast required because mypy doesn't understand the type narrowing
105
- base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
106
- elif is_given(environment):
107
- if base_url_env and base_url is not None:
108
- raise ValueError(
109
- "Ambiguous URL; The `DEEPRAILS_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
110
- )
111
-
112
- try:
113
- base_url = ENVIRONMENTS[environment]
114
- except KeyError as exc:
115
- raise ValueError(f"Unknown environment: {environment}") from exc
116
- elif base_url_env is not None:
117
- base_url = base_url_env
118
- else:
119
- self._environment = environment = "production"
120
-
121
- try:
122
- base_url = ENVIRONMENTS[environment]
123
- except KeyError as exc:
124
- raise ValueError(f"Unknown environment: {environment}") from exc
90
+ if base_url is None:
91
+ base_url = os.environ.get("DEEPRAILS_BASE_URL")
92
+ if base_url is None:
93
+ base_url = f"https://api.deeprails.com"
125
94
 
126
95
  super().__init__(
127
96
  version=__version__,
@@ -164,7 +133,6 @@ class Deeprails(SyncAPIClient):
164
133
  self,
165
134
  *,
166
135
  api_key: str | None = None,
167
- environment: Literal["production", "environment_1"] | None = None,
168
136
  base_url: str | httpx.URL | None = None,
169
137
  timeout: float | Timeout | None | NotGiven = not_given,
170
138
  http_client: httpx.Client | None = None,
@@ -200,7 +168,6 @@ class Deeprails(SyncAPIClient):
200
168
  return self.__class__(
201
169
  api_key=api_key or self.api_key,
202
170
  base_url=base_url or self.base_url,
203
- environment=environment or self._environment,
204
171
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
205
172
  http_client=http_client,
206
173
  max_retries=max_retries if is_given(max_retries) else self.max_retries,
@@ -257,14 +224,11 @@ class AsyncDeeprails(AsyncAPIClient):
257
224
  # client options
258
225
  api_key: str
259
226
 
260
- _environment: Literal["production", "environment_1"] | NotGiven
261
-
262
227
  def __init__(
263
228
  self,
264
229
  *,
265
230
  api_key: str | None = None,
266
- environment: Literal["production", "environment_1"] | NotGiven = not_given,
267
- base_url: str | httpx.URL | None | NotGiven = not_given,
231
+ base_url: str | httpx.URL | None = None,
268
232
  timeout: float | Timeout | None | NotGiven = not_given,
269
233
  max_retries: int = DEFAULT_MAX_RETRIES,
270
234
  default_headers: Mapping[str, str] | None = None,
@@ -295,31 +259,10 @@ class AsyncDeeprails(AsyncAPIClient):
295
259
  )
296
260
  self.api_key = api_key
297
261
 
298
- self._environment = environment
299
-
300
- base_url_env = os.environ.get("DEEPRAILS_BASE_URL")
301
- if is_given(base_url) and base_url is not None:
302
- # cast required because mypy doesn't understand the type narrowing
303
- base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
304
- elif is_given(environment):
305
- if base_url_env and base_url is not None:
306
- raise ValueError(
307
- "Ambiguous URL; The `DEEPRAILS_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
308
- )
309
-
310
- try:
311
- base_url = ENVIRONMENTS[environment]
312
- except KeyError as exc:
313
- raise ValueError(f"Unknown environment: {environment}") from exc
314
- elif base_url_env is not None:
315
- base_url = base_url_env
316
- else:
317
- self._environment = environment = "production"
318
-
319
- try:
320
- base_url = ENVIRONMENTS[environment]
321
- except KeyError as exc:
322
- raise ValueError(f"Unknown environment: {environment}") from exc
262
+ if base_url is None:
263
+ base_url = os.environ.get("DEEPRAILS_BASE_URL")
264
+ if base_url is None:
265
+ base_url = f"https://api.deeprails.com"
323
266
 
324
267
  super().__init__(
325
268
  version=__version__,
@@ -362,7 +305,6 @@ class AsyncDeeprails(AsyncAPIClient):
362
305
  self,
363
306
  *,
364
307
  api_key: str | None = None,
365
- environment: Literal["production", "environment_1"] | None = None,
366
308
  base_url: str | httpx.URL | None = None,
367
309
  timeout: float | Timeout | None | NotGiven = not_given,
368
310
  http_client: httpx.AsyncClient | None = None,
@@ -398,7 +340,6 @@ class AsyncDeeprails(AsyncAPIClient):
398
340
  return self.__class__(
399
341
  api_key=api_key or self.api_key,
400
342
  base_url=base_url or self.base_url,
401
- environment=environment or self._environment,
402
343
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
403
344
  http_client=http_client,
404
345
  max_retries=max_retries if is_given(max_retries) else self.max_retries,
deeprails/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "deeprails"
4
- __version__ = "1.0.0" # x-release-please-version
4
+ __version__ = "1.3.0" # x-release-please-version