FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

networkx: All return types from python-type-stubs by Avasam · Pull Request #14256 · python/typeshed · GitHub

Repository navigation

networkx: All return types from python-type-stubs - #14256

Merged
srittau merged 7 commits into
python:mainfrom
Avasam:networkx-return-type-annotations-from-python-type-stubs
Jul 8, 2025
Merged

srittau merged 7 commits into
python:mainfrom
Avasam:networkx-return-type-annotations-from-python-type-stubs

Conversation

Avasam commented Jun 10, 2025

Copy link
Copy Markdown
Collaborator

Extracted from #14038

Return types are a lot more straightforward to validate. So I extracted them in their own PR to reduce the size of #14038

This comment has been minimized.

srittau left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just two small remarks below.

def write_edgelist(G, path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8") -> None: ...
@_dispatchable
def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[Incomplete, None, None]: ...
def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[str, None, None]: ...

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nitty nit:

Suggested change
def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[str, None, None]: ...
def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[str]: ...

Avasam Jul 8, 2025 •
edited
Loading

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

(applied suggestion)
There's a ton of those in networkx stubs. Maybe we should have a lint rule for the new concise Generator format ?

weight: str | None = "weight",
format="csr",
): ...
): ... # Return is a complex union of scipy classes depending on the format param

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

So, should we return Any?

Suggested change
): ... # Return is a complex union of scipy classes depending on the format param
) -> Any: ... # Return is a complex union of scipy classes depending on the format param

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think I added this comment initially because I probably added Any as well, but I think you could actually represent the return type with overloads based on the format param. So it's more "incomplete", than "unrepresentable".

github-actions Bot commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

srittau merged commit 07a59e9 into python:main Jul 8, 2025
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL