otterapi 0.1.1__tar.gz → 0.1.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.
- {otterapi-0.1.1 → otterapi-0.1.2}/PKG-INFO +1 -1
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/codegen.py +5 -1
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/splitting.py +38 -10
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/config.py +9 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/.gitignore +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/README.md +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/__main__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/cli.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/_body_builder.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/_features.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/_openapi_adapter.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/ast_utils.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/client.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/dataframes.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/endpoints.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/export.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/pagination.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/runtime/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/runtime/_client_stub.py.tpl +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/runtime/_concurrency.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/runtime/_dataframe.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/runtime/_export.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/runtime/_models_mixin.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/runtime/_pagination.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/runtime/_retry.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/schema.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/types.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/codegen/utils.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/exceptions.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/constants.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v2/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v2/spec.json +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v2/v2.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v3/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v3/spec.json +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v3/v3.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v3_1/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v3_1/spec.json +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v3_1/v3_1.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v3_2/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v3_2/spec.json +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/v3_2/v3_2.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/openapi/warnings.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/fixtures/__init__.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/fixtures/golden/constraints/spec.yaml +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/fixtures/golden/dataframe/config.yaml +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/fixtures/golden/dataframe/spec.yaml +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/fixtures/golden/discriminator/spec.yaml +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/fixtures/golden/paginated/config.yaml +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/fixtures/golden/paginated/spec.yaml +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_ast_utils.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_body_builder.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_client_retry_lifecycle.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_codegen.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_codegen_structure.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_concurrency_runtime.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_config_errors.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_dataframe.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_discriminated_unions.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_exceptions.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_export.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_extra_forbid.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_feature_modules.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_html_repr.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_init_scaffold.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_not_schema.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_nullable_upgrade.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_openapi_adapter.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_openapi_support.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_openapi_upgrade.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_pagination.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_per_status_errors.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_public_api.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_regen_script.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_retry_runtime.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_runtime_guards.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_schema_constraints.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_smoke_generated_client.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_splitting_config.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_splitting_integration.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_splitting_resolver.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/otterapi/tests/test_splitting_tree.py +0 -0
- {otterapi-0.1.1 → otterapi-0.1.2}/pyproject.toml +0 -0
|
@@ -1276,7 +1276,10 @@ class Codegen(OpenAPIProcessor):
|
|
|
1276
1276
|
if type_checking_block:
|
|
1277
1277
|
final_body.append(type_checking_block)
|
|
1278
1278
|
|
|
1279
|
-
|
|
1279
|
+
all_names: set[str] = set(endpoint_names)
|
|
1280
|
+
if self.config.reexport_models:
|
|
1281
|
+
all_names |= import_collector._imports.get(MODELS_MODULE, set())
|
|
1282
|
+
final_body.append(_all(sorted(all_names)))
|
|
1280
1283
|
final_body.extend(body)
|
|
1281
1284
|
|
|
1282
1285
|
write_mod(final_body, path)
|
|
@@ -1580,6 +1583,7 @@ class Codegen(OpenAPIProcessor):
|
|
|
1580
1583
|
pagination_config=self.config.pagination,
|
|
1581
1584
|
response_unwrap_config=self.config.response_unwrap,
|
|
1582
1585
|
export_config=self.config.export,
|
|
1586
|
+
reexport_models=self.config.reexport_models,
|
|
1583
1587
|
)
|
|
1584
1588
|
|
|
1585
1589
|
emitted = emitter.emit(
|
|
@@ -607,6 +607,7 @@ class SplitModuleEmitter:
|
|
|
607
607
|
pagination_config: PaginationConfig | None = None,
|
|
608
608
|
response_unwrap_config: ResponseUnwrapConfig | None = None,
|
|
609
609
|
export_config: ExportConfig | None = None,
|
|
610
|
+
reexport_models: bool = False,
|
|
610
611
|
):
|
|
611
612
|
"""Initialize the split module emitter.
|
|
612
613
|
|
|
@@ -620,6 +621,7 @@ class SplitModuleEmitter:
|
|
|
620
621
|
pagination_config: Optional pagination configuration.
|
|
621
622
|
response_unwrap_config: Optional response unwrap configuration.
|
|
622
623
|
export_config: Optional export configuration.
|
|
624
|
+
reexport_models: Whether to include model names in __all__.
|
|
623
625
|
"""
|
|
624
626
|
self.config = config
|
|
625
627
|
self.output_dir = UPath(output_dir)
|
|
@@ -630,6 +632,7 @@ class SplitModuleEmitter:
|
|
|
630
632
|
self.pagination_config = pagination_config
|
|
631
633
|
self.response_unwrap_config = response_unwrap_config
|
|
632
634
|
self.export_config = export_config
|
|
635
|
+
self.reexport_models = reexport_models
|
|
633
636
|
self._emitted_modules: list[EmittedModule] = []
|
|
634
637
|
self._typegen_types: dict[str, Type] = {}
|
|
635
638
|
|
|
@@ -1050,7 +1053,11 @@ class SplitModuleEmitter:
|
|
|
1050
1053
|
endpoint_names: list[str],
|
|
1051
1054
|
) -> bool:
|
|
1052
1055
|
"""Emit sync+async export wrappers around the paginated ``_iter`` fns."""
|
|
1053
|
-
if
|
|
1056
|
+
if (
|
|
1057
|
+
not self.export_config
|
|
1058
|
+
or not self.export_config.enabled
|
|
1059
|
+
or item_type_ast is None
|
|
1060
|
+
):
|
|
1054
1061
|
return False
|
|
1055
1062
|
should_generate, formats, _path = (
|
|
1056
1063
|
self.export_config.should_generate_for_endpoint(
|
|
@@ -1070,7 +1077,9 @@ class SplitModuleEmitter:
|
|
|
1070
1077
|
):
|
|
1071
1078
|
fn, imports = build_standalone_paginated_export_fn(
|
|
1072
1079
|
fn_name=fn_name,
|
|
1073
|
-
target_iter_fn_name=f'{endpoint.sync_fn_name}_iter'
|
|
1080
|
+
target_iter_fn_name=f'{endpoint.sync_fn_name}_iter'
|
|
1081
|
+
if not is_async
|
|
1082
|
+
else f'{endpoint.async_fn_name}_iter',
|
|
1074
1083
|
parameters=endpoint.parameters,
|
|
1075
1084
|
request_body_info=endpoint.request_body,
|
|
1076
1085
|
item_type_ast=item_type_ast,
|
|
@@ -1116,7 +1125,9 @@ class SplitModuleEmitter:
|
|
|
1116
1125
|
):
|
|
1117
1126
|
fn, imports = build_standalone_export_fn(
|
|
1118
1127
|
fn_name=fn_name,
|
|
1119
|
-
target_fn_name=endpoint.sync_fn_name
|
|
1128
|
+
target_fn_name=endpoint.sync_fn_name
|
|
1129
|
+
if not is_async
|
|
1130
|
+
else endpoint.async_fn_name,
|
|
1120
1131
|
parameters=endpoint.parameters,
|
|
1121
1132
|
request_body_info=endpoint.request_body,
|
|
1122
1133
|
item_type_ast=item_type_ast,
|
|
@@ -1158,8 +1169,12 @@ class SplitModuleEmitter:
|
|
|
1158
1169
|
endpoint, pag_config.data_path
|
|
1159
1170
|
)
|
|
1160
1171
|
has_export_methods = self._emit_paginated_export_pair(
|
|
1161
|
-
endpoint,
|
|
1162
|
-
|
|
1172
|
+
endpoint,
|
|
1173
|
+
item_type_ast,
|
|
1174
|
+
item_type_imports,
|
|
1175
|
+
body,
|
|
1176
|
+
import_collector,
|
|
1177
|
+
endpoint_names,
|
|
1163
1178
|
)
|
|
1164
1179
|
else:
|
|
1165
1180
|
generated_paginated_df = False
|
|
@@ -1168,7 +1183,10 @@ class SplitModuleEmitter:
|
|
|
1168
1183
|
)
|
|
1169
1184
|
# Export for non-paginated endpoints
|
|
1170
1185
|
has_export_methods = self._emit_standalone_export_pair(
|
|
1171
|
-
endpoint,
|
|
1186
|
+
endpoint,
|
|
1187
|
+
body,
|
|
1188
|
+
import_collector,
|
|
1189
|
+
endpoint_names,
|
|
1172
1190
|
)
|
|
1173
1191
|
|
|
1174
1192
|
has_dataframe_methods = generated_paginated_df
|
|
@@ -1259,15 +1277,20 @@ class SplitModuleEmitter:
|
|
|
1259
1277
|
endpoint_names: list[str] = []
|
|
1260
1278
|
|
|
1261
1279
|
for endpoint in endpoints:
|
|
1262
|
-
endpoint_has_df, endpoint_has_pagination, endpoint_has_export =
|
|
1263
|
-
|
|
1280
|
+
endpoint_has_df, endpoint_has_pagination, endpoint_has_export = (
|
|
1281
|
+
self._emit_endpoint_functions(
|
|
1282
|
+
endpoint, body, import_collector, endpoint_names
|
|
1283
|
+
)
|
|
1264
1284
|
)
|
|
1265
1285
|
has_dataframe_methods = has_dataframe_methods or endpoint_has_df
|
|
1266
1286
|
has_pagination_methods = has_pagination_methods or endpoint_has_pagination
|
|
1267
1287
|
has_export_methods = has_export_methods or endpoint_has_export
|
|
1268
1288
|
|
|
1269
1289
|
type_checking_block = self._collect_module_file_imports(
|
|
1270
|
-
import_collector,
|
|
1290
|
+
import_collector,
|
|
1291
|
+
endpoints,
|
|
1292
|
+
has_dataframe_methods,
|
|
1293
|
+
has_pagination_methods,
|
|
1271
1294
|
has_export_methods,
|
|
1272
1295
|
)
|
|
1273
1296
|
|
|
@@ -1277,7 +1300,12 @@ class SplitModuleEmitter:
|
|
|
1277
1300
|
if type_checking_block:
|
|
1278
1301
|
final_body.append(type_checking_block)
|
|
1279
1302
|
|
|
1280
|
-
|
|
1303
|
+
all_names = list(endpoint_names)
|
|
1304
|
+
if self.reexport_models:
|
|
1305
|
+
model_names = sorted(import_collector._imports.get(MODELS_MODULE, set()))
|
|
1306
|
+
all_names = sorted(set(all_names) | set(model_names))
|
|
1307
|
+
|
|
1308
|
+
final_body.append(_all(sorted(all_names)))
|
|
1281
1309
|
final_body.extend(body)
|
|
1282
1310
|
|
|
1283
1311
|
file_path = UPath(file_path)
|
|
@@ -1003,6 +1003,15 @@ class DocumentConfig(BaseModel):
|
|
|
1003
1003
|
None, description='Optional name for a generated client class.'
|
|
1004
1004
|
)
|
|
1005
1005
|
|
|
1006
|
+
reexport_models: bool = Field(
|
|
1007
|
+
default=False,
|
|
1008
|
+
description=(
|
|
1009
|
+
'When True, all Pydantic models used in an endpoint module are '
|
|
1010
|
+
"added to that module's ``__all__``, making them importable directly "
|
|
1011
|
+
'from the endpoint module instead of only from the models module.'
|
|
1012
|
+
),
|
|
1013
|
+
)
|
|
1014
|
+
|
|
1006
1015
|
module_split: ModuleSplitConfig = Field(
|
|
1007
1016
|
default_factory=ModuleSplitConfig,
|
|
1008
1017
|
description='Configuration for splitting endpoints into submodules.',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|