From 22b3257e526047059aeb4ca696134e56edf6185b Mon Sep 17 00:00:00 2001 From: Aleksey Lobanov Date: Sat, 9 Apr 2022 23:47:29 +0300 Subject: [PATCH] refactor: pre-commit run --- .github/workflows/ci.yml | 1 - .pre-commit-config.yaml | 2 +- CONTRIBUTING.md | 2 +- Readme.md | 4 ++-- gitea-mirror.py | 12 ++++++------ pyproject.toml | 2 +- requirements.dev.txt | 2 +- src/config.py | 1 + src/gitea_api.py | 6 +++--- src/models.py | 3 ++- src/repository_name.py | 4 ++-- src/sync.py | 4 ++-- tests/test_config.py | 4 ++-- tests/test_repository_name.py | 3 ++- 14 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e331681..a86f064 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,4 +21,3 @@ jobs: coverage xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13b007d..a19e713 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,4 +19,4 @@ repos: rev: 5.10.1 hooks: - id: isort - args: ["--filter-files" ] \ No newline at end of file + args: ["--filter-files" ] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2429b0..b20344b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ # Contributing Any issues and PRs are welcome. -Development environment recommendations are in Readme.md \ No newline at end of file +Development environment recommendations are in Readme.md diff --git a/Readme.md b/Readme.md index 91bc469..0c85af3 100644 --- a/Readme.md +++ b/Readme.md @@ -22,7 +22,7 @@ Other methods are not supporting: **Security notice.** This application uses SSH as git transport layer. It is safe enough with right use, -and for right use you need to save +and for right use you need to save git server ssh digest (~/.ssh/known_hosts file). To do this you just need to clone any repository over ssh first @@ -92,4 +92,4 @@ Token as the only one identifier is _good enough_ for 95% cases. - **A:** Using libraries for specific cases is a good practice in industry. And it keeps code simple and easy to verify (for bugs or malicious actions). - Which is much more important than one-time venv or Docker setup. \ No newline at end of file + Which is much more important than one-time venv or Docker setup. diff --git a/gitea-mirror.py b/gitea-mirror.py index fe5dfa9..cdbf0b7 100644 --- a/gitea-mirror.py +++ b/gitea-mirror.py @@ -1,13 +1,13 @@ import os.path import sys -from src.gitea_api import GiteaApi -from src.repository_name import get_repository_name, is_valid_repository_names -from src.config import Config, read_ini_config -from src.models import GiteaRepository -from src.git import git_pull, git_clone - from os import makedirs +from src.config import Config, read_ini_config +from src.git import git_clone, git_pull +from src.gitea_api import GiteaApi +from src.models import GiteaRepository +from src.repository_name import get_repository_name, is_valid_repository_names + BASE_PATH = "out" FORMAT = "{owner}/{name}" diff --git a/pyproject.toml b/pyproject.toml index dd6b36f..034a343 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,4 +7,4 @@ include = '.pyi?$' profile = "black" py_version = "auto" sections = "FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER" -known_local_folder = "src" \ No newline at end of file +known_local_folder = "src" diff --git a/requirements.dev.txt b/requirements.dev.txt index 89ffd17..fbc9b49 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,2 +1,2 @@ pytest~=7.1.1 -pytest-cov~=3.0.0 \ No newline at end of file +pytest-cov~=3.0.0 diff --git a/src/config.py b/src/config.py index b39858e..6062e26 100644 --- a/src/config.py +++ b/src/config.py @@ -14,6 +14,7 @@ ssh_key=/home/user/.ssh/id_rsa.pub import configparser import os + from .models import Config MAIN_SECTION = "main" diff --git a/src/gitea_api.py b/src/gitea_api.py index a88063b..43805a6 100644 --- a/src/gitea_api.py +++ b/src/gitea_api.py @@ -1,10 +1,10 @@ from typing import List -from .models import GiteaRepository from urllib.parse import urljoin -from pydantic import parse_obj_as - import requests +from pydantic import parse_obj_as + +from .models import GiteaRepository class GiteaApi: diff --git a/src/models.py b/src/models.py index 175b1a3..a4b8c46 100644 --- a/src/models.py +++ b/src/models.py @@ -1,6 +1,7 @@ -from pydantic import BaseModel, Field, HttpUrl import datetime +from pydantic import BaseModel, Field, HttpUrl + class Config(BaseModel): repository_format: str diff --git a/src/repository_name.py b/src/repository_name.py index e5a0dad..2fac7ae 100644 --- a/src/repository_name.py +++ b/src/repository_name.py @@ -1,8 +1,8 @@ -from .models import GiteaRepository, GiteaUser import datetime - from typing import List +from .models import GiteaRepository, GiteaUser + def _get_test_repository() -> GiteaRepository: return GiteaRepository( diff --git a/src/sync.py b/src/sync.py index 5a21075..65a919c 100644 --- a/src/sync.py +++ b/src/sync.py @@ -1,7 +1,7 @@ -from .models import GiteaRepository - from typing import List +from .models import GiteaRepository + class SyncProcessor: def __init__(self): diff --git a/tests/test_config.py b/tests/test_config.py index 53c6dde..bf52097 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,9 +1,9 @@ from tempfile import NamedTemporaryFile -from src.config import read_ini_config, Config - import pytest +from src.config import Config, read_ini_config + @pytest.mark.parametrize( "config_data, expected", diff --git a/tests/test_repository_name.py b/tests/test_repository_name.py index b9f61c7..bd61693 100644 --- a/tests/test_repository_name.py +++ b/tests/test_repository_name.py @@ -1,4 +1,5 @@ import pytest + from src.repository_name import is_valid_format @@ -11,4 +12,4 @@ from src.repository_name import is_valid_format ] ) def test_name_formatting(name_format, expected): - assert is_valid_format(name_format) == expected \ No newline at end of file + assert is_valid_format(name_format) == expected