clear-skies 2.0.0__py3-none-any.whl → 2.0.2__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 clear-skies might be problematic. Click here for more details.

Files changed (78) hide show
  1. {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/METADATA +2 -2
  2. {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/RECORD +78 -77
  3. clearskies/__init__.py +5 -8
  4. clearskies/authentication/authentication.py +4 -0
  5. clearskies/authentication/authorization.py +4 -0
  6. clearskies/authentication/jwks.py +8 -3
  7. clearskies/authentication/secret_bearer.py +3 -3
  8. clearskies/backends/api_backend.py +2 -2
  9. clearskies/backends/backend.py +13 -0
  10. clearskies/backends/secrets_backend.py +0 -1
  11. clearskies/column.py +9 -8
  12. clearskies/columns/audit.py +3 -2
  13. clearskies/columns/belongs_to_id.py +2 -2
  14. clearskies/columns/belongs_to_model.py +6 -2
  15. clearskies/columns/belongs_to_self.py +2 -2
  16. clearskies/columns/boolean.py +6 -2
  17. clearskies/columns/category_tree.py +2 -2
  18. clearskies/columns/category_tree_children.py +2 -2
  19. clearskies/columns/created.py +3 -2
  20. clearskies/columns/created_by_authorization_data.py +2 -2
  21. clearskies/columns/created_by_header.py +2 -2
  22. clearskies/columns/created_by_ip.py +2 -2
  23. clearskies/columns/created_by_routing_data.py +3 -2
  24. clearskies/columns/created_by_user_agent.py +2 -2
  25. clearskies/columns/date.py +6 -2
  26. clearskies/columns/datetime.py +6 -2
  27. clearskies/columns/float.py +6 -2
  28. clearskies/columns/has_many.py +2 -2
  29. clearskies/columns/has_many_self.py +2 -2
  30. clearskies/columns/integer.py +6 -2
  31. clearskies/columns/json.py +6 -2
  32. clearskies/columns/many_to_many_ids.py +6 -2
  33. clearskies/columns/many_to_many_ids_with_data.py +6 -2
  34. clearskies/columns/many_to_many_models.py +6 -2
  35. clearskies/columns/many_to_many_pivots.py +3 -2
  36. clearskies/columns/phone.py +3 -2
  37. clearskies/columns/select.py +3 -2
  38. clearskies/columns/string.py +4 -0
  39. clearskies/columns/timestamp.py +6 -2
  40. clearskies/columns/updated.py +2 -2
  41. clearskies/columns/uuid.py +2 -2
  42. clearskies/configs/__init__.py +4 -1
  43. clearskies/configs/config.py +4 -1
  44. clearskies/configs/endpoint_list.py +28 -0
  45. clearskies/contexts/cli.py +4 -0
  46. clearskies/contexts/context.py +13 -0
  47. clearskies/contexts/wsgi.py +4 -0
  48. clearskies/contexts/wsgi_ref.py +4 -0
  49. clearskies/{parameters_to_properties.py → decorators.py} +2 -0
  50. clearskies/di/di.py +2 -2
  51. clearskies/di/injectable_properties.py +2 -2
  52. clearskies/endpoint.py +7 -6
  53. clearskies/endpoint_group.py +14 -1
  54. clearskies/endpoints/callable.py +5 -4
  55. clearskies/endpoints/create.py +1 -1
  56. clearskies/endpoints/delete.py +1 -1
  57. clearskies/endpoints/get.py +1 -1
  58. clearskies/endpoints/health_check.py +1 -1
  59. clearskies/endpoints/list.py +1 -1
  60. clearskies/endpoints/restful_api.py +2 -2
  61. clearskies/endpoints/simple_search.py +1 -1
  62. clearskies/endpoints/update.py +1 -1
  63. clearskies/model.py +1214 -64
  64. clearskies/query/query.py +4 -4
  65. clearskies/security_header.py +7 -0
  66. clearskies/security_headers/cache_control.py +2 -2
  67. clearskies/security_headers/cors.py +2 -2
  68. clearskies/security_headers/csp.py +2 -2
  69. clearskies/security_headers/hsts.py +2 -2
  70. clearskies/validator.py +12 -0
  71. clearskies/validators/after_column.py +2 -2
  72. clearskies/validators/in_the_future.py +1 -1
  73. clearskies/validators/in_the_past.py +1 -1
  74. clearskies/validators/required.py +0 -1
  75. clearskies/validators/timedelta.py +2 -2
  76. clearskies/validators/unique.py +0 -1
  77. {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/LICENSE +0 -0
  78. {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/WHEEL +0 -0
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Self, overload
4
4
 
5
- import clearskies.parameters_to_properties
5
+ import clearskies.decorators
6
6
  from clearskies import configs
7
7
  from clearskies.column import Column
8
8
  from clearskies.columns import CategoryTree
@@ -36,7 +36,7 @@ class CategoryTreeChildren(Column):
36
36
  is_searchable = configs.Boolean(default=False)
37
37
  _descriptor_config_map = None
38
38
 
39
- @clearskies.parameters_to_properties.parameters_to_properties
39
+ @clearskies.decorators.parameters_to_properties
40
40
  def __init__(
41
41
  self,
42
42
  category_tree_column_name: str,
@@ -3,9 +3,10 @@ from __future__ import annotations
3
3
  import datetime
4
4
  from typing import TYPE_CHECKING, Any
5
5
 
6
+ import clearskies.decorators
6
7
  import clearskies.di
7
8
  import clearskies.typing
8
- from clearskies import configs, parameters_to_properties # type: ignore
9
+ from clearskies import configs
9
10
  from clearskies.columns.datetime import Datetime
10
11
 
11
12
  if TYPE_CHECKING:
@@ -67,7 +68,7 @@ class Created(Datetime):
67
68
 
68
69
  now = clearskies.di.inject.Now()
69
70
 
70
- @parameters_to_properties.parameters_to_properties
71
+ @clearskies.decorators.parameters_to_properties
71
72
  def __init__(
72
73
  self,
73
74
  date_format: str = "%Y-%m-%d %H:%M:%S",
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Any
4
4
 
5
- import clearskies.parameters_to_properties
5
+ import clearskies.decorators
6
6
  import clearskies.typing
7
7
  from clearskies import configs
8
8
  from clearskies.columns.string import String
@@ -100,7 +100,7 @@ class CreatedByAuthorizationData(String):
100
100
 
101
101
  _allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
102
102
 
103
- @clearskies.parameters_to_properties.parameters_to_properties
103
+ @clearskies.decorators.parameters_to_properties
104
104
  def __init__(
105
105
  self,
106
106
  authorization_data_key_name: str,
@@ -1,4 +1,4 @@
1
- import clearskies.parameters_to_properties
1
+ import clearskies.decorators
2
2
  import clearskies.typing
3
3
  from clearskies import configs
4
4
  from clearskies.columns.string import String
@@ -83,7 +83,7 @@ class CreatedByHeader(String):
83
83
 
84
84
  _allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
85
85
 
86
- @clearskies.parameters_to_properties.parameters_to_properties
86
+ @clearskies.decorators.parameters_to_properties
87
87
  def __init__(
88
88
  self,
89
89
  header_name: str,
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Any
4
4
 
5
- import clearskies.parameters_to_properties
5
+ import clearskies.decorators
6
6
  import clearskies.typing
7
7
  from clearskies import configs
8
8
  from clearskies.columns.string import String
@@ -70,7 +70,7 @@ class CreatedByIp(String):
70
70
 
71
71
  _allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
72
72
 
73
- @clearskies.parameters_to_properties.parameters_to_properties
73
+ @clearskies.decorators.parameters_to_properties
74
74
  def __init__(
75
75
  self,
76
76
  is_readable: bool = True,
@@ -1,5 +1,6 @@
1
+ import clearskies.decorators
1
2
  import clearskies.typing
2
- from clearskies import configs, parameters_to_properties
3
+ from clearskies import configs
3
4
  from clearskies.columns.string import String
4
5
 
5
6
 
@@ -80,7 +81,7 @@ class CreatedByRoutingData(String):
80
81
 
81
82
  _allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
82
83
 
83
- @parameters_to_properties.parameters_to_properties
84
+ @clearskies.decorators.parameters_to_properties
84
85
  def __init__(
85
86
  self,
86
87
  routing_path_name: str,
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import datetime
4
4
  from typing import TYPE_CHECKING, Any
5
5
 
6
- import clearskies.parameters_to_properties
6
+ import clearskies.decorators
7
7
  import clearskies.typing
8
8
  from clearskies import configs
9
9
  from clearskies.columns.string import String
@@ -70,7 +70,7 @@ class CreatedByUserAgent(String):
70
70
 
71
71
  _allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
72
72
 
73
- @clearskies.parameters_to_properties.parameters_to_properties
73
+ @clearskies.decorators.parameters_to_properties
74
74
  def __init__(
75
75
  self,
76
76
  is_readable: bool = True,
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, Callable, Self, overload
5
5
 
6
6
  import dateparser # type: ignore
7
7
 
8
- import clearskies.parameters_to_properties
8
+ import clearskies.decorators
9
9
  import clearskies.typing
10
10
  from clearskies import configs
11
11
  from clearskies.autodoc.schema import Datetime as AutoDocDatetime
@@ -102,7 +102,7 @@ class Date(Datetime):
102
102
  auto_doc_class: type[AutoDocSchema] = AutoDocDatetime
103
103
  _descriptor_config_map = None
104
104
 
105
- @clearskies.parameters_to_properties.parameters_to_properties
105
+ @clearskies.decorators.parameters_to_properties
106
106
  def __init__(
107
107
  self,
108
108
  date_format: str = "%Y-%m-%d",
@@ -162,6 +162,10 @@ class Date(Datetime):
162
162
  return super().__get__(instance, cls)
163
163
 
164
164
  def __set__(self, instance, value: datetime.datetime | datetime.date) -> None:
165
+ # this makes sure we're initialized
166
+ if "name" not in self._config: # type: ignore
167
+ instance.get_columns()
168
+
165
169
  instance._next_data[self.name] = value
166
170
 
167
171
  def equals(self, value: str | datetime.datetime | datetime.date) -> Condition:
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, Callable, Self, overload
5
5
 
6
6
  import dateparser # type: ignore
7
7
 
8
- import clearskies.parameters_to_properties
8
+ import clearskies.decorators
9
9
  import clearskies.typing
10
10
  from clearskies import configs
11
11
  from clearskies.autodoc.schema import Datetime as AutoDocDatetime
@@ -127,7 +127,7 @@ class Datetime(Column):
127
127
  auto_doc_class: type[AutoDocSchema] = AutoDocDatetime
128
128
  _descriptor_config_map = None
129
129
 
130
- @clearskies.parameters_to_properties.parameters_to_properties
130
+ @clearskies.decorators.parameters_to_properties
131
131
  def __init__(
132
132
  self,
133
133
  date_format: str = "%Y-%m-%d %H:%M:%S",
@@ -204,6 +204,10 @@ class Datetime(Column):
204
204
  return super().__get__(instance, cls)
205
205
 
206
206
  def __set__(self, instance, value: datetime.datetime) -> None:
207
+ # this makes sure we're initialized
208
+ if "name" not in self._config: # type: ignore
209
+ instance.get_columns()
210
+
207
211
  instance._next_data[self.name] = value
208
212
 
209
213
  def equals(self, value: str | datetime.datetime) -> Condition:
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Callable, Self, overload
4
4
 
5
- import clearskies.parameters_to_properties
5
+ import clearskies.decorators
6
6
  import clearskies.typing
7
7
  from clearskies import configs
8
8
  from clearskies.autodoc.schema import Number as AutoDocNumber
@@ -75,7 +75,7 @@ class Float(Column):
75
75
  auto_doc_class: type[AutoDocSchema] = AutoDocNumber
76
76
  _descriptor_config_map = None
77
77
 
78
- @clearskies.parameters_to_properties.parameters_to_properties
78
+ @clearskies.decorators.parameters_to_properties
79
79
  def __init__(
80
80
  self,
81
81
  default: float | None = None,
@@ -106,6 +106,10 @@ class Float(Column):
106
106
  return super().__get__(instance, cls)
107
107
 
108
108
  def __set__(self, instance, value: float) -> None:
109
+ # this makes sure we're initialized
110
+ if "name" not in self._config: # type: ignore
111
+ instance.get_columns()
112
+
109
113
  instance._next_data[self.name] = float(value)
110
114
 
111
115
  def from_backend(self, value) -> float:
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Any, Self, overload
4
4
 
5
- import clearskies.parameters_to_properties
5
+ import clearskies.decorators
6
6
  import clearskies.typing
7
7
  from clearskies import configs
8
8
  from clearskies.autodoc.schema import Array as AutoDocArray
@@ -382,7 +382,7 @@ class HasMany(Column):
382
382
 
383
383
  input_output = InputOutput()
384
384
 
385
- @clearskies.parameters_to_properties.parameters_to_properties
385
+ @clearskies.decorators.parameters_to_properties
386
386
  def __init__(
387
387
  self,
388
388
  child_model_class,
@@ -1,5 +1,5 @@
1
+ import clearskies.decorators
1
2
  import clearskies.typing
2
- from clearskies import parameters_to_properties
3
3
  from clearskies.columns.has_many import HasMany
4
4
 
5
5
 
@@ -20,7 +20,7 @@ class HasManySelf(HasMany):
20
20
 
21
21
  _descriptor_config_map = None
22
22
 
23
- @parameters_to_properties.parameters_to_properties
23
+ @clearskies.decorators.parameters_to_properties
24
24
  def __init__(
25
25
  self,
26
26
  foreign_column_name: str | None = None,
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Callable, Self, overload
4
4
 
5
- import clearskies.parameters_to_properties
5
+ import clearskies.decorators
6
6
  import clearskies.typing
7
7
  from clearskies import configs
8
8
  from clearskies.autodoc.schema import Integer as AutoDocInteger
@@ -77,7 +77,7 @@ class Integer(Column):
77
77
 
78
78
  _descriptor_config_map = None
79
79
 
80
- @clearskies.parameters_to_properties.parameters_to_properties
80
+ @clearskies.decorators.parameters_to_properties
81
81
  def __init__(
82
82
  self,
83
83
  default: int | None = None,
@@ -113,6 +113,10 @@ class Integer(Column):
113
113
  return None if value is None else int(value)
114
114
 
115
115
  def __set__(self, instance, value: int) -> None:
116
+ # this makes sure we're initialized
117
+ if "name" not in self._config: # type: ignore
118
+ instance.get_columns()
119
+
116
120
  instance._next_data[self.name] = value
117
121
 
118
122
  def from_backend(self, value) -> int | None:
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import json
4
4
  from typing import TYPE_CHECKING, Any, Callable, Self, overload
5
5
 
6
- import clearskies.parameters_to_properties
6
+ import clearskies.decorators
7
7
  import clearskies.typing
8
8
  from clearskies import configs
9
9
  from clearskies.column import Column
@@ -72,7 +72,7 @@ class Json(Column):
72
72
  is_searchable = configs.Boolean(default=False)
73
73
  _descriptor_config_map = None
74
74
 
75
- @clearskies.parameters_to_properties.parameters_to_properties
75
+ @clearskies.decorators.parameters_to_properties
76
76
  def __init__(
77
77
  self,
78
78
  default: dict[str, Any] | None = None,
@@ -102,6 +102,10 @@ class Json(Column):
102
102
  return super().__get__(instance, cls)
103
103
 
104
104
  def __set__(self, instance, value: dict[str, Any]) -> None:
105
+ # this makes sure we're initialized
106
+ if "name" not in self._config: # type: ignore
107
+ instance.get_columns()
108
+
105
109
  instance._next_data[self.name] = value
106
110
 
107
111
  def from_backend(self, value) -> dict[str, Any] | list[Any] | None:
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  from collections import OrderedDict
4
4
  from typing import TYPE_CHECKING, Any, Callable, Self, overload
5
5
 
6
- import clearskies.parameters_to_properties
6
+ import clearskies.decorators
7
7
  import clearskies.typing
8
8
  from clearskies import configs
9
9
  from clearskies.autodoc.schema import Array as AutoDocArray
@@ -173,7 +173,7 @@ class ManyToManyIds(Column):
173
173
  is_searchable = configs.Boolean(default=False)
174
174
  _descriptor_config_map = None
175
175
 
176
- @clearskies.parameters_to_properties.parameters_to_properties
176
+ @clearskies.decorators.parameters_to_properties
177
177
  def __init__(
178
178
  self,
179
179
  related_model_class,
@@ -258,6 +258,10 @@ class ManyToManyIds(Column):
258
258
  return [getattr(model, related_id_column_name) for model in self.get_related_models(instance)]
259
259
 
260
260
  def __set__(self, instance, value: list[str | int]) -> None:
261
+ # this makes sure we're initialized
262
+ if "name" not in self._config: # type: ignore
263
+ instance.get_columns()
264
+
261
265
  instance._next_data[self.name] = value
262
266
 
263
267
  def get_related_models(self, model: Model) -> Model:
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Any, Callable, Self, overload
4
4
 
5
- import clearskies.parameters_to_properties
5
+ import clearskies.decorators
6
6
  import clearskies.typing
7
7
  from clearskies import configs
8
8
  from clearskies.columns.many_to_many_ids import ManyToManyIds
@@ -149,7 +149,7 @@ class ManyToManyIdsWithData(ManyToManyIds):
149
149
  setable = configs.ListAnyDictOrCallable(default=None) # type: ignore
150
150
  _descriptor_config_map = None
151
151
 
152
- @clearskies.parameters_to_properties.parameters_to_properties
152
+ @clearskies.decorators.parameters_to_properties
153
153
  def __init__(
154
154
  self,
155
155
  related_model_class,
@@ -187,6 +187,10 @@ class ManyToManyIdsWithData(ManyToManyIds):
187
187
  return super().__get__(instance, cls)
188
188
 
189
189
  def __set__(self, instance, value: list[dict[str, Any]]) -> None: # type: ignore
190
+ # this makes sure we're initialized
191
+ if "name" not in self._config: # type: ignore
192
+ instance.get_columns()
193
+
190
194
  instance._next_data[self.name] = value
191
195
 
192
196
  def post_save(self, data, model, id):
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  from collections import OrderedDict
4
4
  from typing import TYPE_CHECKING, Any, Callable, Self, overload
5
5
 
6
- import clearskies.parameters_to_properties
6
+ import clearskies.decorators
7
7
  import clearskies.typing
8
8
  from clearskies import configs
9
9
  from clearskies.autodoc.schema import Array as AutoDocArray
@@ -30,7 +30,7 @@ class ManyToManyModels(Column):
30
30
  is_searchable = configs.Boolean(default=False)
31
31
  _descriptor_config_map = None
32
32
 
33
- @clearskies.parameters_to_properties.parameters_to_properties
33
+ @clearskies.decorators.parameters_to_properties
34
34
  def __init__(
35
35
  self,
36
36
  many_to_many_column_name,
@@ -87,6 +87,10 @@ class ManyToManyModels(Column):
87
87
  return self.many_to_many_column.get_related_models(instance) # type: ignore
88
88
 
89
89
  def __set__(self, instance, value: Model | list[Model] | list[dict[str, Any]]) -> None:
90
+ # this makes sure we're initialized
91
+ if "name" not in self._config: # type: ignore
92
+ instance.get_columns()
93
+
90
94
  # we allow a list of models or a model, but if it's a model it may represent a single record or a query.
91
95
  # if it's a single record then we want to wrap it in a list so we can iterate over it.
92
96
  if hasattr(value, "_data") and value._data:
@@ -3,8 +3,9 @@ from __future__ import annotations
3
3
  from collections import OrderedDict
4
4
  from typing import TYPE_CHECKING, Any, Callable, Self, overload
5
5
 
6
+ import clearskies.decorators
6
7
  import clearskies.typing
7
- from clearskies import configs, parameters_to_properties # type: ignore
8
+ from clearskies import configs
8
9
  from clearskies.autodoc.schema import Array as AutoDocArray
9
10
  from clearskies.autodoc.schema import Object as AutoDocObject
10
11
  from clearskies.column import Column
@@ -30,7 +31,7 @@ class ManyToManyPivots(Column):
30
31
  is_searchable = configs.Boolean(default=False)
31
32
  _descriptor_config_map = None
32
33
 
33
- @parameters_to_properties.parameters_to_properties
34
+ @clearskies.decorators.parameters_to_properties
34
35
  def __init__(
35
36
  self,
36
37
  many_to_many_column_name,
@@ -1,8 +1,9 @@
1
1
  import re
2
2
  from typing import Any, Callable
3
3
 
4
+ import clearskies.decorators
4
5
  import clearskies.typing
5
- from clearskies import configs, parameters_to_properties
6
+ from clearskies import configs
6
7
  from clearskies.columns.string import String
7
8
 
8
9
 
@@ -98,7 +99,7 @@ class Phone(String):
98
99
  usa_only = configs.Boolean(default=True)
99
100
  _descriptor_config_map = None
100
101
 
101
- @parameters_to_properties.parameters_to_properties
102
+ @clearskies.decorators.parameters_to_properties
102
103
  def __init__(
103
104
  self,
104
105
  usa_only: bool = True,
@@ -1,7 +1,8 @@
1
1
  from typing import Callable
2
2
 
3
+ import clearskies.decorators
3
4
  import clearskies.typing
4
- from clearskies import configs, parameters_to_properties
5
+ from clearskies import configs
5
6
  from clearskies.columns.string import String
6
7
 
7
8
 
@@ -67,7 +68,7 @@ class Select(String):
67
68
  allowed_values = configs.StringList(required=True)
68
69
  _descriptor_config_map = None
69
70
 
70
- @parameters_to_properties.parameters_to_properties
71
+ @clearskies.decorators.parameters_to_properties
71
72
  def __init__(
72
73
  self,
73
74
  allowed_values: list[str],
@@ -92,6 +92,10 @@ class String(Column):
92
92
  return instance._transformed_data[self.name]
93
93
 
94
94
  def __set__(self, instance: Model, value: str) -> None:
95
+ # this makes sure we're initialized
96
+ if "name" not in self._config: # type: ignore
97
+ instance.get_columns()
98
+
95
99
  instance._next_data[self.name] = value
96
100
 
97
101
  def input_error_for_value(self, value: str, operator: str | None = None) -> str:
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import datetime
4
4
  from typing import TYPE_CHECKING, Any, Callable, Self, Type, overload
5
5
 
6
- import clearskies.parameters_to_properties
6
+ import clearskies.decorators
7
7
  import clearskies.typing
8
8
  from clearskies import configs
9
9
  from clearskies.columns.datetime import Datetime
@@ -76,7 +76,7 @@ class Timestamp(Datetime):
76
76
  include_microseconds = configs.Boolean(default=False)
77
77
  _descriptor_config_map = None
78
78
 
79
- @clearskies.parameters_to_properties.parameters_to_properties
79
+ @clearskies.decorators.parameters_to_properties
80
80
  def __init__(
81
81
  self,
82
82
  include_microseconds: bool = False,
@@ -148,6 +148,10 @@ class Timestamp(Datetime):
148
148
  return super().__get__(instance, cls)
149
149
 
150
150
  def __set__(self, instance, value: datetime.datetime) -> None:
151
+ # this makes sure we're initialized
152
+ if "name" not in self._config: # type: ignore
153
+ instance.get_columns()
154
+
151
155
  instance._next_data[self.name] = value
152
156
 
153
157
  def input_error_for_value(self, value: str, operator: str | None = None) -> str:
@@ -3,8 +3,8 @@ from __future__ import annotations
3
3
  import datetime
4
4
  from typing import TYPE_CHECKING, Any
5
5
 
6
+ import clearskies.decorators
6
7
  import clearskies.di
7
- import clearskies.parameters_to_properties
8
8
  import clearskies.typing
9
9
  from clearskies import configs
10
10
  from clearskies.columns.datetime import Datetime
@@ -85,7 +85,7 @@ class Updated(Datetime):
85
85
 
86
86
  now = clearskies.di.inject.Now()
87
87
 
88
- @clearskies.parameters_to_properties.parameters_to_properties
88
+ @clearskies.decorators.parameters_to_properties
89
89
  def __init__(
90
90
  self,
91
91
  in_utc: bool = True,
@@ -2,8 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Any
4
4
 
5
+ import clearskies.decorators
5
6
  import clearskies.di
6
- import clearskies.parameters_to_properties
7
7
  import clearskies.typing
8
8
  from clearskies import configs
9
9
  from clearskies.columns.string import String
@@ -65,7 +65,7 @@ class Uuid(String):
65
65
 
66
66
  uuid = clearskies.di.inject.Uuid()
67
67
 
68
- @clearskies.parameters_to_properties.parameters_to_properties
68
+ @clearskies.decorators.parameters_to_properties
69
69
  def __init__(
70
70
  self,
71
71
  is_readable: bool = True,
@@ -56,7 +56,7 @@ class MyConfigurableClass(configs.Configurable):
56
56
  age = configs.Integer(required=True)
57
57
  property_with_default = configs.String(default="some value")
58
58
 
59
- @clearskies.parameters_to_properties()
59
+ @clearskies.decorators()
60
60
  def __init__(self, name: str, age: int, optional: string = None):
61
61
  self.finalize_and_validate_configuration()
62
62
  ```
@@ -80,6 +80,7 @@ from .config import Config
80
80
  from .datetime import Datetime
81
81
  from .datetime_or_callable import DatetimeOrCallable
82
82
  from .endpoint import Endpoint
83
+ from .endpoint_list import EndpointList
83
84
  from .float import Float
84
85
  from .float_or_callable import FloatOrCallable
85
86
  from .integer import Integer
@@ -126,6 +127,8 @@ __all__ = [
126
127
  "Config",
127
128
  "Datetime",
128
129
  "DatetimeOrCallable",
130
+ "Endpoint",
131
+ "EndpointList",
129
132
  "Float",
130
133
  "FloatOrCallable",
131
134
  "Joins",
@@ -1,5 +1,8 @@
1
+ from typing import Any
2
+
3
+
1
4
  class Config:
2
- def __init__(self, required=False, default=None):
5
+ def __init__(self, required: bool = False, default: Any = None):
3
6
  self.required = required
4
7
  self.default = default
5
8
 
@@ -0,0 +1,28 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from clearskies.configs import config
6
+
7
+ if TYPE_CHECKING:
8
+ from clearskies.endpoint import Endpoint as EndpointBase
9
+
10
+
11
+ class EndpointList(config.Config):
12
+ def __set__(self, instance, value: list[EndpointBase]):
13
+ if not isinstance(value, list):
14
+ raise TypeError(
15
+ f"{error_prefix} attempt to set a value of type '{value.__class__.__name__}' to a parameter that requries a list of endpoints."
16
+ )
17
+ for index, item in enumerate(value):
18
+ if not hasattr(item, "top_level_authentication_and_authorization"):
19
+ error_prefix = self._error_prefix(instance)
20
+ raise TypeError(
21
+ f"{error_prefix} attempt to set a value of type '{item.__class__.__name__}' for item #{index+1} when all items in the list should be instances of clearskies.End."
22
+ )
23
+ instance._set_config(self, value)
24
+
25
+ def __get__(self, instance, parent) -> list[EndpointBase]:
26
+ if not instance:
27
+ return self # type: ignore
28
+ return instance._get_config(self)
@@ -3,5 +3,9 @@ from clearskies.input_outputs import Cli as CliInputOutput
3
3
 
4
4
 
5
5
  class Cli(Context):
6
+ """
7
+ Run an application via a CLI command
8
+ """
9
+
6
10
  def __call__(self): # type: ignore
7
11
  return self.execute_application(CliInputOutput())
@@ -15,8 +15,21 @@ if TYPE_CHECKING:
15
15
 
16
16
 
17
17
  class Context:
18
+ """
19
+ Context: a flexible way to connect applications to hosting strategies.
20
+ """
21
+
18
22
  di: Di = None # type: ignore
19
23
 
24
+ """
25
+ The application to execute.
26
+
27
+ This can be a callable, an endpoint, or an endpoint group. If passed a callable, the callable can request any
28
+ standard or defined dependencies and should return the desired response. It can also raise any exception from
29
+ clearskies.exceptions.
30
+ """
31
+ application: Callable | clearskies.endpoint.Endpoint | clearskies.endpoint_group.EndpointGroup = None # type: ignore
32
+
20
33
  def __init__(
21
34
  self,
22
35
  application: Callable | clearskies.endpoint.Endpoint | clearskies.endpoint_group.EndpointGroup,
@@ -12,5 +12,9 @@ from clearskies.input_outputs import Wsgi as WsgiInputOutput
12
12
 
13
13
 
14
14
  class Wsgi(Context):
15
+ """
16
+ Connect your application to a WSGI server.
17
+ """
18
+
15
19
  def __call__(self, env, start_response): # type: ignore
16
20
  return self.execute_application(WsgiInputOutput(env, start_response))
@@ -12,6 +12,10 @@ from clearskies.input_outputs import Wsgi as WsgiInputOutput
12
12
 
13
13
 
14
14
  class WsgiRef(Context):
15
+ """
16
+ Use a built in WSGI server (for development purposes only).
17
+ """
18
+
15
19
  port: int = 8080
16
20
 
17
21
  def __init__(
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  import inspect
2
4
 
3
5
  import wrapt # type: ignore