Skip to content

Commit 8acbc15

Browse files
committed
style: format project with black and isort
1 parent c50fc25 commit 8acbc15

27 files changed

Lines changed: 106 additions & 219 deletions

.flake8

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[flake8]
2+
max-line-length = 88
3+
4+
extend-ignore =
5+
E203,
6+
W503
7+
8+
exclude =
9+
.git,
10+
__pycache__,
11+
myenv,
12+
.pytest_cache,
13+
storage/solutions

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
4444
isort --check-only .
4545
46-
flake8 .
46+
flake8

.gitignore

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
.myenv/
2-
.env
31
__pycache__/
2+
3+
.pytest_cache/
4+
5+
.coverage
6+
7+
htmlcov/
8+
49
*.pyc
10+
511
logs/
6-
.vscode/
7-
.idea/
12+
13+
storage/
14+
15+
.env
16+
17+
.vscode/

config/settings.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from pathlib import Path
21
import os
2+
from pathlib import Path
33

44
from dotenv import load_dotenv
55

@@ -52,5 +52,3 @@ def validate(cls):
5252
for variable in required:
5353
if not getattr(cls, variable):
5454
raise ValueError(f"Missing environment variable: {variable}")
55-
56-

github_sync/manager.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from pathlib import Path
21
import shutil
32
import subprocess
3+
from pathlib import Path
44

55

66
class GitManager:
@@ -10,9 +10,7 @@ class GitManager:
1010

1111
def __init__(self, repository: Path):
1212
if shutil.which("git") is None:
13-
raise RuntimeError(
14-
"Git is not installed or not available in PATH."
15-
)
13+
raise RuntimeError("Git is not installed or not available in PATH.")
1614

1715
self.repository = Path(repository).resolve()
1816

@@ -44,4 +42,4 @@ def push(self) -> None:
4442
self.run("push")
4543

4644
def pull(self) -> None:
47-
self.run("pull")
45+
self.run("pull")

github_sync/messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ def generate_commit_message(detail) -> str:
33
f"feat(leetcode): solve "
44
f"{detail.question_id} - "
55
f"{detail.title_slug.replace('-', ' ').title()}"
6-
)
6+
)

leetcode/api.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
from config.settings import Config
2-
3-
from leetcode.parser import (
4-
parse_submissions,
5-
parse_submission_detail,
6-
)
7-
8-
from leetcode.queries import (
9-
PROFILE_QUERY,
10-
RECENT_SUBMISSIONS_QUERY,
11-
SUBMISSION_DETAILS_QUERY,
12-
)
2+
from leetcode.parser import parse_submission_detail, parse_submissions
3+
from leetcode.queries import (PROFILE_QUERY, RECENT_SUBMISSIONS_QUERY,
4+
SUBMISSION_DETAILS_QUERY)
135

146

157
class LeetCodeAPI:
@@ -21,9 +13,7 @@ def get_profile(self):
2113

2214
response = self.client.post(
2315
PROFILE_QUERY,
24-
{
25-
"username": Config.LEETCODE_USERNAME
26-
},
16+
{"username": Config.LEETCODE_USERNAME},
2717
)
2818

2919
if "errors" in response:
@@ -45,18 +35,14 @@ def get_recent_submissions(self, limit=15):
4535
if "errors" in response:
4636
raise Exception(response["errors"])
4737

48-
return parse_submissions(
49-
response["data"]["recentAcSubmissionList"]
50-
)
38+
return parse_submissions(response["data"]["recentAcSubmissionList"])
5139

5240
def get_submission_detail(self, submission_id):
5341
"""Fetch detailed information about a submission."""
5442

5543
response = self.client.post(
5644
SUBMISSION_DETAILS_QUERY,
57-
{
58-
"submissionId": int(submission_id)
59-
},
45+
{"submissionId": int(submission_id)},
6046
)
6147

6248
if "errors" in response:
@@ -65,4 +51,4 @@ def get_submission_detail(self, submission_id):
6551
return parse_submission_detail(
6652
submission_id,
6753
response["data"]["submissionDetails"],
68-
)
54+
)

leetcode/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ def __init__(self):
2626

2727
def get_session(self) -> Session:
2828
"""Return the configured session."""
29-
return self.session
29+
return self.session

leetcode/client.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from requests import Session
2+
23
from config.settings import Config
34

45

@@ -7,15 +8,10 @@ def __init__(self, session: Session):
78
self.session = session
89

910
def post(self, query: str, variables: dict = None):
10-
payload = {
11-
"query": query,
12-
"variables": variables or {}
13-
}
11+
payload = {"query": query, "variables": variables or {}}
1412

1513
response = self.session.post(
16-
Config.GRAPHQL_URL,
17-
json=payload,
18-
timeout=Config.REQUEST_TIMEOUT
14+
Config.GRAPHQL_URL, json=payload, timeout=Config.REQUEST_TIMEOUT
1915
)
2016
if Config.DEBUG:
2117

@@ -24,6 +20,4 @@ def post(self, query: str, variables: dict = None):
2420
print(response.text)
2521
print("=" * 80)
2622

27-
28-
29-
return response.json()
23+
return response.json()

leetcode/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
15: "Runtime Error",
88
16: "Internal Error",
99
20: "Compile Error",
10-
}
10+
}

0 commit comments

Comments
 (0)