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

Allow PyGraph and PyDiGraph to be annotated as generic classes at runtime #1348

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

Conversation

IvanIsCoding
Copy link
Collaborator

@IvanIsCoding IvanIsCoding commented Dec 30, 2024

Fixes #1345. It should address the core aspects for PyGraph and PyDiGraph. However, custom return types will come in a follow up PR

This makes the following work without requiring from __future__ import annotations:

import rustworkx as rx

graph: rx.PyDiGraph[int, int] = rx.PyDiGraph()

Also, this is worth highlighting: I refrained from adding __class_getitem__ to the type stubs as in the stubs that method is inherited from Generic[_S, _T] I ended up adding the method to the stubs as mypy stub tests disagreed with my reasoning

@IvanIsCoding IvanIsCoding changed the title Allow PyGraph and PyDiGraph to be annotated as generic classes at run… Allow PyGraph and PyDiGraph to be annotated as generic classes at runtime Dec 30, 2024
@coveralls
Copy link

coveralls commented Dec 30, 2024

Pull Request Test Coverage Report for Build 12661334236

Details

  • 24 of 24 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 95.83%

Totals Coverage Status
Change from base Build 12653809774: 0.005%
Covered Lines: 18384
Relevant Lines: 19184

💛 - Coveralls

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.

Add __class_getitem__ to generic classes
2 participants