Skip to content

Commit e33da15

Browse files
committed
chore: apply ruff lint auto-fixes
1 parent 769a2f9 commit e33da15

21 files changed

Lines changed: 68 additions & 63 deletions

ferry/args_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def load_yaml(parser: argparse.ArgumentParser):
369369
# Load YAML config as default args
370370
import yaml
371371

372-
with open(p.config_file, "r") as f:
372+
with open(p.config_file) as f:
373373
default_arg: dict[str, Any] = yaml.safe_load(f)
374374
key = vars(p).keys()
375375

@@ -379,7 +379,7 @@ def load_yaml(parser: argparse.ArgumentParser):
379379
return
380380
for k in default_arg.keys():
381381
if k not in key:
382-
print("WRONG ARG: {}".format(k))
382+
print(f"WRONG ARG: {k}")
383383
assert k in key
384384

385385
# Set default args

ferry/crawler/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def load_cache_json(path: Path):
2121
if not path.is_file():
2222
return None
2323

24-
with open(path, "r") as f:
24+
with open(path) as f:
2525
return ujson.load(f)
2626

2727

ferry/crawler/classes/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from pathlib import Path
2+
23
from httpx import AsyncClient
34
from tqdm import tqdm
45

56
from .fetch import (
6-
fetch_season_course_list,
77
fetch_all_season_courses_details,
88
fetch_cws_api,
9+
fetch_season_course_list,
910
)
10-
from .parse import parse_courses, ParsedCourse
11+
from .parse import ParsedCourse, parse_courses
1112

1213

1314
async def crawl_classes(

ferry/crawler/classes/fetch.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from httpx import AsyncClient
2-
from tqdm.asyncio import tqdm_asyncio
1+
import itertools
32
from pathlib import Path
4-
import ujson
53
from typing import Any
6-
import itertools
4+
5+
import ujson
6+
from httpx import AsyncClient
7+
from tqdm.asyncio import tqdm_asyncio
78

89
from ferry.crawler.cache import load_cache_json, save_cache_json
910
from ferry.crawler.cas_request import request

ferry/crawler/classes/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import logging
12
import re
23
import traceback
34
import warnings
45
from pathlib import Path
56
from typing import Any, TypedDict, cast
6-
import logging
77

88
import ujson
99
from bs4 import BeautifulSoup, MarkupResemblesLocatorWarning, ResultSet, Tag

ferry/crawler/evals/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from tqdm import tqdm
77

88
from ferry.crawler.cache import load_cache_json, save_cache_json
9-
from ferry.crawler.cas_request import CASClient, USER_AGENT
9+
from ferry.crawler.cas_request import USER_AGENT, CASClient
1010
from ferry.crawler.classes.parse import ParsedCourse
1111

1212
from .fetch import FetchError, fetch_course_evals

ferry/crawler/evals/fetch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def fetch_eval_page(
199199
questions_index = data_dir / "rating_cache" / "questions_index"
200200
html_file = questions_index / f"{season_code}_{crn}.html"
201201
if html_file.is_file():
202-
with open(html_file, "r") as file:
202+
with open(html_file) as file:
203203
return ast.literal_eval(file.read())
204204

205205
# OCE website for evaluations

ferry/crawler/seasons.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"""
44

55
import re
6+
from pathlib import Path
67

78
from httpx import AsyncClient
8-
from pathlib import Path
9+
910
from .cache import load_cache_json, save_cache_json
1011

1112
# -----------------------------------------

ferry/database/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@
66
)
77
from .models import (
88
Base,
9+
Building,
910
Course,
1011
EvaluationNarrative,
1112
EvaluationNarrativeSummary,
1213
EvaluationQuestion,
1314
EvaluationRating,
1415
EvaluationStatistics,
1516
Flag,
16-
course_meetings,
17-
Building,
18-
Location,
1917
Listing,
18+
Location,
2019
Professor,
2120
Season,
2221
course_flags,
22+
course_meetings,
2323
course_professors,
2424
)
25-
2625
from .sync_db_courses import sync_db_courses
2726
from .sync_db_courses_old import sync_db_courses_old
2827
from .sync_db_evals import sync_db_evals

ferry/database/database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import sqlalchemy
21
from contextlib import contextmanager
3-
from .models import Base
2+
3+
import sqlalchemy
44

55

66
class Database:

0 commit comments

Comments
 (0)