Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jul 11, 2023

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from sevaho July 11, 2023 17:33
Comment on lines -97 to +116
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)
Copy link
Author

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:

target = ".".join(err_loc_tree)
return target
return ".".join(err_loc_tree)
Copy link
Author

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:

Comment on lines -63 to +66
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, ...)
)
Copy link
Author

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:

Comment on lines -35 to +36
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}"
Copy link
Author

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:

reply_name = "Reply_" + self.operation_id
reply_name = f"Reply_{self.operation_id}"
Copy link
Author

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:

Comment on lines -109 to +104
schema = {}
schema["range"] = {"upper": upper_bound, "lower": lower_bound}
schema = {"range": {"upper": upper_bound, "lower": lower_bound}}
Copy link
Author

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:

Comment on lines -177 to +175
info = {"title": title, "version": version}
info["description"] = description if description else None
info = {
"title": title,
"version": version,
"description": description if description else None,
}
Copy link
Author

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:

reply = JsonRPCReply.parse_raw(reply_raw.data)
return reply
return JsonRPCReply.parse_raw(reply_raw.data)
Copy link
Author

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:

Comment on lines -74 to +79
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)}"
)
Copy link
Author

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:

Comment on lines -154 to +164
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,
)
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants