这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Nov 15, 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 Sam9799 November 15, 2023 19:26
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

# return None

return variables
return {'X-Hasura-Role': 'user', 'X-Hasura-User-Id': '1'}
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_details_for_token refactored with the following changes:

This removes the following comments ( why? ):

# Here as an example, we return user, 1
# return None
# to X-Hasura-Role and other variables like X-Hasura-User-Id
# response should be 403, Unauthorized. In this example if variables are
# if the request should be rejected, say due to an invalid token, the
# None, we return 401, Unauthorized
# execute some logic (say contacting a 3rd party API) to resolve the token

Comment on lines -39 to +26
if variables is not None:
# allow the graphql request with variables
return jsonify(variables)
else:
# reject the graphql request
return abort(401)
return jsonify(variables) if variables is not None else abort(401)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function auth_webhook refactored with the following changes:

This removes the following comments ( why? ):

# allow the graphql request with variables
# reject the graphql request

Comment on lines -17 to +23
message = 'New note {} inserted, with data: {}'.format(data['new']['id'], data['new']['note'])
message = f"New note {data['new']['id']} inserted, with data: {data['new']['note']}"

elif body['table']['name'] == 'notes' and body['event']['op'] == 'UPDATE':
message = 'Note {} updated, with data: {}'.format(data['new']['id'], data['new']['note'])
message = f"Note {data['new']['id']} updated, with data: {data['new']['note']}"

elif body['table'] == 'notes' and body['event']['op'] == 'DELETE':
message = 'Note {} deleted, with data: {}'.format(data['old']['id'], data['old']['note'])
message = f"Note {data['old']['id']} deleted, with data: {data['old']['note']}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lambda_handler refactored with the following changes:

ADMIN_SECRET = os.environ['ADMIN_SECRET']
HGE_ENDPOINT = os.environ['HGE_ENDPOINT']
HGE_URL = HGE_ENDPOINT + '/v1/graphql'
HGE_URL = f'{HGE_ENDPOINT}/v1/graphql'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 7-7 refactored with the following changes:

Comment on lines -34 to +41
# check balance
if balance >= minAmount.amount:
#create user if balance is greater
user = UserModel(name=name, balance=balance)
db_session.add(user)
db_session.commit()
db_session.refresh(user)
return ValidateAndAddUser(id = user.id, name = user.name, balance=user.balance)
else:
raise ValueError('balance too low, required atleast ' + str(minAmount.amount))
if balance < minAmount.amount:
raise ValueError(f'balance too low, required atleast {str(minAmount.amount)}')
#create user if balance is greater
user = UserModel(name=name, balance=balance)
db_session.add(user)
db_session.commit()
db_session.refresh(user)
return ValidateAndAddUser(id = user.id, name = user.name, balance=user.balance)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ValidateAndAddUser.mutate refactored with the following changes:

This removes the following comments ( why? ):

# check balance

