Skip to content
This repository was archived by the owner on Dec 17, 2023. It is now read-only.

Refine types #6

Merged
merged 2 commits into from
Jul 20, 2022
Merged

Refine types #6

merged 2 commits into from
Jul 20, 2022

Conversation

charmoniumQ
Copy link
Contributor

@charmoniumQ charmoniumQ commented Jul 20, 2022

Resolves #2.

This pull request is the result of:

  • Merging @NeilGirdhar's types in Add type annotations for Graph and DiGraph networkx/networkx#4014 (classes/graph.pyi and classes/digraph.pyi).
  • Adding my own (classes/reportviews.pyi, classes/coreviews.pyi).
  • Fixing all of the problems uncovered by mypy 0.971.
    • form .blah import * pulls in whatever type variables you have, and if there are two of the same name, Mypy complains. Therefore, I prefixed all of the type variables with an underscore, so they don't get pulled in by *.
    • If mypy flagged an annotation that is internal to NetworkX, I deleted that annotation rather than fix it. I decided something is internal if it had a leading underscore, or in some cases, if it wasn't documented by NetworkX.
    • Removing test code in NetworkX.
    • Unfortunately type variables can't themselves take type parameters, so this doesn't work:
      T = TypeVar("T")
      GT = TypeVar("GT", bound=Graph)
      graph: GT[T]
      
      In such cases, I converted graph to Any, as it is elsewhere in the stubs.

I will add automated tests in a future PR.

@charmoniumQ charmoniumQ mentioned this pull request Jul 20, 2022
@fmagin fmagin merged commit aa580b8 into fmagin:master Jul 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge tighter annotations?
2 participants