Skip to content

fix: fix Series construction with data as an iterator#1377

Closed
terencehonles wants to merge 1 commit into
pandas-dev:mainfrom
terencehonles:update-Series.constructor
Closed

fix: fix Series construction with data as an iterator#1377
terencehonles wants to merge 1 commit into
pandas-dev:mainfrom
terencehonles:update-Series.constructor

Conversation

@terencehonles
Copy link
Copy Markdown
Contributor

  • Tests added: Please use assert_type() to assert the type of any return value

Copy link
Copy Markdown
Contributor

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

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

Hi @terencehonles , thank you for the proposal. Having checked the Pandas documentation, and it seems that data can indeed be an Iterator.

Comment on lines +159 to +163
check(
assert_type(pd.Series(iter([1.0])), "pd.Series[float]"),
pd.Series,
float,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Several __new__'s have been retyped, but only one test has been added. Please complete the new tests. Alternatively, you can split the old test function into two.

def __new__(
cls,
data: Sequence[_str],
data: Iterator[_str],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Iterator[_str] can be ambiguous, because _str is an Iterable in its own right. However, I don't have more insights how to improve this.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can use Iterator[SequenceNotStr[_str]]

@cmp0xff
Copy link
Copy Markdown
Contributor

cmp0xff commented Oct 9, 2025

Hi @terencehonles , would you be able to follow up on this?

@cmp0xff cmp0xff added the Constructors Series/DataFrame/Index/pd.array Constructors label Oct 28, 2025
@loicdiridollou
Copy link
Copy Markdown
Member

Unless we have some changes in the next few days on this one I would consider closing it since the codebase has drifted a lot and it would be a lot of effort to reconcile them, more than just starting from scratch again.

@loicdiridollou loicdiridollou added the Closing Candidate May be closeable, needs more eyeballs label Jan 10, 2026
@loicdiridollou
Copy link
Copy Markdown
Member

Will close for now, it has diverged too much, please reopen a fresh PR so we can more easily review it.

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

Labels

Closing Candidate May be closeable, needs more eyeballs Constructors Series/DataFrame/Index/pd.array Constructors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants