From 580bf81c1542adbf1646622cc4a03e22f28dcdf6 Mon Sep 17 00:00:00 2001 From: erik Date: Thu, 20 Apr 2023 16:50:31 +0200 Subject: [PATCH] Fix CI: Remove whitespaces, add newlines --- src/main/python/ddadevops/application/__init__.py | 2 +- src/main/python/ddadevops/devops_build.py | 2 +- src/main/python/ddadevops/domain/__init__.py | 2 +- src/main/python/ddadevops/domain/release.py | 4 ++-- .../python/ddadevops/infrastructure/__init__.py | 2 +- .../ddadevops/infrastructure/infrastructure.py | 2 +- .../infrastructure/release_mixin/__init__.py | 2 +- .../release_mixin/infrastructure_api.py | 10 +++++----- .../ddadevops/infrastructure/release_mixin/repo.py | 14 +++++++------- src/test/python/release_mixin/__init__.py | 2 +- src/test/python/release_mixin/helper.py | 4 ++-- src/test/python/release_mixin/mock_domain.py | 1 - .../python/release_mixin/mock_infrastructure.py | 6 +++--- .../release_mixin/mock_infrastructure_api.py | 8 ++++---- .../python/release_mixin/test_infrastructure.py | 3 +-- .../release_mixin/test_infrastructure_api.py | 6 +++--- .../python/release_mixin/test_release_mixin.py | 8 ++++---- src/test/python/release_mixin/test_services.py | 2 +- src/test/python/test_c4k_mixin.py | 3 +-- 19 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/main/python/ddadevops/application/__init__.py b/src/main/python/ddadevops/application/__init__.py index 73018ad..6159750 100644 --- a/src/main/python/ddadevops/application/__init__.py +++ b/src/main/python/ddadevops/application/__init__.py @@ -1,2 +1,2 @@ from .image_build_service import ImageBuildService -from .release_mixin_services import TagAndPushReleaseService, PrepareReleaseService \ No newline at end of file +from .release_mixin_services import TagAndPushReleaseService, PrepareReleaseService diff --git a/src/main/python/ddadevops/devops_build.py b/src/main/python/ddadevops/devops_build.py index 8485bc4..cc3f860 100644 --- a/src/main/python/ddadevops/devops_build.py +++ b/src/main/python/ddadevops/devops_build.py @@ -21,7 +21,7 @@ def get_devops_build(project): @deprecation.deprecated(deprecated_in="3.2") -# TODO: Remove from here! +# TODO: Remove from here! # pylint: disable=W0511 def get_tag_from_latest_commit(): try: value = run( diff --git a/src/main/python/ddadevops/domain/__init__.py b/src/main/python/ddadevops/domain/__init__.py index 8eaba18..c584453 100644 --- a/src/main/python/ddadevops/domain/__init__.py +++ b/src/main/python/ddadevops/domain/__init__.py @@ -1,4 +1,4 @@ from .common import Validateable, DnsRecord, Devops from .image import Image from .c4k import C4k -from .release import Release, ReleaseConfig, ReleaseType, Version, EnvironmentKeys \ No newline at end of file +from .release import Release, ReleaseConfig, ReleaseType, Version, EnvironmentKeys diff --git a/src/main/python/ddadevops/domain/release.py b/src/main/python/ddadevops/domain/release.py index 67da3ef..7f9baf0 100644 --- a/src/main/python/ddadevops/domain/release.py +++ b/src/main/python/ddadevops/domain/release.py @@ -69,13 +69,13 @@ class ReleaseConfig(Validateable): main_branch: str, config_file: str, devops: Devops, - release_version: Optional[str | None] = None, + release_version: Optional[str | None] = None, bump_version: Optional[str | None] = None ): self.main_branch = main_branch self.config_file = config_file self.release_version = release_version - self.bump_version = bump_version + self.bump_version = bump_version self.devops = devops class Release(): diff --git a/src/main/python/ddadevops/infrastructure/__init__.py b/src/main/python/ddadevops/infrastructure/__init__.py index 2b6d1de..10deeea 100644 --- a/src/main/python/ddadevops/infrastructure/__init__.py +++ b/src/main/python/ddadevops/infrastructure/__init__.py @@ -1 +1 @@ -from .infrastructure import FileApi, ImageApi, ResourceApi, ExecutionApi, ProjectRepository \ No newline at end of file +from .infrastructure import FileApi, ImageApi, ResourceApi, ExecutionApi, ProjectRepository diff --git a/src/main/python/ddadevops/infrastructure/infrastructure.py b/src/main/python/ddadevops/infrastructure/infrastructure.py index b329ae5..c8bc41e 100644 --- a/src/main/python/ddadevops/infrastructure/infrastructure.py +++ b/src/main/python/ddadevops/infrastructure/infrastructure.py @@ -32,7 +32,7 @@ class ProjectRepository: def get_release(self, project) -> ReleaseConfig: return project.get_property("release_build") - + def set_release(self, project, build: ReleaseConfig): project.set_property("release_build", build) diff --git a/src/main/python/ddadevops/infrastructure/release_mixin/__init__.py b/src/main/python/ddadevops/infrastructure/release_mixin/__init__.py index 8d31c07..8d6598a 100644 --- a/src/main/python/ddadevops/infrastructure/release_mixin/__init__.py +++ b/src/main/python/ddadevops/infrastructure/release_mixin/__init__.py @@ -1,2 +1,2 @@ from .infrastructure_api import FileHandler, SystemApi, EnvironmentApi, GitApi, JsonFileHandler, GradleFileHandler, PythonFileHandler, ClojureFileHandler -from .repo import VersionRepository, ReleaseRepository, ReleaseTypeRepository \ No newline at end of file +from .repo import VersionRepository, ReleaseRepository, ReleaseTypeRepository diff --git a/src/main/python/ddadevops/infrastructure/release_mixin/infrastructure_api.py b/src/main/python/ddadevops/infrastructure/release_mixin/infrastructure_api.py index 3b0a5d6..d4c8ca1 100644 --- a/src/main/python/ddadevops/infrastructure/release_mixin/infrastructure_api.py +++ b/src/main/python/ddadevops/infrastructure/release_mixin/infrastructure_api.py @@ -197,11 +197,11 @@ class SystemApi(): stderr=sub.PIPE, text=True, encoding="UTF-8") - if stream.stdout is not None: + if stream.stdout is not None: self.stdout = stream.stdout.readlines() else: self.stdout = None - if stream.stderr is not None: + if stream.stderr is not None: self.stderr = stream.stderr.readlines() else: self.stderr = None @@ -246,7 +246,7 @@ class GitApi(): def init(self, default_branch: str = "main"): self.system_api.run_checked('git', 'init', '-b', default_branch) - + def set_user_config(self, email: str, name: str): self.system_api.run_checked('git', 'config', 'user.email', email) self.system_api.run_checked('git', 'config', 'user.name', name) @@ -279,6 +279,6 @@ class EnvironmentApi(): def get(self, key): return self.environ.get(key) - + def set(self, key, value): - self.environ[key] = value \ No newline at end of file + self.environ[key] = value diff --git a/src/main/python/ddadevops/infrastructure/release_mixin/repo.py b/src/main/python/ddadevops/infrastructure/release_mixin/repo.py index e32c4f9..80bd461 100644 --- a/src/main/python/ddadevops/infrastructure/release_mixin/repo.py +++ b/src/main/python/ddadevops/infrastructure/release_mixin/repo.py @@ -8,28 +8,28 @@ class VersionRepository(): def __init__(self, file): self.file = file self.file_handler = None - + def load_file(self): self.file_handler = FileHandler.from_file_path(self.file) return self.file_handler def write_file(self, version_string): if self.file_handler is None: - raise Exception('Version was not created by load_file method.') + raise Exception('Version was not created by load_file method.') else: self.file_handler.write(version_string) - + def parse_file(self): version_list, is_snapshot = self.file_handler.parse() return version_list, is_snapshot - + def get_version(self) -> Version: self.file_handler = self.load_file() version_list, is_snapshot = self.parse_file() version = Version(self.file, version_list) version.is_snapshot = is_snapshot - + return version class ReleaseTypeRepository(): @@ -50,7 +50,7 @@ class ReleaseTypeRepository(): releaseTypeRepo = cls(environment_api=environment_api) releaseTypeRepo.get_from_env = True return releaseTypeRepo - + def __get_release_type_git(self) -> ReleaseType | None: latest_commit = self.git_api.get_latest_commit() @@ -87,7 +87,7 @@ class ReleaseTypeRepository(): elif self.get_from_env: return self.__get_release_type_environment() else: - raise ValueError('No valid api passed to ReleaseTypeRepository') + raise ValueError('No valid api passed to ReleaseTypeRepository') class ReleaseRepository(): def __init__(self, version_repository: VersionRepository, release_type_repository: ReleaseTypeRepository, main_branch: str): diff --git a/src/test/python/release_mixin/__init__.py b/src/test/python/release_mixin/__init__.py index 9b7968b..1514703 100644 --- a/src/test/python/release_mixin/__init__.py +++ b/src/test/python/release_mixin/__init__.py @@ -1,2 +1,2 @@ from .mock_infrastructure import MockReleaseRepository, MockReleaseTypeRepository, MockVersionRepository -from .mock_infrastructure_api import MockGitApi \ No newline at end of file +from .mock_infrastructure_api import MockGitApi diff --git a/src/test/python/release_mixin/helper.py b/src/test/python/release_mixin/helper.py index 8009e18..5c41a79 100644 --- a/src/test/python/release_mixin/helper.py +++ b/src/test/python/release_mixin/helper.py @@ -6,8 +6,8 @@ class Helper(): def __init__(self, file_name = 'config.json'): self.TEST_FILE_NAME = file_name self.TEST_FILE_ROOT = Path('src/test/resources/') - self.TEST_FILE_PATH = self.TEST_FILE_ROOT / self.TEST_FILE_NAME + self.TEST_FILE_PATH = self.TEST_FILE_ROOT / self.TEST_FILE_NAME def copy_files(self, source: Path, target: Path): api = SystemApi() - api.run_checked('cp', source, target) \ No newline at end of file + api.run_checked('cp', source, target) diff --git a/src/test/python/release_mixin/mock_domain.py b/src/test/python/release_mixin/mock_domain.py index dc676fd..e350a7b 100644 --- a/src/test/python/release_mixin/mock_domain.py +++ b/src/test/python/release_mixin/mock_domain.py @@ -39,4 +39,3 @@ class MockRelease(): def is_valid(self, main_branch): return len(self.validate(main_branch)) < 1 - diff --git a/src/test/python/release_mixin/mock_infrastructure.py b/src/test/python/release_mixin/mock_infrastructure.py index 6d03180..9d7891f 100644 --- a/src/test/python/release_mixin/mock_infrastructure.py +++ b/src/test/python/release_mixin/mock_infrastructure.py @@ -9,14 +9,14 @@ class MockVersionRepository(): self.file = None self.file_handler = None self.write_file_count = 0 - + def load_file(self): pass def write_file(self, version_string): self.write_file_count += 1 pass - + def parse_file(self): pass @@ -39,4 +39,4 @@ class MockReleaseRepository(): def get_release(self) -> MockRelease: self.get_release_count += 1 - return MockRelease(self.release_type_repository.get_release_type(), self.version_repository.get_version(), self.main_branch) \ No newline at end of file + return MockRelease(self.release_type_repository.get_release_type(), self.version_repository.get_version(), self.main_branch) diff --git a/src/test/python/release_mixin/mock_infrastructure_api.py b/src/test/python/release_mixin/mock_infrastructure_api.py index 7f84571..368203b 100644 --- a/src/test/python/release_mixin/mock_infrastructure_api.py +++ b/src/test/python/release_mixin/mock_infrastructure_api.py @@ -17,7 +17,7 @@ class MockGitApi(): self.system_api = MockSystemApi() self.get_latest_commit_count = 0 self.commit_string = commit_string - self.tag_annotated_count = 0 + self.tag_annotated_count = 0 self.add_file_count = 0 self.commit_count = 0 self.push_count = 0 @@ -30,9 +30,9 @@ class MockGitApi(): return self.commit_string def tag_annotated(self, annotation: str, message: str, count: int): - self.tag_annotated_count += 1 + self.tag_annotated_count += 1 return " " - + def tag_annotated_second_last(self, annotation: str, message: str): self.tag_annotated(annotation, message, 1) return " " @@ -70,4 +70,4 @@ class MockEnvironmentApi(): return self.environ.get(name) def set(self, name, value): - self.environ[name] = value \ No newline at end of file + self.environ[name] = value diff --git a/src/test/python/release_mixin/test_infrastructure.py b/src/test/python/release_mixin/test_infrastructure.py index da427b3..b008ef0 100644 --- a/src/test/python/release_mixin/test_infrastructure.py +++ b/src/test/python/release_mixin/test_infrastructure.py @@ -15,7 +15,7 @@ def test_version_repository(tmp_path): def test_release_repository(tmp_path): - # init + # init th = Helper() th.copy_files( th.TEST_FILE_PATH, tmp_path) version_repo = VersionRepository(th.TEST_FILE_PATH) @@ -83,4 +83,3 @@ def test_release_type_repository_env(): release_type = sut.get_release_type() except: assert release_type == None - \ No newline at end of file diff --git a/src/test/python/release_mixin/test_infrastructure_api.py b/src/test/python/release_mixin/test_infrastructure_api.py index e983fac..f2ba909 100644 --- a/src/test/python/release_mixin/test_infrastructure_api.py +++ b/src/test/python/release_mixin/test_infrastructure_api.py @@ -11,13 +11,13 @@ def change_test_dir( tmp_path: Path, monkeypatch: pt.MonkeyPatch): monkeypatch.chdir(tmp_path) def test_environment_api(): - # init + # init env_api = EnvironmentApi() key = "TEST_ENV_KEY" value = "data" env_api.set(key, value) - #test + #test assert env_api.get(key) == value def test_git_api(tmp_path: Path, monkeypatch: pt.MonkeyPatch): @@ -26,7 +26,7 @@ def test_git_api(tmp_path: Path, monkeypatch: pt.MonkeyPatch): th.copy_files(th.TEST_FILE_PATH, tmp_path) # change the context of the script execution to tmp_path - change_test_dir(tmp_path, monkeypatch) + change_test_dir(tmp_path, monkeypatch) git_api = GitApi() git_api.init() diff --git a/src/test/python/release_mixin/test_release_mixin.py b/src/test/python/release_mixin/test_release_mixin.py index b56fe5f..d681d4a 100644 --- a/src/test/python/release_mixin/test_release_mixin.py +++ b/src/test/python/release_mixin/test_release_mixin.py @@ -25,7 +25,7 @@ def initialize_with_object(project, CONFIG_FILE): devops = Devops(STAGE, PROJECT_ROOT_PATH, MODULE, "release_test", BUILD_DIR_NAME) release_config = ReleaseConfig(MAIN_BRANCH, CONFIG_FILE, devops) build = MyBuild(project, release_config=release_config) - return build + return build def test_release_mixin_git(tmp_path: Path, monkeypatch: pt.MonkeyPatch): @@ -34,7 +34,7 @@ def test_release_mixin_git(tmp_path: Path, monkeypatch: pt.MonkeyPatch): th.copy_files(th.TEST_FILE_PATH, tmp_path) th.TEST_FILE_PATH = tmp_path / th.TEST_FILE_NAME - change_test_dir(tmp_path, monkeypatch) + change_test_dir(tmp_path, monkeypatch) project = Project(tmp_path) git_api = GitApi() @@ -57,7 +57,7 @@ def test_release_mixin_environment(tmp_path: Path, monkeypatch: pt.MonkeyPatch): th.copy_files(th.TEST_FILE_PATH, tmp_path) th.TEST_FILE_PATH = tmp_path / th.TEST_FILE_NAME - change_test_dir(tmp_path, monkeypatch) + change_test_dir(tmp_path, monkeypatch) project = Project(tmp_path) git_api = GitApi() @@ -68,7 +68,7 @@ def test_release_mixin_environment(tmp_path: Path, monkeypatch: pt.MonkeyPatch): environment_api = EnvironmentApi() environment_api.set("DDADEVOPS_RELEASE_TYPE", "MAJOR") - + build = initialize_with_object(project, th.TEST_FILE_PATH) build.prepare_release() release_version = build.prepare_release_service.release_repo.version_repository.get_version() diff --git a/src/test/python/release_mixin/test_services.py b/src/test/python/release_mixin/test_services.py index 00b8380..5aff9ac 100644 --- a/src/test/python/release_mixin/test_services.py +++ b/src/test/python/release_mixin/test_services.py @@ -25,7 +25,7 @@ def test_prepare_release_service(): assert prepare_release_service.release_repo.version_repository.write_file_count == 2 assert prepare_release_service.git_api.add_file_count == 2 assert prepare_release_service.git_api.commit_count == 2 - + def test_tag_and_push_release_service(): # init mock_release_repo = MockReleaseRepository(MockVersionRepository(), MockReleaseTypeRepository(MockGitApi()), 'main') diff --git a/src/test/python/test_c4k_mixin.py b/src/test/python/test_c4k_mixin.py index 2f5db38..59cf436 100644 --- a/src/test/python/test_c4k_mixin.py +++ b/src/test/python/test_c4k_mixin.py @@ -28,7 +28,7 @@ def test_c4k_mixin(tmp_path): add_c4k_mixin_config(project_config, config, auth, grafana_cloud_user='user', grafana_cloud_password='password') assert project_config.get('C4kMixin') is not None - + mixin = MyC4kMixin(project, project_config) mixin.initialize_build_dir() assert mixin.build_path() == f'{tmp_path_str}/{build_dir}/{project_name}/{module_name}' @@ -44,4 +44,3 @@ def test_c4k_mixin(tmp_path): mixin.write_c4k_auth() assert os.path.exists(f'{mixin.build_path()}/out_c4k_auth.yaml') - \ No newline at end of file