-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
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
base: master
Are you sure you want to change the base?
Conversation
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.
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'} |
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_details_for_token refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
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
| 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) |
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 auth_webhook refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
This removes the following comments ( why? ):
# allow the graphql request with variables
# reject the graphql request
| 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']}" |
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 lambda_handler refactored with the following changes:
- Replace call to format with f-string [×3] (
use-fstring-for-formatting)
| 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' |
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.
Lines 7-7 refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| # 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) |
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 ValidateAndAddUser.mutate refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else) - Use f-string instead of string concatenation (
use-fstring-for-concatenation)
This removes the following comments ( why? ):
# check balance
| 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) | ||
| } |
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 CronTrigger.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["value"] = from_str(self.value) | ||
| result: dict = {"value": from_str(self.value)} |
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 EnumValue.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["name"] = from_str(self.name) | ||
| result: dict = {"name": from_str(self.name)} |
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 EnumType.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["name"] = from_str(self.name) | ||
| result: dict = {"name": from_str(self.name)} |
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 InputObjectField.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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 | ||
| ) | ||
| } |
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 InputObjectType.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["name"] = from_str(self.name) | ||
| result: dict = {"name": from_str(self.name)} |
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 QualifiedTable.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["field_mapping"] = from_dict(from_str, self.field_mapping) | ||
| result: dict = {"field_mapping": from_dict(from_str, self.field_mapping)} |
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 CustomTypeObjectRelationship.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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 | ||
| ) | ||
| } |
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 ObjectType.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["name"] = from_str(self.name) | ||
| result: dict = {"name": from_str(self.name)} |
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 ScalarType.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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, | ||
| ) | ||
| } |
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 CustomTypes.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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, | ||
| ) | ||
| } |
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 ArrRelUsing.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["name"] = from_str(self.name) | ||
| result: dict = {"name": from_str(self.name)} |
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 ArrayRelationship.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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 | ||
| ) | ||
| } |
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 ComputedFieldDefinition.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["definition"] = to_class(ComputedFieldDefinition, self.definition) | ||
| result: dict = { | ||
| "definition": to_class(ComputedFieldDefinition, self.definition) | ||
| } |
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 ComputedField.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["delete"] = from_union([from_str, from_none], self.delete) | ||
| result: dict = {"delete": from_union([from_str, from_none], self.delete)} |
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 CustomRootFields.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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, | ||
| ) | ||
| } |
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 TableConfig.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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, | ||
| ) | ||
| } |
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 DeletePermission.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["permission"] = to_class(DeletePermission, self.permission) | ||
| result: dict = {"permission": to_class(DeletePermission, self.permission)} |
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 DeletePermissionEntry.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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, | ||
| ) | ||
| } |
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 OperationSpec.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["enable_manual"] = from_bool(self.enable_manual) | ||
| result: dict = {"enable_manual": from_bool(self.enable_manual)} |
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 EventTriggerDefinition.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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, | ||
| ) | ||
| } |
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 SelectPermission.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["permission"] = to_class(SelectPermission, self.permission) | ||
| result: dict = {"permission": to_class(SelectPermission, self.permission)} |
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 SelectPermissionEntry.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| 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, | ||
| ) | ||
| } |
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 UpdatePermission.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["permission"] = to_class(UpdatePermission, self.permission) | ||
| result: dict = {"permission": to_class(UpdatePermission, self.permission)} |
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 UpdatePermissionEntry.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| result: dict = {} | ||
| result["table"] = to_class(QualifiedTable, self.table) | ||
| result: dict = {"table": to_class(QualifiedTable, self.table)} |
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 TableEntry.to_dict refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
|
SonarCloud Quality Gate failed.
|
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!