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

Bump black to v22.3.0 and update format #5606

Merged
merged 5 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ Fixed

Contributed by @nzlosh

Changed
~~~~~~~

* Bump black to v22.3.0 - This is used internally to reformat our python code. #5606

3.6.0 - October 29, 2021
------------------------

Expand Down
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,19 @@ black: requirements .black-check
echo "Running black on" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate ; black --check --config pyproject.toml $$component/ || exit 1; \
. $(VIRTUALENV_DIR)/bin/activate ; black $$(grep -rl '^#!/.*python' $$component/bin) || exit 1; \
if [ -d "$$component/bin" ]; then \
. $(VIRTUALENV_DIR)/bin/activate ; black $$(grep -rl '^#!/.*python' $$component/bin) || exit 1; \
fi \
done
# runner modules and packages
@for component in $(COMPONENTS_RUNNERS); do\
echo "==========================================================="; \
echo "Running black on" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate ; black --check --config pyproject.toml $$component/ || exit 1; \
. $(VIRTUALENV_DIR)/bin/activate ; black $$(grep -rl '^#!/.*python' $$component/bin) || exit 1; \
if [ -d "$$component/bin" ]; then \
. $(VIRTUALENV_DIR)/bin/activate ; black $$(grep -rl '^#!/.*python' $$component/bin) || exit 1; \
fi \
done
. $(VIRTUALENV_DIR)/bin/activate; black --check --config pyproject.toml contrib/ || exit 1;
. $(VIRTUALENV_DIR)/bin/activate; black --check --config pyproject.toml scripts/*.py || exit 1;
Expand All @@ -411,15 +415,19 @@ black: requirements .black-format
echo "Running black on" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate ; black --config pyproject.toml $$component/ || exit 1; \
. $(VIRTUALENV_DIR)/bin/activate ; black --config pyproject.toml $$(grep -rl '^#!/.*python' $$component/bin) || exit 1; \
if [ -d "$$component/bin" ]; then \
. $(VIRTUALENV_DIR)/bin/activate ; black --config pyproject.toml $$(grep -rl '^#!/.*python' $$component/bin) || exit 1; \
fi \
done
# runner modules and packages
@for component in $(COMPONENTS_RUNNERS); do\
echo "==========================================================="; \
echo "Running black on" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate ; black --config pyproject.toml $$component/ || exit 1; \
. $(VIRTUALENV_DIR)/bin/activate ; black --config pyproject.toml $$(grep -rl '^#!/.*python' $$component/bin) || exit 1; \
if [ -d "$$component/bin" ]; then \
. $(VIRTUALENV_DIR)/bin/activate ; black --config pyproject.toml $$(grep -rl '^#!/.*python' $$component/bin) || exit 1; \
fi \
done
. $(VIRTUALENV_DIR)/bin/activate; black --config pyproject.toml contrib/ || exit 1;
. $(VIRTUALENV_DIR)/bin/activate; black --config pyproject.toml scripts/*.py || exit 1;
Expand Down
2 changes: 1 addition & 1 deletion contrib/packs/actions/pack_mgmt/get_installed.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


class GetInstalled(Action):
""""Get information about installed pack."""
"""Get information about installed pack."""

def run(self, pack):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def test_large_stdout(self):
)
runner = self._get_runner(action_db, entry_point=entry_point)
runner.pre_run()
char_count = 10 ** 6 # Note 10^7 succeeds but ends up being slow.
char_count = 10**6 # Note 10^7 succeeds but ends up being slow.
status, result, _ = runner.run({"chars": char_count})
runner.post_run(status, result)
self.assertEqual(status, action_constants.LIVEACTION_STATUS_SUCCEEDED)
Expand Down
9 changes: 6 additions & 3 deletions st2actions/st2actions/scheduler/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,12 @@ def _cleanup_policy_delayed(self):
)
)
except db_exc.StackStormDBObjectWriteConflictError:
msg = '[%s] Item "%s" is currently being processed by another scheduler.' % (
execution_queue_item_db.action_execution_id,
str(execution_queue_item_db.id),
msg = (
'[%s] Item "%s" is currently being processed by another scheduler.'
% (
execution_queue_item_db.action_execution_id,
str(execution_queue_item_db.id),
)
)
LOG.error(msg)
raise Exception(msg)
Expand Down
2 changes: 1 addition & 1 deletion st2api/st2api/controllers/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def _get_all(

# TODO: To protect us from DoS, we need to make max_limit mandatory
offset = int(offset)
if offset >= 2 ** 31:
if offset >= 2**31:
raise ValueError('Offset "%s" specified is more than 32-bit int' % (offset))

limit = validate_limit_query_param(limit=limit, requester_user=requester_user)
Expand Down
2 changes: 1 addition & 1 deletion st2api/tests/unit/controllers/v1/test_executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ def test_re_run_with_very_large_delay(self):
self.assertEqual(post_resp.status_int, 201)
execution_id = self._get_actionexecution_id(post_resp)

delay_time = 10 ** 10
delay_time = 10**10
data = {"delay": delay_time}
re_run_resp = self.app.post_json(
"/v1/executions/%s/re_run" % (execution_id), data
Expand Down
2 changes: 1 addition & 1 deletion st2common/bin/st2-purge-task-executions
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ import sys

from st2common.cmd.purge_task_executions import main

if __name__ == '__main__':
if __name__ == "__main__":
sys.exit(main())
2 changes: 1 addition & 1 deletion st2common/bin/st2-purge-workflows
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ import sys

from st2common.cmd.purge_workflows import main

if __name__ == '__main__':
if __name__ == "__main__":
sys.exit(main())
2 changes: 1 addition & 1 deletion st2common/st2common/middleware/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def custom_start_response(status, headers, exc_info=None):
"path": request.path,
"remote_addr": request.remote_addr,
"status": status_code[0],
"runtime": float("{0:.3f}".format((clock() - start_time) * 10 ** 3)),
"runtime": float("{0:.3f}".format((clock() - start_time) * 10**3)),
"content_length": content_length[0]
if content_length
else len(b"".join(retval)),
Expand Down
2 changes: 1 addition & 1 deletion st2reactor/st2reactor/container/hash_partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Range(object):
RANGE_MIN_VALUE = 0

RANGE_MAX_ENUM = "max"
RANGE_MAX_VALUE = 2 ** 32
RANGE_MAX_VALUE = 2**32

def __init__(self, range_repr):
self.range_start, self.range_end = self._get_range_boundaries(range_repr)
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ st2flake8==0.1.0
astroid==2.5.6
pylint==2.8.2
pylint-plugin-utils>=0.4
black==20.8b1
black==22.3.0
pre-commit==2.1.0
bandit==1.7.0
ipython<6.0.0
Expand Down