Skip to content

accept iterable inputs in write_lines type annotation - #259

Open
gheshm-jpg wants to merge 1 commit into
jaraco:mainfrom
gheshm-jpg:fix-write-lines-iterables
Open

gheshm-jpg wants to merge 1 commit into
jaraco:mainfrom
gheshm-jpg:fix-write-lines-iterables

Conversation

@gheshm-jpg

@gheshm-jpg gheshm-jpg commented Sep 16, 2026 •

Copy link
Copy Markdown

write_lines accepts tuples and generators at runtime, but its list[str] annotation makes mypy reject both. the implementation already forwards its input to _replace_linesep, which accepts Iterable[str].

this broadens the public annotation to Iterable[str] and updates the parameter documentation. a typed regression test writes a tuple, appends a generator, and checks newline normalization and the resulting file contents.

validation on macOS with Python 3.13.7:

  • a minimal tuple/generator caller produced two mypy argument errors before the change and passes afterward.
  • python -m pytest -q: 161 passed, 1 skipped, and 7 ruff failures. the unchanged base reports 160 passed, 1 skipped, and the same 7 ruff failures with Ruff 0.16.6.
  • git diff --check passed.

no runtime implementation changes.

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