Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify Any for PyGraph and PyDiGraph type annotations for pyright compatibility #1246

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

IvanIsCoding
Copy link
Collaborator

Closes #1242

This is a pretty annoying PR but it avoids pyright from infering the types as Unknown. Although we will only keep mypy in the CI, pyright is the base for pylance which ships with VSCode. And we got VSCode issues in the past (#832), so I think it's worth supporting.

@IvanIsCoding IvanIsCoding added the stable-backport-potential This PR or issue is potentially worth backporting for inclusion in a stable branch label Jul 11, 2024
@coveralls
Copy link

coveralls commented Jul 11, 2024

Pull Request Test Coverage Report for Build 11862655294

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.834%

Totals Coverage Status
Change from base Build 11860433299: 0.0%
Covered Lines: 18125
Relevant Lines: 18913

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

Just one question inline about using the generic type var instead Any. But if that doesn't work I'm fine with this.

rustworkx/__init__.pyi Show resolved Hide resolved
@@ -552,39 +554,39 @@ def directed_gnm_random_graph(
num_edges: int,
/,
seed: int | None = ...,
) -> PyDiGraph: ...
Copy link
Member

Choose a reason for hiding this comment

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

So based on the earlier comment is this actually [Any, Any]. The weights from the generator functions are a fixed type depending on the arguments. Like for this gnm random graph function the nodes and edges are always None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stable-backport-potential This PR or issue is potentially worth backporting for inclusion in a stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem type checking ancestors() with pyright
3 participants