Skip to content

Commit

Permalink
format: refactor _get_error_fields_and_models
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiruha01 committed Jul 1, 2024
1 parent 24058d1 commit 028e8c3
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions pybotx_smartapp_rpc/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,27 @@ def _get_error_fields_and_models(
self,
errors: Optional[List[Type[RPCError]]],
) -> Tuple[dict, dict]:
errors_fields = {}
errors_models = {}
if errors:
errors_fields = {
error.__fields__["id"].default: {
"description": error.__doc__ or error.__fields__["reason"].default,
}
for error in errors
if error.__fields__["id"].default
}
errors_models = {
error.__fields__["id"].default: ModelField(
name=error.__name__,
type_=error,
class_validators=None,
model_config=BaseConfig,
)
for error in errors
if error.__fields__["id"].default
errors_fields: Dict[str, dict] = {}
errors_models: Dict[str, ModelField] = {}
if not errors:
return errors_fields, errors_models

errors_fields = {
error.__fields__["id"].default: {
"description": error.__doc__ or error.__fields__["reason"].default,
}
for error in errors
if error.__fields__["id"].default
}
errors_models = {
error.__fields__["id"].default: ModelField(
name=error.__name__,
type_=error,
class_validators=None,
model_config=BaseConfig,
)
for error in errors
if error.__fields__["id"].default
}

return errors_fields, errors_models

0 comments on commit 028e8c3

Please sign in to comment.