Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: "CHANGELOG.md|.copier-answers.yml"
default_stages: [commit]
default_stages: [pre-commit]

ci:
autofix_commit_msg: "chore(pre-commit.ci): auto fixes"
autoupdate_commit_msg: "chore(pre-commit.ci): pre-commit autoupdate"

repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.30.1
rev: v4.13.10
hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: debug-statements
- id: check-builtin-literals
Expand All @@ -28,37 +28,37 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-poetry/poetry
rev: 1.8.4
rev: 2.3.2
hooks:
- id: poetry-check
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
rev: v4.0.0-alpha.8
hooks:
- id: prettier
args: ["--tab-width", "2"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
rev: v2.3.3
hooks:
- id: autoflake
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
rev: 8.0.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.12.1
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.3.1
hooks:
- id: black
# - repo: https://github.com/codespell-project/codespell
# rev: v2.2.6
# hooks:
# - id: codespell
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.3.0
hooks:
- id: flake8
# - repo: https://github.com/pre-commit/mirrors-mypy
Expand All @@ -67,12 +67,12 @@ repos:
# - id: mypy
# additional_dependencies: ["types-aiofiles"]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
rev: 1.9.4
hooks:
- id: bandit
args: [-x, tests]
- repo: https://github.com/srstevenson/nb-clean
rev: "3.3.0"
rev: "4.0.1"
hooks:
- id: nb-clean
args: [--preserve-cell-outputs]
17 changes: 15 additions & 2 deletions src/ut_course_catalog/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@ def parse_scoring_method(text: str | None) -> set[ScoringMethod]:
ScoringMethod.課題: ["課題", "assign", "宿題"],
ScoringMethod.レポート: ["レポート", "レポ", "report"],
ScoringMethod.発表: ["発表", "presenta", "プレゼン"],
ScoringMethod.出席: ["出席", "発表", "参加", "attend", "平常", "出欠", "リアペ", "リアクション"],
ScoringMethod.出席: [
"出席",
"発表",
"参加",
"attend",
"平常",
"出欠",
"リアペ",
"リアクション",
],
}
result: set[ScoringMethod] = set()
if text is None:
Expand Down Expand Up @@ -95,7 +104,11 @@ def encode_common_code(common_codes: pd.Series[CommonCode]) -> pd.DataFrame:
def to_perfect_dataframe(df: pd.DataFrame) -> pd.DataFrame:
df = df.copy()
df = pd.concat(
[df, encode_scoring_method(df["成績評価方法"]), encode_common_code(df["共通科目コード"])],
[
df,
encode_scoring_method(df["成績評価方法"]),
encode_common_code(df["共通科目コード"]),
],
axis=1,
)
return df
Expand Down
6 changes: 4 additions & 2 deletions src/ut_course_catalog/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ async def wait(self) -> None:

def wraps(
self,
func: WrappedFn[WrappedFnParam, WrappedFnResult]
| WrappedAwaitableFn[WrappedFnParam, WrappedFnResult],
func: (
WrappedFn[WrappedFnParam, WrappedFnResult]
| WrappedAwaitableFn[WrappedFnParam, WrappedFnResult]
),
) -> WrappedFn[WrappedFnParam, WrappedFnResult]:
@wraps(func)
async def wrapper(
Expand Down
17 changes: 12 additions & 5 deletions src/ut_course_catalog/ja.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ def _parse_weekday_period(period_text: str) -> set[tuple[Weekday, int]]:
period_texts = period_text.split("、")

def parse_one(period: str) -> tuple[Weekday, int] | None:
w = Weekday([weekday in period for weekday in list("月火水木金土日")].index(True))
w = Weekday(
[weekday in period for weekday in list("月火水木金土日")].index(True)
)
reres = re.search(r"\d+", period)
if not reres:
# raise ValueError(f"Invalid period: {period}")
Expand Down Expand Up @@ -778,7 +780,9 @@ def iterable_or_type_to_iterable(
x.value * 100 + 1000 for x in iterable_or_type_to_iterable(params.曜日)
]
if params.講義使用言語:
facet["course_language_codes"] = iterable_or_type_to_iterable(params.講義使用言語)
facet["course_language_codes"] = iterable_or_type_to_iterable(
params.講義使用言語
)
if params.実務経験のある教員による授業科目:
facet["operational_experience_flag"] = iterable_or_type_to_iterable(
params.実務経験のある教員による授業科目
Expand Down Expand Up @@ -1094,8 +1098,9 @@ async def fetch_search_detail_all(
*,
year: int = current_fiscal_year(),
use_tqdm: bool = True,
on_initial_request: None
| (Callable[[SearchResult], Awaitable[None] | None]) = None,
on_initial_request: None | (
Callable[[SearchResult], Awaitable[None] | None]
) = None,
on_detail_request: Callable[[Details], Awaitable[None] | None] | None = None,
) -> Iterable[Details]:
"""Fetch all search results by repeatedly calling `fetch_search` and `fetch_detail`.
Expand Down Expand Up @@ -1144,7 +1149,9 @@ async def on_initial_request_wrapper(search_result: SearchResult):
async def inner(item):
async with s:
try:
details = await self.retry(self.fetch_detail)(item.時間割コード, year)
details = await self.retry(self.fetch_detail)(
item.時間割コード, year
)
except Exception as e:
self._logger.error(e)
return None
Expand Down
Loading