Skip to content

Fixed join_continuation's parameter type annotation#28

Merged
jaraco merged 1 commit intojaraco:mainfrom
Avasam:allow-more-types-in-join_continuation
Feb 9, 2026
Merged

Fixed join_continuation's parameter type annotation#28
jaraco merged 1 commit intojaraco:mainfrom
Avasam:allow-more-types-in-join_continuation

Conversation

@Avasam
Copy link
Contributor

@Avasam Avasam commented Feb 8, 2026

This should solve a type issue with setuptools passing in a map[str] by accounting for more possible overloads of iter. Whilst also slightly simplifying type import.

This is the failing usage in setuptools:

from collections.abc import Iterable, Iterator

def parse_strings(strs: str | Iterable[str]) -> Iterator[str]:
    return text.join_continuation(map(text.drop_comment, text.yield_lines(strs)))

Normally I'd add a test with the above snippet to ensure it is caught statically (and that runtime matches the type expectation by not crashing), but I think this project uses docstring tests.

@Avasam Avasam force-pushed the allow-more-types-in-join_continuation branch from 30cb72a to d0c7054 Compare February 8, 2026 23:17
@Avasam Avasam marked this pull request as ready for review February 8, 2026 23:58
@Avasam Avasam force-pushed the allow-more-types-in-join_continuation branch from d0c7054 to d061705 Compare February 9, 2026 14:28
@Avasam Avasam changed the title allow more iterable types in join_continuation Allow more iterable types in join_continuation Feb 9, 2026
@Avasam Avasam force-pushed the allow-more-types-in-join_continuation branch from d061705 to 50292c1 Compare February 9, 2026 14:31
@jaraco
Copy link
Owner

jaraco commented Feb 9, 2026

Normally I'd add a test with the above snippet to ensure it is caught statically (and that runtime matches the type expectation by not crashing), but I think this project uses docstring tests.

Feel free to add a tests/test_core.py with any unit tests.

Copy link
Owner

@jaraco jaraco left a comment

Choose a reason for hiding this comment

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

It's clear to me that typing in Python requires its own expertise. Thanks for being that expert.

@Avasam Avasam force-pushed the allow-more-types-in-join_continuation branch 3 times, most recently from 4fdd69a to 4c7ee6e Compare February 9, 2026 16:32
@Avasam
Copy link
Contributor Author

Avasam commented Feb 9, 2026

You're welcome ! Btw if you ever need help and I'm not available (or it's more obscure than I can manage), https://github.com/python/typeshed/#discussion lists a few community resources. There's also the Python Discord and Astral Discord's typing channels.

Feel free to edit the test before merging. Also note that it's reliant on mypy config warn_unused_ignores = True for the "expecting a type error" part.

@Avasam Avasam force-pushed the allow-more-types-in-join_continuation branch from 4c7ee6e to 80da994 Compare February 9, 2026 17:49
@Avasam Avasam changed the title Allow more iterable types in join_continuation Fixed join_continuation's parameter type annotation Feb 9, 2026
@Avasam Avasam force-pushed the allow-more-types-in-join_continuation branch from 80da994 to e01b1ae Compare February 9, 2026 17:53
@jaraco jaraco merged commit 20fedcf into jaraco:main Feb 9, 2026
15 checks passed
@Avasam Avasam deleted the allow-more-types-in-join_continuation branch February 9, 2026 18:34
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.

2 participants