mypy w/ burnettk cullerton

This commit is contained in:
jasquat 2022-12-08 17:12:19 -05:00
parent d50d95a49c
commit 4878d2329b
9 changed files with 27 additions and 16 deletions

View File

@ -27,3 +27,8 @@ per-file-ignores =
# this file overwrites methods from the logging library so we can't change them # this file overwrites methods from the logging library so we can't change them
# and ignore long comment line # and ignore long comment line
spiffworkflow-backend/src/spiffworkflow_backend/services/logging_service.py:N802,B950 spiffworkflow-backend/src/spiffworkflow_backend/services/logging_service.py:N802,B950
# TODO: fix the S issues:
# S607 Starting a process with a partial executable path
# S605 Starting a process with a shell: Seems safe, but may be changed in the future, consider rewriting without shell
spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py:S607,S101,D103,S605

View File

@ -27,3 +27,5 @@ per-file-ignores =
# this file overwrites methods from the logging library so we can't change them # this file overwrites methods from the logging library so we can't change them
# and ignore long comment line # and ignore long comment line
src/spiffworkflow_backend/services/logging_service.py:N802,B950 src/spiffworkflow_backend/services/logging_service.py:N802,B950
tests/spiffworkflow_backend/integration/test_process_api.py:S607,S101,D103,S605

View File

@ -1,6 +1,8 @@
"""dev.""" """Dev."""
from os import environ from os import environ
GIT_MERGE_BRANCH = environ.get("GIT_MERGE_BRANCH", default="staging") GIT_MERGE_BRANCH = environ.get("GIT_MERGE_BRANCH", default="staging")
GIT_USERNAME = environ.get("GIT_USERNAME", default="sartography-automated-committer") GIT_USERNAME = environ.get("GIT_USERNAME", default="sartography-automated-committer")
GIT_USER_EMAIL = environ.get("GIT_USER_EMAIL", default="sartography-automated-committer@users.noreply.github.com") GIT_USER_EMAIL = environ.get(
"GIT_USER_EMAIL", default="sartography-automated-committer@users.noreply.github.com"
)

View File

@ -2,7 +2,7 @@
import os import os
from contextlib import contextmanager from contextlib import contextmanager
from datetime import datetime from datetime import datetime
from typing import List from typing import Generator, List
from typing import Optional from typing import Optional
import pytz import pytz
@ -25,9 +25,9 @@ class FileSystemService:
PROCESS_MODEL_JSON_FILE = "process_model.json" PROCESS_MODEL_JSON_FILE = "process_model.json"
# https://stackoverflow.com/a/24176022/6090676 # https://stackoverflow.com/a/24176022/6090676
@contextmanager
@staticmethod @staticmethod
def cd(newdir): @contextmanager
def cd(newdir: str) -> Generator:
"""Cd.""" """Cd."""
prevdir = os.getcwd() prevdir = os.getcwd()
os.chdir(os.path.expanduser(newdir)) os.chdir(os.path.expanduser(newdir))

View File

@ -44,7 +44,7 @@ class GitService:
return file_contents.encode("utf-8") return file_contents.encode("utf-8")
@staticmethod @staticmethod
def commit(message: str, repo_path: Optional[str]) -> str: def commit(message: str, repo_path: Optional[str] = None) -> str:
"""Commit.""" """Commit."""
repo_path_to_use = repo_path repo_path_to_use = repo_path
if repo_path is None: if repo_path is None:
@ -73,10 +73,14 @@ class GitService:
clone_dir = f"sample-process-models.{unique_hex}" clone_dir = f"sample-process-models.{unique_hex}"
# clone new instance of sample-process-models, checkout branch_to_update # clone new instance of sample-process-models, checkout branch_to_update
destination_process_root = f"/tmp/{clone_dir}" # we are adding a guid to this so the flake8 issue has been mitigated
os.system( destination_process_root = f"/tmp/{clone_dir}" # noqa
f"git clone https://{current_app.config['GIT_USERNAME']}:{current_app.config['GIT_USER_PASSWORD']}@github.com/sartography/sample-process-models.git {destination_process_root}"
cmd = (
f"git clone https://{current_app.config['GIT_USERNAME']}:{current_app.config['GIT_USER_PASSWORD']}"
f"@github.com/sartography/sample-process-models.git {destination_process_root}"
) )
os.system(cmd) # noqa: S605
with FileSystemService.cd(destination_process_root): with FileSystemService.cd(destination_process_root):
# create publish branch from branch_to_update # create publish branch from branch_to_update
os.system(f"git checkout {branch_to_update}") # noqa: S605 os.system(f"git checkout {branch_to_update}") # noqa: S605
@ -84,7 +88,7 @@ class GitService:
command = f"git show-ref --verify refs/remotes/origin/{publish_branch}" command = f"git show-ref --verify refs/remotes/origin/{publish_branch}"
output = os.popen(command).read() # noqa: S605 output = os.popen(command).read() # noqa: S605
if output: if output:
os.system(f"git checkout {publish_branch}") os.system(f"git checkout {publish_branch}") # noqa: S605
else: else:
os.system(f"git checkout -b {publish_branch}") # noqa: S605 os.system(f"git checkout -b {publish_branch}") # noqa: S605
@ -99,10 +103,10 @@ class GitService:
# add and commit files to publish_branch, then push # add and commit files to publish_branch, then push
commit_message = f"Request to publish changes to {process_model_id}, from {g.user.username}" commit_message = f"Request to publish changes to {process_model_id}, from {g.user.username}"
cls.commit(commit_message, destination_process_root) cls.commit(commit_message, destination_process_root)
os.system("git push") os.system("git push") # noqa
# build url for github page to open PR # build url for github page to open PR
output = os.popen("git config --get remote.origin.url").read() output = os.popen("git config --get remote.origin.url").read() # noqa
remote_url = output.strip().replace(".git", "") remote_url = output.strip().replace(".git", "")
pr_url = f"{remote_url}/compare/{publish_branch}?expand=1" pr_url = f"{remote_url}/compare/{publish_branch}?expand=1"

View File

@ -2664,7 +2664,7 @@ class TestProcessApi(BaseTest):
assert "process_model.json" in listing assert "process_model.json" in listing
assert "new_file.txt" in listing assert "new_file.txt" in listing
modified_process_model_id = process_model_identifier.replace("/", ":") # modified_process_model_id = process_model_identifier.replace("/", ":")
# response = client.post( # response = client.post(
# f"/v1.0/process-models/{modified_process_model_id}/publish?branch_to_update=staging", # f"/v1.0/process-models/{modified_process_model_id}/publish?branch_to_update=staging",
# headers=self.logged_in_headers(with_super_admin_user), # headers=self.logged_in_headers(with_super_admin_user),

View File

@ -29,4 +29,4 @@ cypress/screenshots
/test*.json /test*.json
# Editors # Editors
.idea .idea

View File

@ -41,4 +41,3 @@
--> -->
</body> </body>
</html> </html>

View File

@ -370,4 +370,3 @@ svg.notification-icon {
.tag-type-green:hover { .tag-type-green:hover {
background-color: #80ee90; background-color: #80ee90;
} }