-
Notifications
You must be signed in to change notification settings - Fork 0
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 #2
base: master
Are you sure you want to change the base?
Conversation
c96a782
to
c0e6bd2
Compare
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.46%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Let us know what you think of it by mentioning @sourcery-ai in a comment. |
only_kv_data = [] | ||
_, data = self.consul_client.kv.get(key='', recurse=True) | ||
for item in data: | ||
only_kv_data.append({ | ||
return [{ | ||
"Key": item['Key'], | ||
"Value": json.loads((item['Value'].decode('utf-8'))) | ||
}) | ||
return only_kv_data | ||
} for item in 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 ConsulClient.get_all
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
service_state = { | ||
return { | ||
'status_code': status_code, | ||
} | ||
|
||
return service_state |
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 SitesCheckerService.status
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
res_status = 200 | ||
|
||
return res_status | ||
return 200 |
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 HealthCheckController.check_health
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
only_kv_data = [] | ||
_, data = self.consul_client.kv.get(key='', recurse=True) | ||
for item in data: | ||
only_kv_data.append({ | ||
return [{ | ||
"Key": item['Key'], | ||
"Value": json.loads((item['Value'].decode('utf-8'))) | ||
}) | ||
return only_kv_data | ||
} for item in 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 ConsulClient.get_all
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
consul_client = ConsulClient(host=os.getenv('CONSUL_HOST', '127.0.0.1'), prefix='sites-checker-service') | ||
return consul_client | ||
return ConsulClient( | ||
host=os.getenv('CONSUL_HOST', '127.0.0.1'), | ||
prefix='sites-checker-service', | ||
) |
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 CoreModule.provide_consul_client
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
postgres_client = PostgresClient(dsn=conf_service.postgres_url) | ||
# TODO: check asyncio support | ||
# await postgres_client.connect() | ||
return postgres_client | ||
return PostgresClient(dsn=conf_service.postgres_url) |
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 CoreModule.provide_postgres_client
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
logger = get_logger( | ||
return get_logger( | ||
logger_name='SitesCheckerService', | ||
logger_format=LoggingFormat.JSON, | ||
logger_level=logging.INFO, | ||
logger_output=LoggingOutput.STDOUT, | ||
) | ||
|
||
return logger |
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 CoreModule.provide_logger
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
for result in cursor.fetchall(): | ||
yield result | ||
yield from cursor.fetchall() |
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 PostgresClient.select
refactored with the following changes:
- Replace yield inside for loop with yield from (
yield-from
)
for result in cursor.fetchall(): | ||
yield result | ||
yield from cursor.fetchall() |
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 PostgresClient.insert
refactored with the following changes:
- Replace yield inside for loop with yield from (
yield-from
)
job = self.scheduler.add_job(callback, 'date', args=args) | ||
return job | ||
return self.scheduler.add_job(callback, 'date', args=args) |
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 JobManager.run_once
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
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: