remove useless comments matching filenames

This commit is contained in:
burnettk 2023-05-30 12:21:50 -04:00
parent a567b990e6
commit 7b2f75c349
73 changed files with 41 additions and 72 deletions

View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
# Function to check if a string matches the file name pattern
matches_filename_pattern() {
local file_name="$1"
local comment_line="$2"
# Remove file extension and capitalize the first letter
local expected_comment=$(basename "$file_name" .py)
expected_comment_with_first_letter_capitalized="${expected_comment^}"
if grep -Eq "\"\"\"${expected_comment}\.\"\"\"" <<< "$comment_line"; then
return 0
else
if grep -Eq "\"\"\"${expected_comment_with_first_letter_capitalized}\.\"\"\"" <<< "$comment_line"; then
return 0
else
return 1
fi
fi
}
# Process each Python file in the "src" and "tests" directories
for file in $(find src tests -type f -name '*.py'); do
# Read the first line of the file
read -r first_line < "$file"
# Check if the first line matches the expected comment pattern
if matches_filename_pattern "$file" "$first_line"; then
# Remove the comment from the file
hot_sed -i '1d' "$file"
fi
done

View File

@ -1,4 +1,3 @@
"""__init__."""
import base64 import base64
import faulthandler import faulthandler
import json import json

View File

@ -1,4 +1,3 @@
"""Default."""
import re import re
from os import environ from os import environ

View File

@ -1,2 +1 @@
"""Api_version."""
V1_API_PATH_PREFIX = "/v1.0" V1_API_PATH_PREFIX = "/v1.0"

View File

@ -1,4 +1,3 @@
"""Db_helper."""
import time import time
import sqlalchemy import sqlalchemy

View File

@ -1,4 +1,3 @@
"""Interfaces."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import NewType from typing import NewType
from typing import TypedDict from typing import TypedDict

View File

@ -1 +0,0 @@
"""__init__."""

View File

@ -1,4 +1,3 @@
"""Db."""
from __future__ import annotations from __future__ import annotations
import enum import enum

View File

@ -1,4 +1,3 @@
"""Group."""
from __future__ import annotations from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING

View File

@ -1,4 +1,3 @@
"""Human_task."""
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass

View File

@ -1,4 +1,3 @@
"""Human_task_user."""
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass

View File

@ -1,4 +1,3 @@
"""Message_instance."""
import enum import enum
from dataclasses import dataclass from dataclasses import dataclass
from typing import TYPE_CHECKING from typing import TYPE_CHECKING

View File

@ -1,4 +1,3 @@
"""Principal."""
from dataclasses import dataclass from dataclasses import dataclass
from sqlalchemy import ForeignKey from sqlalchemy import ForeignKey

View File

@ -1,4 +1,3 @@
"""Process_group."""
from __future__ import annotations from __future__ import annotations
import dataclasses import dataclasses

View File

@ -1,4 +1,3 @@
"""Process_instance."""
from __future__ import annotations from __future__ import annotations
from typing import Any from typing import Any

View File

@ -1,4 +1,3 @@
"""Process_instance_file_data."""
from dataclasses import dataclass from dataclasses import dataclass
from sqlalchemy import ForeignKey from sqlalchemy import ForeignKey

View File

@ -1,4 +1,3 @@
"""Process_instance_queue."""
from dataclasses import dataclass from dataclasses import dataclass
from sqlalchemy import ForeignKey from sqlalchemy import ForeignKey

View File

@ -1,4 +1,3 @@
"""Process_model."""
from __future__ import annotations from __future__ import annotations
import enum import enum

View File

@ -1,4 +1,3 @@
"""Refresh_token."""
from dataclasses import dataclass from dataclasses import dataclass
from sqlalchemy import ForeignKey from sqlalchemy import ForeignKey

View File

@ -1,4 +1,3 @@
"""Secret_model."""
from dataclasses import dataclass from dataclasses import dataclass
from marshmallow import Schema from marshmallow import Schema

View File

@ -1,4 +1,3 @@
"""Task."""
import enum import enum
from dataclasses import dataclass from dataclasses import dataclass
from typing import TYPE_CHECKING from typing import TYPE_CHECKING

View File

@ -1,4 +1,3 @@
"""User."""
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass

View File

@ -1 +0,0 @@
"""__init__."""

View File

@ -1,4 +1,3 @@
"""User."""
import ast import ast
import base64 import base64
import json import json

View File

@ -1,4 +1,3 @@
"""Users_controller."""
from typing import Any from typing import Any
import flask import flask

View File

@ -1,4 +1,3 @@
"""Delete_process_instances_with_criteria."""
from time import time from time import time
from typing import Any from typing import Any

View File

@ -1,4 +1,3 @@
"""Fact_service."""
from typing import Any from typing import Any
from spiffworkflow_backend.models.script_attributes_context import ScriptAttributesContext from spiffworkflow_backend.models.script_attributes_context import ScriptAttributesContext

View File

@ -1,4 +1,3 @@
"""Get_data_sizes."""
from typing import Any from typing import Any
from spiffworkflow_backend.models.script_attributes_context import ScriptAttributesContext from spiffworkflow_backend.models.script_attributes_context import ScriptAttributesContext

View File

@ -1,4 +1,3 @@
"""Get_encoded_file_data."""
import base64 import base64
from typing import Any from typing import Any

View File

@ -1,4 +1,3 @@
"""Get_env."""
from typing import Any from typing import Any
from spiffworkflow_backend.models.script_attributes_context import ScriptAttributesContext from spiffworkflow_backend.models.script_attributes_context import ScriptAttributesContext

View File

@ -1,4 +1,3 @@
"""Get_localtime."""
from datetime import datetime from datetime import datetime
from typing import Any from typing import Any

View File

@ -1,4 +1,3 @@
"""Get_secret."""
from typing import Any from typing import Any
from spiffworkflow_backend.models.script_attributes_context import ScriptAttributesContext from spiffworkflow_backend.models.script_attributes_context import ScriptAttributesContext

View File

@ -1,4 +1,3 @@
"""Markdown_file_download_link."""
from typing import Any from typing import Any
from flask import current_app from flask import current_app

View File

@ -1,4 +1,3 @@
"""Script."""
from __future__ import annotations from __future__ import annotations
import importlib import importlib

View File

@ -1,4 +1,3 @@
"""Acceptance_test_fixtures."""
import time import time
from flask import current_app from flask import current_app

View File

@ -1,4 +1,3 @@
"""Assertion_service."""
import contextlib import contextlib
from collections.abc import Generator from collections.abc import Generator

View File

@ -1,4 +1,3 @@
"""Background_processing_service."""
import flask import flask
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
from spiffworkflow_backend.services.message_service import MessageService from spiffworkflow_backend.services.message_service import MessageService

View File

@ -1,4 +1,3 @@
"""Custom_parser."""
from SpiffWorkflow.dmn.parser.BpmnDmnParser import BpmnDmnParser # type: ignore from SpiffWorkflow.dmn.parser.BpmnDmnParser import BpmnDmnParser # type: ignore
from SpiffWorkflow.spiff.parser.process import SpiffBpmnParser # type: ignore from SpiffWorkflow.spiff.parser.process import SpiffBpmnParser # type: ignore
from spiffworkflow_backend.specs.start_event import StartEvent from spiffworkflow_backend.specs.start_event import StartEvent

View File

@ -1,4 +1,3 @@
"""Data_setup_service."""
from flask import current_app from flask import current_app
from spiffworkflow_backend.models.db import db from spiffworkflow_backend.models.db import db
from spiffworkflow_backend.services.process_model_service import ProcessModelService from spiffworkflow_backend.services.process_model_service import ProcessModelService

View File

@ -1,4 +1,3 @@
"""Email_service."""
from flask import current_app from flask import current_app
from flask_mail import Message # type: ignore from flask_mail import Message # type: ignore

View File

@ -1,4 +1,3 @@
"""File_system_service."""
import os import os
from collections.abc import Generator from collections.abc import Generator
from contextlib import contextmanager from contextlib import contextmanager

View File

@ -1,4 +1,3 @@
"""Git_service."""
import os import os
import re import re
import shutil import shutil

View File

@ -1,4 +1,3 @@
"""Logging_service."""
import json import json
import logging import logging
import re import re

View File

@ -1,4 +1,3 @@
"""Message_service."""
from spiffworkflow_backend.models.db import db from spiffworkflow_backend.models.db import db
from spiffworkflow_backend.models.message_instance import MessageInstanceModel from spiffworkflow_backend.models.message_instance import MessageInstanceModel

View File

@ -1,4 +1,3 @@
"""Process_instance_processor."""
# TODO: clean up this service for a clear distinction between it and the process_instance_service # TODO: clean up this service for a clear distinction between it and the process_instance_service
# where this points to the pi service # where this points to the pi service
import decimal import decimal

View File

@ -1,4 +1,3 @@
"""Process_instance_report_service."""
import copy import copy
import re import re
from collections.abc import Generator from collections.abc import Generator

View File

@ -1,4 +1,3 @@
"""Process_instance_service."""
import base64 import base64
import hashlib import hashlib
import time import time

View File

@ -1,4 +1,3 @@
"""Process_model_service."""
import json import json
import os import os
import shutil import shutil

View File

@ -1,4 +1,3 @@
"""Secret_service."""
from flask import current_app from flask import current_app
from spiffworkflow_backend.exceptions.api_error import ApiError from spiffworkflow_backend.exceptions.api_error import ApiError

View File

@ -1,4 +1,3 @@
"""Spec_file_service."""
import os import os
import shutil import shutil
from datetime import datetime from datetime import datetime

View File

@ -1,4 +1,3 @@
"""User_service."""
from typing import Any from typing import Any
from flask import current_app from flask import current_app

View File

@ -1,4 +1,3 @@
"""workflow_service."""
from datetime import datetime from datetime import datetime
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow # type: ignore from SpiffWorkflow.bpmn.workflow import BpmnWorkflow # type: ignore

View File

@ -1 +0,0 @@
"""__init__."""

View File

@ -1,4 +1,3 @@
"""Base_test."""
import io import io
import json import json
import os import os

View File

@ -1,4 +1,3 @@
"""Example_data."""
import glob import glob
import os import os

View File

@ -1,4 +1,3 @@
"""Test_authentication."""
import ast import ast
import base64 import base64

View File

@ -1,4 +1,3 @@
"""Test_authorization."""
from tests.spiffworkflow_backend.helpers.base_test import BaseTest from tests.spiffworkflow_backend.helpers.base_test import BaseTest

View File

@ -1,4 +1,3 @@
"""Test_logging_service."""
from uuid import UUID from uuid import UUID
from flask.app import Flask from flask.app import Flask

View File

@ -1,4 +1,3 @@
"""Test_nested_groups."""
import json import json
from flask.app import Flask from flask.app import Flask

View File

@ -1,4 +1,3 @@
"""Test_secret_service."""
import json import json
import pytest import pytest

View File

@ -1,4 +1,3 @@
"""Test_user_blueprint."""
# TODO: fix these tests for new authing system # TODO: fix these tests for new authing system
# """Test User Blueprint.""" # """Test User Blueprint."""
# import json # import json

View File

@ -1,4 +1,3 @@
"""Test_users_controller."""
from flask.app import Flask from flask.app import Flask
from flask.testing import FlaskClient from flask.testing import FlaskClient
from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.models.user import UserModel

View File

@ -1,4 +1,3 @@
"""Test_acceptance_test_fixtures."""
import os import os
from flask.app import Flask from flask.app import Flask

View File

@ -1,4 +1,3 @@
"""Test_file."""
from datetime import datetime from datetime import datetime
from spiffworkflow_backend.models.file import File from spiffworkflow_backend.models.file import File

View File

@ -1,4 +1,3 @@
"""Test_message_instance."""
import pytest import pytest
from flask import Flask from flask import Flask
from flask.testing import FlaskClient from flask.testing import FlaskClient

View File

@ -1,4 +1,3 @@
"""Test_process_instance_processor."""
from uuid import UUID from uuid import UUID
import pytest import pytest

View File

@ -1,4 +1,3 @@
"""Test_process_instance_queue_service."""
import time import time
from contextlib import suppress from contextlib import suppress

View File

@ -1,4 +1,3 @@
"""Test_process_instance_report_service."""
import pytest import pytest
from flask import Flask from flask import Flask
from flask.testing import FlaskClient from flask.testing import FlaskClient

View File

@ -1,4 +1,3 @@
"""Test_process_model_service."""
from flask import Flask from flask import Flask
from spiffworkflow_backend.services.process_model_service import ProcessModelService from spiffworkflow_backend.services.process_model_service import ProcessModelService

View File

@ -1,4 +1,3 @@
"""Test_various_bpmn_constructs."""
from flask.app import Flask from flask.app import Flask
from flask.testing import FlaskClient from flask.testing import FlaskClient
from spiffworkflow_backend.services.process_instance_processor import ProcessInstanceProcessor from spiffworkflow_backend.services.process_instance_processor import ProcessInstanceProcessor

View File

@ -1,4 +1,3 @@
"""Test_workflow_service."""
from collections.abc import Generator from collections.abc import Generator
from datetime import datetime from datetime import datetime
from datetime import timedelta from datetime import timedelta