Commit 7eb476c2 authored by Bertrand Néron's avatar Bertrand Néron
Browse files

🎨 improve hint typing

parent e481175d
import itertools
from typing import Iterator, Optional
from typing import Iterator, Set, Optional
class NDGraph:
......@@ -14,7 +14,7 @@ class NDGraph:
"""
def __init__(self):
self.nodes = set()
self.nodes: Set['Node'] = set()
def add_node(self, node: 'Node') -> None:
self.nodes.add(node)
......@@ -29,7 +29,7 @@ class Node:
def __init__(self):
self.id: int = next(self._id)
self.neighbors = set()
self.neighbors: Set['Node'] = set()
def __hash__(self):
# to be usable in set an object must be hashable
......
import itertools
from typing import Iterator, Set, Sequence
from typing import Iterator, Dict, Set, Sequence
class NDGraph:
......@@ -14,8 +14,8 @@ class NDGraph:
"""
def __init__(self, nodes):
self.nodes = {n for n in nodes}
self.vertices = {n: set() for n in self.nodes}
self.nodes: Set['Node'] = {n for n in nodes}
self.vertices: Dict['Node': Set['Node']] = {n: set() for n in self.nodes}
def add_node(self, node: 'Node') -> None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment