@@ -67,24 +67,24 @@ class DuplicateRouteError(ViewError):
6767
6868
6969@dataclass (slots = True )
70- class PathNode :
70+ class _PathNode :
7171 """
7272 A node in the "path tree".
7373 """
7474
7575 name : str
7676 routes : MutableMapping [Method , Route ] = field (default_factory = dict )
77- children : MutableMapping [str , PathNode ] = field (default_factory = dict )
78- path_parameter : PathNode | None = None
77+ children : MutableMapping [str , _PathNode ] = field (default_factory = dict )
78+ path_parameter : _PathNode | None = None
7979 subrouter : SubRouter | None = None
8080
81- def parameter (self , name : str ) -> PathNode :
81+ def parameter (self , name : str ) -> _PathNode :
8282 """
8383 Mark this node as having a path parameter (if not already), and
8484 return the path parameter node.
8585 """
8686 if self .path_parameter is None :
87- next_node = PathNode (name = name )
87+ next_node = _PathNode (name = name )
8888 self .path_parameter = next_node
8989 return next_node
9090 if __debug__ and name != self .path_parameter .name :
@@ -94,7 +94,7 @@ def parameter(self, name: str) -> PathNode:
9494 )
9595 return self .path_parameter
9696
97- def next (self , part : str ) -> PathNode :
97+ def next_node (self , part : str ) -> _PathNode :
9898 """
9999 Get the next node for the given path part, creating it if it doesn't
100100 exist.
@@ -103,19 +103,19 @@ def next(self, part: str) -> PathNode:
103103 if node is not None :
104104 return node
105105
106- new_node = PathNode (name = part )
106+ new_node = _PathNode (name = part )
107107 self .children [part ] = new_node
108108 return new_node
109109
110110
111- def is_path_parameter (part : str ) -> bool :
111+ def _is_path_parameter (part : str ) -> bool :
112112 """
113113 Is this part a path parameter?
114114 """
115115 return part .startswith ("{" ) and part .endswith ("}" )
116116
117117
118- def extract_path_parameter (part : str ) -> str :
118+ def _extract_path_parameter (part : str ) -> str :
119119 """
120120 Extract the name of a path parameter from a string given by the user
121121 in a route string.
@@ -143,11 +143,11 @@ class Router:
143143 error_views : MutableMapping [type [HTTPError ], RouteView ] = field (
144144 default_factory = dict
145145 )
146- parent_node : PathNode = field (default_factory = lambda : PathNode (name = "" ))
146+ parent_node : _PathNode = field (default_factory = lambda : _PathNode (name = "" ))
147147
148148 def _get_node_for_path (
149149 self , path : str , * , allow_path_parameters : bool
150- ) -> PathNode :
150+ ) -> _PathNode :
151151 if __debug__ and not isinstance (path , str ):
152152 raise InvalidTypeError (path , str )
153153
@@ -156,14 +156,14 @@ def _get_node_for_path(
156156 parts = path .split ("/" )
157157
158158 for part in parts :
159- if is_path_parameter (part ):
159+ if _is_path_parameter (part ):
160160 if not allow_path_parameters :
161161 raise RuntimeError ("Path parameters are not allowed here" )
162162 parent_node = parent_node .parameter (
163- extract_path_parameter (part )
163+ _extract_path_parameter (part )
164164 )
165165 else :
166- parent_node = parent_node .next (part )
166+ parent_node = parent_node .next_node (part )
167167
168168 return parent_node
169169
0 commit comments