Skip to content

Commit

Permalink
Revert "feat: add ruff linter with ci check (#1178)" (#1181)
Browse files Browse the repository at this point in the history
This reverts commit a2c424a.
  • Loading branch information
spacewander authored Nov 25, 2024
1 parent a2c424a commit 6520331
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 241 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ jobs:
readarray -t changed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')"
~/go/bin/editorconfig-checker ${changed_files[@]}
- name: Lint and format Python with Ruff
uses: astral-sh/ruff-action@v1
typo:
runs-on: ubuntu-latest
Expand Down
6 changes: 1 addition & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,26 @@
import pytest
from helper import TempRepository


def create_repo(dirname=None):
def create_repo(dirname = None):
repo = TempRepository(dirname)
tmp_file_a = repo.create_tmp_file()
tmp_file_b = repo.create_tmp_file()
repo.switch_cwd_under_repo()
return repo


def init_repo_git_status(repo):
git = repo.get_repo_git()
git.add(".")
git.config("--local", "user.name", "test")
git.config("--local", "user.email", "[email protected]")
git.commit("-m", "chore: initial commit")


@pytest.fixture(scope="module")
def temp_repo():
repo = create_repo()
init_repo_git_status(repo)
return repo


@pytest.fixture(scope="module")
def named_temp_repo(request):
dirname = request.param
Expand Down
14 changes: 6 additions & 8 deletions tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
GITLAB_ORIGIN = "https://gitlab.com/tj/git-extras.git"
BITBUCKET_ORIGIN = "https://bitbucket.org/tj/git-extras.git"


class TempRepository:
def __init__(self, repo_work_dir=None):
def __init__(self, repo_work_dir = None):
self._system_tmpdir = tempfile.gettempdir()
if repo_work_dir == None:
repo_work_dir = tempfile.mkdtemp()
else:
repo_work_dir = os.path.join(self._system_tmpdir, repo_work_dir)
self._cwd = repo_work_dir
self._tempdirname = self._cwd[len(self._system_tmpdir) + 1 :]
self._tempdirname = self._cwd[len(self._system_tmpdir) + 1:]
self._git_repo = Repo.init(repo_work_dir, b="default")
self._files = []
self.change_origin_to_github()
Expand Down Expand Up @@ -51,7 +50,7 @@ def create_tmp_dir(self):
tmp_dir = tempfile.mkdtemp()
return tmp_dir

def create_tmp_file(self, temp_dir=None):
def create_tmp_file(self, temp_dir = None):
if temp_dir == None:
temp_dir = self._cwd

Expand Down Expand Up @@ -87,9 +86,8 @@ def invoke_installed_extras_command(self, name, *params):
origin_extras_command = os.path.join(GIT_EXTRAS_BIN, command_name)
temp_extras_command = os.path.join(self._cwd, command_name)
helpers = [
os.path.join(GIT_EXTRAS_HELPER, "git-extra-utility"),
os.path.join(GIT_EXTRAS_HELPER, "is-git-repo"),
]
os.path.join(GIT_EXTRAS_HELPER, "git-extra-utility"),
os.path.join(GIT_EXTRAS_HELPER, "is-git-repo")]

if not os.path.exists(temp_extras_command):
whole = []
Expand All @@ -108,7 +106,7 @@ def invoke_installed_extras_command(self, name, *params):
os.chmod(temp_extras_command, 0o775)

script = [temp_extras_command, *params]
print(f'Run the script "{script}"')
print(f"Run the script \"{script}\"")
return subprocess.run(script, capture_output=True)

def change_origin(self, origin_url):
Expand Down
63 changes: 0 additions & 63 deletions tests/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,66 +21,3 @@ testpaths = ["."]
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.9
target-version = "py39"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
select = ["E4", "E7", "E9", "F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
1 change: 0 additions & 1 deletion tests/test_git_abort.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from git import GitCommandError


class TestGitAbort:
def test_init(self, temp_repo):
git = temp_repo.get_repo_git()
Expand Down
32 changes: 14 additions & 18 deletions tests/test_git_archive_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os, pytest


class TestGitArchiveFile:
def test_init(self, temp_repo):
git = temp_repo.get_repo_git()
Expand All @@ -17,17 +16,14 @@ def test_archive_file_on_tags_branch(self, temp_repo):
filename = "{0}.{1}.zip".format(temp_repo.get_repo_dirname(), git.describe())
assert filename in os.listdir()

def test_archive_file_on_any_not_tags_branch_without_default_branch(
self, temp_repo
):
def test_archive_file_on_any_not_tags_branch_without_default_branch(self, temp_repo):
git = temp_repo.get_repo_git()
git.checkout("-b", "not-tags-branch")
temp_repo.invoke_installed_extras_command("archive-file")
filename = "{0}.{1}.{2}.zip".format(
temp_repo.get_repo_dirname(),
git.describe("--always", "--long"),
"not-tags-branch",
)
temp_repo.get_repo_dirname(),
git.describe("--always", "--long"),
"not-tags-branch")
assert filename in os.listdir()

def test_archive_file_on_any_not_tags_branch_with_default_branch(self, temp_repo):
Expand All @@ -36,28 +32,28 @@ def test_archive_file_on_any_not_tags_branch_with_default_branch(self, temp_repo
git.config("git-extras.default-branch", "default")
temp_repo.invoke_installed_extras_command("archive-file")
filename = "{0}.{1}.zip".format(
temp_repo.get_repo_dirname(), git.describe("--always", "--long")
)
temp_repo.get_repo_dirname(),
git.describe("--always", "--long"))
assert filename in os.listdir()

def test_archive_file_on_branch_name_has_slash(self, temp_repo):
git = temp_repo.get_repo_git()
git.checkout("-b", "feature/slash")
temp_repo.invoke_installed_extras_command("archive-file")
filename = "{0}.{1}.{2}.zip".format(
temp_repo.get_repo_dirname(),
git.describe("--always", "--long"),
"feature-slash",
)
temp_repo.get_repo_dirname(),
git.describe("--always", "--long"),
"feature-slash")
assert filename in os.listdir()

@pytest.mark.parametrize("named_temp_repo", ["backslash\\dir"], indirect=True)
def test_archive_file_on_dirname_has_backslash(self, named_temp_repo):
named_temp_repo.invoke_installed_extras_command("archive-file")
git = named_temp_repo.get_repo_git()
filename = "{0}.{1}.{2}.zip".format(
"backslash-dir", git.describe("--always", "--long"), "default"
)
"backslash-dir",
git.describe("--always", "--long"),
"default")
assert filename in os.listdir()

def test_archive_file_on_tag_name_has_slash(self, temp_repo):
Expand All @@ -69,6 +65,6 @@ def test_archive_file_on_tag_name_has_slash(self, temp_repo):
temp_repo.invoke_installed_extras_command("archive-file")
description_include_version = git.describe("--always", "--long")
filename = "{0}.{1}.zip".format(
temp_repo.get_repo_dirname(), description_include_version.replace("/", "-")
)
temp_repo.get_repo_dirname(),
description_include_version.replace("/", "-"))
assert filename in os.listdir()
5 changes: 1 addition & 4 deletions tests/test_git_authors.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import os, subprocess

expected_authors_list = (
"test <[email protected]>\ntestagain <[email protected]>\n"
)
expected_authors_list = "test <[email protected]>\ntestagain <[email protected]>\n"
expected_authors_list_without_email = "test\ntestagain\n"
authors_file = "AUTHORS"


class TestGitAuthors:
def test_init(self, temp_repo):
git = temp_repo.get_repo_git()
Expand Down
Loading

0 comments on commit 6520331

Please sign in to comment.