feat(api): 공개 함수를 패키지 최상위로 재export - #20
Merged
Merged
Conversation
README·결과보고서는 parse·simplify·score·verify·match·render_html 을 "공개 함수 6개"
로 소개하는데, ttobak/__init__.py 에는 __version__ 밖에 없어서 `from ttobak import
simplify` 가 ImportError 였다. 서브모듈 경로를 아는 사람만 코어를 가져다 쓸 수 있었고,
README 어디에도 import 예제가 없었다.
parse 만 제외한다. `ttobak.parse` 는 서브패키지 이름이기도 해서 최상위 이름을 함수로
덮으면 `import ttobak.parse.pdf_parser` 가 깨진다(실제로 재export 를 넣자 pdfminer
폴백 테스트가 죽었다). 하나의 이름이 모듈이면서 함수일 수는 없으므로 parse 는 모듈
경로를 정본으로 둔다. 서브패키지 리네임은 파괴적 변경이라 별도 결정 사항이다.
README 에 실제로 실행되는 예제를 넣었다 — get_provider("fake") 는 기본 응답이 없으면
IndexError 라, 예제도 그대로 돌려보고 default 를 넘기도록 고쳤다. 테스트 수 표기도
417 → 427 로 동기화했다(배지 alt 텍스트 포함, 세 곳 모두).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
문제
README 는 "공개 함수 6개"를 아키텍처의 중심으로 소개하는데, 정작 패키지 최상위에는
아무것도 없었다.
서브모듈 경로를 아는 사람만 코어를 가져다 쓸 수 있었고, README 에 import 예제도 없었다.
"복지단체·도서관·개발자·연구자가 확장 가능"하다는 재사용성 주장의 실제 진입로가 비어 있었다.
바꾼 것
다섯 함수(
simplifyscoreverifymatchrender_html)를 최상위로 재export 하고__all__을 선언했다. 정본은 각 서브모듈이며 여기서는 이름만 다시 노출한다 —pipeline이 monkeypatch 를 위해score/verify를 모듈 레벨로 들고 있는 구조는건드리지 않았다(테스트로 동일성 고정).
parse는 왜 빠졌나ttobak.parse는 서브패키지 이름이기도 하다. 최상위 이름을 함수로 덮자 곧바로회귀가 났다:
하나의 이름이 모듈이면서 함수일 수는 없다. 마감을 앞두고 서브패키지를 리네임하는 것은
파괴적 변경이라 별도 결정 사항으로 두고,
parse는from ttobak.parse import parse를정본으로 유지한다. 이 제약을 테스트로 고정해 두었다 —
test_parse_stays_a_traversable_subpackage가 앞으로 누가 최상위로 올리면 잡는다.README 예제는 실제로 돌려봤다
처음 쓴 예제는 실행하면 죽었다:
get_provider("fake")는 기본 응답이 없으면 큐가 비는 즉시 던진다. 예제를 고쳐default=를 넘기게 했고, 문서에 실린 코드 그대로 실행해 통과를 확인했다(
verdict: pass).테스트 수 표기도 417 → 427 로 동기화했다(배지 alt 텍스트 포함 세 곳).
검증
pytest -q→ 427 passed (423 + 신규 4)ruff check→ cleanverdict: pass