Skip to content

feat(tables): index doc.tables by position - #463

Merged
airmang merged 1 commit into
mainfrom
feat/tables-namespace-index
Oct 15, 2026
Merged

airmang merged 1 commit into
mainfrom
feat/tables-namespace-index

Conversation

@airmang

@airmang airmang commented Oct 14, 2026

Copy link
Copy Markdown
Owner

바뀐 점

doc.tables는 반복과 len()은 되지만 번호로 꺼낼 수 없어서 doc.tables[0]이 TypeError를 냈다. python-docx처럼 doc.tables[0]로 첫 표를 꺼내는 코드가 그대로 동작하도록 번호와 조각을 받는다.

  • src/hwpx/_document/ns/tables.py: TablesNamespace.__getitem__ — int(음수는 끝에서부터)와 slice를 문서 순서로 받는다. doc.tables.all[...]와 같고, 범위 밖이면 IndexError. int는 표 하나, slice는 표 목록으로 타입을 나눠 적었다(overload).
  • CHANGELOG.md: [Unreleased] 추가에 한 항목.

테스트

  • tests/test_ns_tables.py: 번호·음수·조각이 문서 순서대로 표를 돌려주고 범위 밖이면 IndexError인 시험, 번호로 꺼낸 표를 고치면 문서에 남는 시험. 두 시험은 고치기 전 main에서 실패한다.
  • tests/test_stable_surface.py, tests/test_contract_docs_sync.py 통과. ruff·mypy·pyright 통과.

🤖 Generated with Claude Code

doc.tables iterated and had a length but could not be indexed, so
doc.tables[0] raised TypeError. It now takes an int (negative counts
from the end) or a slice, in document order, the same as
doc.tables.all[...]; an index out of range raises IndexError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@airmang airmang left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

df1e58b 검토 완료. __getitem__이 기존 all 목록에 위임하므로 음수·slice·IndexError와 문서 객체의 변경 반영 규약이 유지되는 것을 확인했습니다. 별도 Python 3.12 체크아웃에서 namespace/stable-surface/contract-docs 검사 160개가 통과했습니다. #462 병합 후 실제 최신 main 1ff5265를 로컬 검증 트리에 합친 상태에서도 같은 검사와 HWP 읽기·쓰기 회귀 검사를 포함한 431개가 통과했습니다. 최신 head의 GitHub 검사 13개는 모두 성공했고 미해결 리뷰 스레드가 없습니다. 병합을 막는 결함을 찾지 못했습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant