Skip to content

Commit

Permalink
Enhance flake8 and black checks in Makefile and adjust imports
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbeevip committed Nov 2, 2024
1 parent 557aed4 commit 733a508
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ init:
pip install . '.[lint]' '.[test]' '.[package]'

lint:
@pflake8 ./src
@pflake8 ./src ./tests ./gitlab_bot.py || (echo "Run 'make fmt' to fix the issues" && exit 1)
@black --check ./src ./tests ./gitlab_bot.py || (echo "Run 'make fmt' to fix the issues" && exit 1)

fmt:
@black ./src
@isort --profile black ./src
@$(MAKE) lint
@black ./src ./tests ./gitlab_bot.py
@isort --profile black ./src ./tests ./gitlab_bot.py

coverage: lint
@pytest --cov=an_copilot tests
Expand Down
10 changes: 8 additions & 2 deletions gitlab_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@

load_dotenv() # isort:skip

from src.config import bot_gitlab_username, bot_gitlab_url, bot_gitlab_token, bot_port, bot_host
from src.config import (
bot_gitlab_token,
bot_gitlab_url,
bot_gitlab_username,
bot_host,
bot_port,
)
from src.issue_hook import IssueHooks
from src.logs import print_event
from src.merge_request_hook import MergeRequestHooks
Expand Down Expand Up @@ -69,7 +75,7 @@ async def merge_request_updated_event(event, gl, *args, **kwargs):


@bot.router.register("Merge Request Hook", action="reopen")
async def merge_request_updated_event(event, gl, *args, **kwargs):
async def merge_request_reopen_event(event, gl, *args, **kwargs):
if not ignore_event(event):
await merge_request_hooks.merge_request_reopen_event(event, gl, args, kwargs)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ package = [

[tool.flake8]
max-line-length = 300
ignore = ['E231', 'E241', 'W291', 'W293', 'W503']
ignore = ['E231', 'E241', 'W291', 'W293', 'W503', 'E402']
per-file-ignores = [
'__init__.py:F401',
]
Expand Down
1 change: 0 additions & 1 deletion tests/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class TestLLM(TestCase):

def test_ai_diffs_summary(self):
with open("git_diff.json", "r") as f:
git_diff_json = json.loads(f.read())
Expand Down
9 changes: 6 additions & 3 deletions tests/test_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@


class TestPrompts(TestCase):

def test_load_prompt(self):
self.assertIn("你是一个精通多种编程语言的智能机器人", get_prompt_text("DIFFS_SUMMARY_PROMPTS_TEMPLATE", "zh"))
self.assertIn(
"你是一个精通多种编程语言的智能机器人",
get_prompt_text("DIFFS_SUMMARY_PROMPTS_TEMPLATE", "zh"),
)
self.assertIn(
"You are an intelligent robot proficient in multiple programming languages and good at reading git-dff reports",
get_prompt_text("DIFFS_SUMMARY_PROMPTS_TEMPLATE", "en"))
get_prompt_text("DIFFS_SUMMARY_PROMPTS_TEMPLATE", "en"),
)


if __name__ == "__main__":
Expand Down

0 comments on commit 733a508

Please sign in to comment.