Comment on lines -473 to +467
result: dict = {}
result["headers"] = from_list(lambda x: to_class(Header, x), self.headers)
result: dict = {
"headers": from_list(lambda x: to_class(Header, x), self.headers)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CronTrigger.to_dict refactored with the following changes:

Comment on lines -506 to +499
result: dict = {}
result["value"] = from_str(self.value)
result: dict = {"value": from_str(self.value)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function EnumValue.to_dict refactored with the following changes:

Comment on lines -534 to +526
result: dict = {}
result["name"] = from_str(self.name)
result: dict = {"name": from_str(self.name)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function EnumType.to_dict refactored with the following changes:

Comment on lines -562 to +553
result: dict = {}
result["name"] = from_str(self.name)
result: dict = {"name": from_str(self.name)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function InputObjectField.to_dict refactored with the following changes:

Comment on lines -590 to +584
result: dict = {}
result["fields"] = from_list(lambda x: to_class(InputObjectField, x), self.fields)
result: dict = {
"fields": from_list(
lambda x: to_class(InputObjectField, x), self.fields
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function InputObjectType.to_dict refactored with the following changes:

Comment on lines -610 to +603
result: dict = {}
result["name"] = from_str(self.name)
result: dict = {"name": from_str(self.name)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function QualifiedTable.to_dict refactored with the following changes:

Comment on lines -646 to +638
result: dict = {}
result["field_mapping"] = from_dict(from_str, self.field_mapping)
result: dict = {"field_mapping": from_dict(from_str, self.field_mapping)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CustomTypeObjectRelationship.to_dict refactored with the following changes:

Comment on lines -678 to +673
result: dict = {}
result["fields"] = from_list(lambda x: to_class(InputObjectField, x), self.fields)
result: dict = {
"fields": from_list(
lambda x: to_class(InputObjectField, x), self.fields
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ObjectType.to_dict refactored with the following changes:

Comment on lines -704 to +698
result: dict = {}
result["name"] = from_str(self.name)
result: dict = {"name": from_str(self.name)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ScalarType.to_dict refactored with the following changes:

Comment on lines -727 to +728
result: dict = {}
result["enums"] = from_union([lambda x: from_list(lambda x: to_class(EnumType, x), x), from_none], self.enums)
result: dict = {
"enums": from_union(
[
lambda x: from_list(lambda x: to_class(EnumType, x), x),
from_none,
],
self.enums,
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CustomTypes.to_dict refactored with the following changes:

Comment on lines -1009 to +1020
result: dict = {}
result["foreign_key_constraint_on"] = from_union([lambda x: to_class(ArrRelUsingFKeyOn, x), from_none], self.foreign_key_constraint_on)
result: dict = {
"foreign_key_constraint_on": from_union(
[lambda x: to_class(ArrRelUsingFKeyOn, x), from_none],
self.foreign_key_constraint_on,
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ArrRelUsing.to_dict refactored with the following changes:

Comment on lines -1036 to +1046
result: dict = {}
result["name"] = from_str(self.name)
result: dict = {"name": from_str(self.name)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ArrayRelationship.to_dict refactored with the following changes:

Comment on lines -1070 to +1083
result: dict = {}
result["function"] = from_union([lambda x: to_class(QualifiedFunction, x), from_str], self.function)
result: dict = {
"function": from_union(
[lambda x: to_class(QualifiedFunction, x), from_str], self.function
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ComputedFieldDefinition.to_dict refactored with the following changes:

Comment on lines -1098 to +1112
result: dict = {}
result["definition"] = to_class(ComputedFieldDefinition, self.definition)
result: dict = {
"definition": to_class(ComputedFieldDefinition, self.definition)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ComputedField.to_dict refactored with the following changes:

Comment on lines -1147 to +1160
result: dict = {}
result["delete"] = from_union([from_str, from_none], self.delete)
result: dict = {"delete": from_union([from_str, from_none], self.delete)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CustomRootFields.to_dict refactored with the following changes:

Comment on lines -1182 to +1199
result: dict = {}
result["custom_column_names"] = from_union([lambda x: from_dict(from_str, x), from_none], self.custom_column_names)
result: dict = {
"custom_column_names": from_union(
[lambda x: from_dict(from_str, x), from_none],
self.custom_column_names,
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TableConfig.to_dict refactored with the following changes:

Comment on lines -1206 to +1240
result: dict = {}
result["filter"] = from_union([lambda x: from_dict(lambda x: from_union([lambda x: from_dict(lambda x: x, x), to_float, from_str], x), x), from_none], self.filter)
result: dict = {
"filter": from_union(
[
lambda x: from_dict(
lambda x: from_union(
[
lambda x: from_dict(lambda x: x, x),
to_float,
from_str,
],
x,
),
x,
),
from_none,
],
self.filter,
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DeletePermission.to_dict refactored with the following changes:

Comment on lines -1232 to +1265
result: dict = {}
result["permission"] = to_class(DeletePermission, self.permission)
result: dict = {"permission": to_class(DeletePermission, self.permission)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DeletePermissionEntry.to_dict refactored with the following changes:

Comment on lines -1265 to +1305
result: dict = {}
result["columns"] = from_union([lambda x: from_list(from_str, x), lambda x: to_enum(EventTriggerColumnsEnum, x)], self.columns)
result: dict = {
"columns": from_union(
[
lambda x: from_list(from_str, x),
lambda x: to_enum(EventTriggerColumnsEnum, x),
],
self.columns,
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function OperationSpec.to_dict refactored with the following changes:

Comment on lines -1298 to +1337
result: dict = {}
result["enable_manual"] = from_bool(self.enable_manual)
result: dict = {"enable_manual": from_bool(self.enable_manual)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function EventTriggerDefinition.to_dict refactored with the following changes:

Comment on lines -1636 to +1688
result: dict = {}
result["columns"] = from_union([lambda x: from_list(from_str, x), lambda x: to_enum(EventTriggerColumnsEnum, x)], self.columns)
result: dict = {
"columns": from_union(
[
lambda x: from_list(from_str, x),
lambda x: to_enum(EventTriggerColumnsEnum, x),
],
self.columns,
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SelectPermission.to_dict refactored with the following changes:

Comment on lines -1666 to +1717
result: dict = {}
result["permission"] = to_class(SelectPermission, self.permission)
result: dict = {"permission": to_class(SelectPermission, self.permission)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SelectPermissionEntry.to_dict refactored with the following changes:

Comment on lines -1699 to +1757
result: dict = {}
result["columns"] = from_union([lambda x: from_list(from_str, x), lambda x: to_enum(EventTriggerColumnsEnum, x)], self.columns)
result: dict = {
"columns": from_union(
[
lambda x: from_list(from_str, x),
lambda x: to_enum(EventTriggerColumnsEnum, x),
],
self.columns,
)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdatePermission.to_dict refactored with the following changes:

Comment on lines -1728 to +1785
result: dict = {}
result["permission"] = to_class(UpdatePermission, self.permission)
result: dict = {"permission": to_class(UpdatePermission, self.permission)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdatePermissionEntry.to_dict refactored with the following changes:

Comment on lines -1773 to +1829
result: dict = {}
result["table"] = to_class(QualifiedTable, self.table)
result: dict = {"table": to_class(QualifiedTable, self.table)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TableEntry.to_dict refactored with the following changes:

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 6, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 1 Security Hotspot
Code Smell A 18 Code Smells

No Coverage information No Coverage information
16.5% 16.5% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

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.

1 participant