-
Notifications
You must be signed in to change notification settings - Fork 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
Sourcery Starbot ⭐ refactored DucarrougeR/themis-1 #1
base: main
Are you sure you want to change the base?
Conversation
if connection.name not in ('looker', 'looker__ilooker', 'looker__internal__analytics'): | ||
if connection.dialect: | ||
connection_tests = {'tests': connection.dialect.connection_tests} | ||
for test in connection_tests['tests']: | ||
try: | ||
db_validation = self.looker_client.test_connection(connection.name, test) | ||
for item in db_validation: | ||
if item.status != 'success': | ||
db_errors.append("Database Connection {} Test '{}' returned '{}'".format(connection.name, | ||
item.name, | ||
item.message)) | ||
except Exception as e: | ||
print("Database Connection test for {} failed due to {}".format(connection.name, e)) | ||
if ( | ||
connection.name | ||
not in ('looker', 'looker__ilooker', 'looker__internal__analytics') | ||
and connection.dialect | ||
): | ||
connection_tests = {'tests': connection.dialect.connection_tests} | ||
for test in connection_tests['tests']: | ||
try: | ||
db_validation = self.looker_client.test_connection(connection.name, test) | ||
for item in db_validation: | ||
if item.status != 'success': | ||
db_errors.append("Database Connection {} Test '{}' returned '{}'".format(connection.name, | ||
item.name, | ||
item.message)) | ||
except Exception as e: | ||
print("Database Connection test for {} failed due to {}".format(connection.name, e)) |
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 Connectivity.test_db_connections
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
)
else: | ||
# integration_errors.append("Integration {} not enabled.".format(elem.label)) | ||
pass |
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 Connectivity.test_integrations
refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass
)
This removes the following comments ( why? ):
# integration_errors.append("Integration {} not enabled.".format(elem.label))
modules/connectivity.py
Outdated
group_errors = [] | ||
for elem in all_datagroups: | ||
if elem.trigger_error: | ||
group_errors.append("Datagroup \"{}\" on model \"{}\" has this error:\t{}".format(elem.name, | ||
elem.model_name, | ||
elem.trigger_error)) | ||
return group_errors No newline at end of file | ||
return [ | ||
"Datagroup \"{}\" on model \"{}\" has this error:\t{}".format( | ||
elem.name, elem.model_name, elem.trigger_error | ||
) | ||
for elem in all_datagroups | ||
if elem.trigger_error | ||
] |
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 Connectivity.test_datagroups
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
for i in range(0, len(error)): | ||
for i in range(len(error)): |
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 Content.validate_content
refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range
)
body = ''' | ||
return ''' |
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 email_body
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
cleaned_errors = [] | ||
for elem in json.loads(failed_pdts_list): | ||
# cleaned_errors.append("PDT \'{}\' failed with error: {}".format(elem['pdt_event_log.view_name'], elem['error_message'])) | ||
cleaned_errors.append("PDT \'{}\' failed on connection: {}".format(elem['pdt_event_log.view_name'], elem['pdt_event_log.connection'])) | ||
cleaned_errors = [ | ||
"PDT \'{}\' failed on connection: {}".format( | ||
elem['pdt_event_log.view_name'], elem['pdt_event_log.connection'] | ||
) | ||
for elem in json.loads(failed_pdts_list) | ||
] | ||
|
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 Schedules.get_pdts_status
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
This removes the following comments ( why? ):
# cleaned_errors.append("PDT \'{}\' failed with error: {}".format(elem['pdt_event_log.view_name'], elem['error_message']))
to_emails = [] | ||
for email in email_list.split(','): | ||
to_emails.append(email) | ||
to_emails = [email for email in email_list.split(',')] |
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 send_report_out
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
disabled_users = [] | ||
disabled_users = [i for i in all_users if i.is_disabled] | ||
|
||
for i in all_users: | ||
if i.is_disabled: | ||
disabled_users.append(i) | ||
user_results = [] | ||
user_results.append("Disabled Looker users: {}".format(len(disabled_users))) | ||
user_results = ["Disabled Looker users: {}".format(len(disabled_users))] |
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 Users.get_users_issue
refactored with the following changes:
- Merge append into list declaration (
merge-list-append
) - Convert for loop into list comprehension (
list-comprehension
)
cred_file = [] | ||
for file in os.listdir(parent_dir): | ||
if file.endswith(".ini"): | ||
cred_file.append(os.path.join(parent_dir, file)) | ||
cred_file = [ | ||
os.path.join(parent_dir, file) | ||
for file in os.listdir(parent_dir) | ||
if file.endswith(".ini") | ||
] | ||
|
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 LookerSDKTestCase.test_looker_credentials
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
regex = r'^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$' | ||
for email in self.__class__.email_list.split(','): | ||
regex = r'^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$' |
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 LookerSDKTestCase.test_emails_format
refactored with the following changes:
- Hoist statements out of for/while loops (
hoist-statement-from-loop
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
main
branch, then run: