33import os
44from typing import (
55 TYPE_CHECKING ,
6- Dict ,
7- List ,
8- Set ,
9- Tuple ,
10- Type ,
116)
127
138from ..casing import safe_snake_case
1813 from ..plugin .models import PluginRequestCompiler
1914 from ..plugin .typing_compiler import TypingCompiler
2015
21- WRAPPER_TYPES : Dict [str , Type ] = {
16+ WRAPPER_TYPES : dict [str , type ] = {
2217 ".google.protobuf.DoubleValue" : google_protobuf .DoubleValue ,
2318 ".google.protobuf.FloatValue" : google_protobuf .FloatValue ,
2419 ".google.protobuf.Int32Value" : google_protobuf .Int32Value ,
3126}
3227
3328
34- def parse_source_type_name (field_type_name : str , request : " PluginRequestCompiler" ) -> Tuple [str , str ]:
29+ def parse_source_type_name (field_type_name : str , request : PluginRequestCompiler ) -> tuple [str , str ]:
3530 """
3631 Split full source type name into package and type name.
3732 E.g. 'root.package.Message' -> ('root.package', 'Message')
@@ -77,7 +72,7 @@ def get_type_reference(
7772 imports : set ,
7873 source_type : str ,
7974 typing_compiler : TypingCompiler ,
80- request : " PluginRequestCompiler" ,
75+ request : PluginRequestCompiler ,
8176 unwrap : bool = True ,
8277 pydantic : bool = False ,
8378) -> str :
@@ -98,8 +93,8 @@ def get_type_reference(
9893
9994 source_package , source_type = parse_source_type_name (source_type , request )
10095
101- current_package : List [str ] = package .split ("." ) if package else []
102- py_package : List [str ] = source_package .split ("." ) if source_package else []
96+ current_package : list [str ] = package .split ("." ) if package else []
97+ py_package : list [str ] = source_package .split ("." ) if source_package else []
10398 py_type : str = pythonize_class_name (source_type )
10499
105100 compiling_google_protobuf = current_package == ["google" , "protobuf" ]
@@ -122,7 +117,7 @@ def get_type_reference(
122117 return reference_cousin (current_package , imports , py_package , py_type )
123118
124119
125- def reference_absolute (imports : Set [str ], py_package : List [str ], py_type : str ) -> str :
120+ def reference_absolute (imports : set [str ], py_package : list [str ], py_type : str ) -> str :
126121 """
127122 Returns a reference to a python type located in the root, i.e. sys.path.
128123 """
@@ -139,7 +134,7 @@ def reference_sibling(py_type: str) -> str:
139134 return f"{ py_type } "
140135
141136
142- def reference_descendent (current_package : List [str ], imports : Set [str ], py_package : List [str ], py_type : str ) -> str :
137+ def reference_descendent (current_package : list [str ], imports : set [str ], py_package : list [str ], py_type : str ) -> str :
143138 """
144139 Returns a reference to a python type in a package that is a descendent of the
145140 current package, and adds the required import that is aliased to avoid name
@@ -157,7 +152,7 @@ def reference_descendent(current_package: List[str], imports: Set[str], py_packa
157152 return f"{ string_import } .{ py_type } "
158153
159154
160- def reference_ancestor (current_package : List [str ], imports : Set [str ], py_package : List [str ], py_type : str ) -> str :
155+ def reference_ancestor (current_package : list [str ], imports : set [str ], py_package : list [str ], py_type : str ) -> str :
161156 """
162157 Returns a reference to a python type in a package which is an ancestor to the
163158 current package, and adds the required import that is aliased (if possible) to avoid
@@ -178,7 +173,7 @@ def reference_ancestor(current_package: List[str], imports: Set[str], py_package
178173 return string_alias
179174
180175
181- def reference_cousin (current_package : List [str ], imports : Set [str ], py_package : List [str ], py_type : str ) -> str :
176+ def reference_cousin (current_package : list [str ], imports : set [str ], py_package : list [str ], py_type : str ) -> str :
182177 """
183178 Returns a reference to a python type in a package that is not descendent, ancestor
184179 or sibling, and adds the required import that is aliased to avoid name conflicts.
0 commit comments