avoid print statements, generally (#784)
* avoid print statements, generally * remove test for empty main script --------- Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
parent
1627f5dd07
commit
353ba4cd31
|
@ -12,7 +12,7 @@ def main() -> None:
|
|||
VersionOneThree().run()
|
||||
|
||||
end_time = time.time()
|
||||
print(
|
||||
app.logger.debug(
|
||||
f"done running data migration from ./bin/data_migrations/version_1_3.py. took {end_time - start_time} seconds"
|
||||
)
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ Changelog = "https://github.com/orgs/sartography/packages?repo_name=spiff-arena"
|
|||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.10,<3.12"
|
||||
click = "^8.0.1"
|
||||
flask = "2.2.5"
|
||||
flask-admin = "*"
|
||||
flask-bcrypt = "*"
|
||||
|
@ -183,6 +182,7 @@ select = [
|
|||
"N", # pep8-naming
|
||||
"PL", # pylint
|
||||
"S", # flake8-bandit
|
||||
"T", # flake8-print
|
||||
"UP", # pyupgrade
|
||||
"W", # pycodestyle warning
|
||||
"I001" # isort
|
||||
|
@ -207,6 +207,7 @@ exclude = [
|
|||
[tool.ruff.per-file-ignores]
|
||||
"migrations/versions/*.py" = ["E501"]
|
||||
"tests/**/*.py" = ["PLR2004", "S101"] # PLR2004 is about magic vars, S101 allows assert
|
||||
"bin/*.py" = ["T"] # it's ok to print things in scripts
|
||||
|
||||
[tool.ruff.isort]
|
||||
force-single-line = true
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
"""Command-line interface."""
|
||||
import click
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.version_option()
|
||||
def main() -> None:
|
||||
"""Spiffworkflow Backend."""
|
||||
print("This does nothing")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(prog_name="spiffworkflow-backend") # pragma: no cover
|
|
@ -77,7 +77,6 @@ def setup_database_configs(app: Flask) -> None:
|
|||
def load_config_file(app: Flask, env_config_module: str) -> None:
|
||||
try:
|
||||
app.config.from_object(env_config_module)
|
||||
print(f"loaded config: {env_config_module}")
|
||||
except ImportStringError:
|
||||
# ignore this error
|
||||
pass
|
||||
|
@ -201,9 +200,6 @@ def setup_config(app: Flask) -> None:
|
|||
"permissions",
|
||||
permissions_file_name,
|
||||
)
|
||||
print(f"base_permissions: loaded permissions file: {permissions_file_name}")
|
||||
else:
|
||||
print("base_permissions: no permissions file loaded")
|
||||
|
||||
# unversioned (see .gitignore) config that can override everything and include secrets.
|
||||
# src/spiffworkflow_backend/config/secrets.py
|
||||
|
|
|
@ -20,9 +20,9 @@ class VersionOneThree:
|
|||
"""
|
||||
|
||||
def run(self) -> None:
|
||||
print("start VersionOneThree.run")
|
||||
current_app.logger.debug("start VersionOneThree.run")
|
||||
task_definitions = self.get_relevant_task_definitions()
|
||||
print(f"found relevant task_definitions: {len(task_definitions)}")
|
||||
current_app.logger.debug(f"found relevant task_definitions: {len(task_definitions)}")
|
||||
for task_definition in task_definitions:
|
||||
self.process_task_definition(task_definition)
|
||||
relating_task_models = TaskModel.query.filter_by(task_definition_id=task_definition.id).all()
|
||||
|
@ -42,7 +42,7 @@ class VersionOneThree:
|
|||
self.update_tasks_where_last_change_is_null()
|
||||
|
||||
db.session.commit()
|
||||
print("end VersionOneThree.run")
|
||||
current_app.logger.debug("end VersionOneThree.run")
|
||||
|
||||
def get_relevant_task_definitions(self) -> list[TaskDefinitionModel]:
|
||||
task_definitions: list[TaskDefinitionModel] = TaskDefinitionModel.query.filter(
|
||||
|
|
|
@ -14,5 +14,5 @@ def try_to_connect(start_time: float) -> None:
|
|||
raise exception
|
||||
else:
|
||||
time.sleep(1)
|
||||
print("Waiting for db to be ready in loop...")
|
||||
print("Waiting for db to be ready in loop...") # noqa: T201
|
||||
try_to_connect(start_time)
|
||||
|
|
|
@ -1159,7 +1159,7 @@ class ProcessInstanceProcessor:
|
|||
try:
|
||||
self.bpmn_process_instance.send_event(bpmn_event)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
current_app.logger.warning(e)
|
||||
|
||||
# TODO: do_engine_steps without a lock
|
||||
self.do_engine_steps(save=True)
|
||||
|
|
|
@ -381,7 +381,7 @@ class ProcessInstanceService:
|
|||
created_at_in_seconds=now_in_seconds,
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
current_app.logger.warning(e)
|
||||
|
||||
return None
|
||||
|
||||
|
|
|
@ -90,7 +90,6 @@ class TestExtensionsController(BaseTest):
|
|||
f"/v1.0/extensions/{self.modify_process_identifier_for_path_param(process_model.id)}",
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
)
|
||||
print(f"response.json: {response.json}")
|
||||
assert response.status_code == 403
|
||||
assert response.json
|
||||
assert response.json["error_code"] == "invalid_process_model_extension"
|
||||
|
|
|
@ -245,5 +245,3 @@ class TestNestedGroups(BaseTest):
|
|||
user = self.find_or_create_user()
|
||||
self.add_permissions_to_user(user, target_uri=target_uri, permission_names=["read"])
|
||||
response = client.get(target_uri, headers=self.logged_in_headers(user)) # noqa: F841
|
||||
|
||||
print("test_process_group_show: ")
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
"""Test cases for the __main__ module."""
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
from spiffworkflow_backend import __main__
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def runner() -> CliRunner:
|
||||
"""Fixture for invoking command-line interfaces."""
|
||||
return CliRunner()
|
||||
|
||||
|
||||
def test_main_succeeds(runner: CliRunner) -> None:
|
||||
"""It exits with a status code of zero."""
|
||||
result = runner.invoke(__main__.main)
|
||||
assert result.exit_code == 0
|
Loading…
Reference in New Issue