-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #30
base: master
Are you sure you want to change the base?
Conversation
encoded_list = [] | ||
for item in obj: | ||
encoded_list.append( | ||
jsonable_encoder( | ||
item, | ||
include=include, | ||
exclude=exclude, | ||
by_alias=by_alias, | ||
exclude_unset=exclude_unset, | ||
exclude_defaults=exclude_defaults, | ||
exclude_none=exclude_none, | ||
custom_encoder=custom_encoder, | ||
sqlalchemy_safe=sqlalchemy_safe, | ||
) | ||
return [ | ||
jsonable_encoder( | ||
item, | ||
include=include, | ||
exclude=exclude, | ||
by_alias=by_alias, | ||
exclude_unset=exclude_unset, | ||
exclude_defaults=exclude_defaults, | ||
exclude_none=exclude_none, | ||
custom_encoder=custom_encoder, | ||
sqlalchemy_safe=sqlalchemy_safe, | ||
) | ||
return encoded_list | ||
|
||
for item in obj | ||
] | ||
if custom_encoder: | ||
if type(obj) in custom_encoder: | ||
return custom_encoder[type(obj)](obj) | ||
else: | ||
for encoder_type, encoder in custom_encoder.items(): | ||
if isinstance(obj, encoder_type): | ||
return encoder(obj) | ||
for encoder_type, encoder in custom_encoder.items(): | ||
if isinstance(obj, encoder_type): | ||
return encoder(obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function jsonable_encoder
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
target = ".".join(err_loc_tree) | ||
return target | ||
return ".".join(err_loc_tree) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_validation_target
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
def with_params(self, params: BaseModel): | ||
return create_model("JsonRPC" + params.__name__, __base__=self, params=(params, ...)) | ||
def with_params(cls, params: BaseModel): | ||
return create_model( | ||
f"JsonRPC{params.__name__}", __base__=cls, params=(params, ...) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function JsonRPCRequest.with_params
refactored with the following changes:
- The first argument to class methods should be
cls
(class-method-first-arg-name
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
reply_name = "Reply_" + self.operation_id | ||
request_name = "Request_" + self.operation_id | ||
reply_name = f"Reply_{self.operation_id}" | ||
request_name = f"Request_{self.operation_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Request.__init__
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
reply_name = "Reply_" + self.operation_id | ||
reply_name = f"Reply_{self.operation_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Publish.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
schema = {} | ||
schema["range"] = {"upper": upper_bound, "lower": lower_bound} | ||
schema = {"range": {"upper": upper_bound, "lower": lower_bound}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function domain_errors_schema
refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign
)
info = {"title": title, "version": version} | ||
info["description"] = description if description else None | ||
info = { | ||
"title": title, | ||
"version": version, | ||
"description": description if description else None, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_asyncapi
refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign
) - Simplify sequence length comparison (
simplify-len-comparison
)
reply = JsonRPCReply.parse_raw(reply_raw.data) | ||
return reply | ||
return JsonRPCReply.parse_raw(reply_raw.data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function NatsClient.request
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
asyncio.create_task(self._handle_request(msg), name="natsapi_" + secrets.token_hex(16)) | ||
asyncio.create_task( | ||
self._handle_request(msg), name=f"natsapi_{secrets.token_hex(16)}" | ||
) | ||
else: | ||
asyncio.create_task(self._handle_publish(msg), name="natsapi_" + secrets.token_hex(16)) | ||
asyncio.create_task( | ||
self._handle_publish(msg), name=f"natsapi_{secrets.token_hex(16)}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function NatsClient.handle_request
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
for cls in type(exc).__mro__: | ||
if cls in self._exception_handlers: | ||
return self._exception_handlers[cls] | ||
return None | ||
return next( | ||
( | ||
self._exception_handlers[cls] | ||
for cls in type(exc).__mro__ | ||
if cls in self._exception_handlers | ||
), | ||
None, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function NatsClient._lookup_exception_handler
refactored with the following changes:
- Use the built-in function
next
instead of a for-loop (use-next
)
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!