6666 from i2 .signatures import set_signature_of_func , KO
6767
6868DFLT_PORT = 5000
69- DFLT_BASE_URL = "http://localhost:{port}" . format ( port = DFLT_PORT )
69+ DFLT_BASE_URL = f "http://localhost:{ DFLT_PORT } "
7070DFLT_REQUEST_METHOD = "post"
7171DFLT_REQUEST_KWARGS = imdict ({"method" : DFLT_REQUEST_METHOD , "url" : "" })
7272
@@ -227,7 +227,7 @@ def request_func(*args, **kwargs):
227227 if "url_template" in method_spec :
228228 url_template = method_spec ["url_template" ]
229229 # Check if the url template already has parameters, add them otherwise
230- if query_arg_names and not re .search ("^.*\?((.*=.*)(&?))+$" , url_template ):
230+ if query_arg_names and not re .search (r "^.*\?((.*=.*)(&?))+$" , url_template ):
231231 url_arg_parts = [f"{ x } ={{{ x } }}" for x in query_arg_names if x in kwargs ]
232232 url_args = "&" .join (url_arg_parts )
233233 if url_args :
@@ -316,7 +316,7 @@ def request_func(self, *args, **kwargs):
316316str_formatter = string .Formatter ()
317317
318318
319- class Py2Request ( object ) :
319+ class Py2Request :
320320 """Make a class that has methods that offer a python interface to web requests"""
321321
322322 def __init__ (
@@ -653,8 +653,9 @@ def mk_method_spec_from_openapi_method_spec(
653653
654654##### Open api stuff TODO: To move ###########################################
655655from inspect import Parameter , Signature
656- from typing import Union , Callable , Iterable
657- from typing import Mapping as MappingType
656+ from typing import Union
657+ from collections .abc import Callable , Iterable
658+ from collections .abc import Mapping as MappingType
658659
659660PK = Parameter .POSITIONAL_OR_KEYWORD
660661
@@ -755,7 +756,8 @@ def mk_request_func_from_openapi_spec(
755756mk_request_function .from_openapi_spec = mk_request_func_from_openapi_spec
756757
757758
758- from typing import Optional , Iterable , Dict , Tuple , Callable
759+ from typing import Optional , Dict , Tuple
760+ from collections .abc import Iterable , Callable
759761from ju .oas import Routes
760762from http2py .py2request import mk_request_func_from_openapi_spec
761763
@@ -773,12 +775,12 @@ def default_path_to_func_name(method: str, uri: str) -> str:
773775
774776def openapi_to_py (
775777 openapi_spec : dict ,
776- paths : Optional [ Iterable [Tuple [str , str ]]] = None ,
778+ paths : Iterable [tuple [str , str ]] | None = None ,
777779 * ,
778780 path_to_func_name : Callable [[str , str ], str ] = default_path_to_func_name ,
779- servers : Optional [ list ] = None ,
781+ servers : list | None = None ,
780782 default_server_url : str = "http://localhost:8000" ,
781- ) -> Dict [str , Callable ]:
783+ ) -> dict [str , Callable ]:
782784 """
783785 Given an OpenAPI spec dict, returns a dict mapping function names to request functions.
784786 The `servers` argument overrides or provides a default for the OpenAPI servers field.
0 commit comments