u-toolkit 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- u_toolkit/fastapi/cbv.py +27 -8
 - {u_toolkit-0.1.2.dist-info → u_toolkit-0.1.4.dist-info}/METADATA +1 -1
 - {u_toolkit-0.1.2.dist-info → u_toolkit-0.1.4.dist-info}/RECORD +5 -5
 - {u_toolkit-0.1.2.dist-info → u_toolkit-0.1.4.dist-info}/WHEEL +0 -0
 - {u_toolkit-0.1.2.dist-info → u_toolkit-0.1.4.dist-info}/entry_points.txt +0 -0
 
    
        u_toolkit/fastapi/cbv.py
    CHANGED
    
    | 
         @@ -24,7 +24,8 @@ class EndpointsClassInterface(Protocol): 
     | 
|
| 
       24 
24 
     | 
    
         
             
                deprecated: bool | None = None
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                @classmethod
         
     | 
| 
       27 
     | 
    
         
            -
                def build_self(cls) -> Self: 
     | 
| 
      
 27 
     | 
    
         
            +
                def build_self(cls) -> Self:
         
     | 
| 
      
 28 
     | 
    
         
            +
                    return cls()
         
     | 
| 
       28 
29 
     | 
    
         | 
| 
       29 
30 
     | 
    
         | 
| 
       30 
31 
     | 
    
         
             
            _T = TypeVar("_T")
         
     | 
| 
         @@ -68,7 +69,8 @@ class Methods(StrEnum): 
     | 
|
| 
       68 
69 
     | 
    
         | 
| 
       69 
70 
     | 
    
         | 
| 
       70 
71 
     | 
    
         
             
            METHOD_PATTERNS = {
         
     | 
| 
       71 
     | 
    
         
            -
                method: re.compile(f"^{method}", re.IGNORECASE) 
     | 
| 
      
 72 
     | 
    
         
            +
                method: re.compile(f"^({method}_|{method})", re.IGNORECASE)
         
     | 
| 
      
 73 
     | 
    
         
            +
                for method in Methods
         
     | 
| 
       72 
74 
     | 
    
         
             
            }
         
     | 
| 
       73 
75 
     | 
    
         | 
| 
       74 
76 
     | 
    
         
             
            _FnName = str
         
     | 
| 
         @@ -107,7 +109,7 @@ def iter_endpoints(cls: type[_T]): 
     | 
|
| 
       107 
109 
     | 
    
         
             
                    paths = [prefix]
         
     | 
| 
       108 
110 
     | 
    
         | 
| 
       109 
111 
     | 
    
         
             
                    if method := get_method(name):
         
     | 
| 
       110 
     | 
    
         
            -
                        path = method[1].sub( 
     | 
| 
      
 112 
     | 
    
         
            +
                        path = method[1].sub("", name).replace("__", "/")
         
     | 
| 
       111 
113 
     | 
    
         
             
                        if path:
         
     | 
| 
       112 
114 
     | 
    
         
             
                            paths.append(path)
         
     | 
| 
       113 
115 
     | 
    
         | 
| 
         @@ -136,6 +138,7 @@ def iter_dependencies(cls: type[_T]): 
     | 
|
| 
       136 
138 
     | 
    
         | 
| 
       137 
139 
     | 
    
         | 
| 
       138 
140 
     | 
    
         
             
            _CBVEndpointParamName = Literal[
         
     | 
| 
      
 141 
     | 
    
         
            +
                "path",
         
     | 
| 
       139 
142 
     | 
    
         
             
                "tags",
         
     | 
| 
       140 
143 
     | 
    
         
             
                "dependencies",
         
     | 
| 
       141 
144 
     | 
    
         
             
                "responses",
         
     | 
| 
         @@ -197,6 +200,8 @@ class CBV: 
     | 
|
| 
       197 
200 
     | 
    
         
             
                        method
         
     | 
| 
       198 
201 
     | 
    
         
             
                    ]
         
     | 
| 
       199 
202 
     | 
    
         | 
| 
      
 203 
     | 
    
         
            +
                    path = self._state[cls][method_name].get("path") or path
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
       200 
205 
     | 
    
         
             
                    return self.router.api_route(
         
     | 
| 
       201 
206 
     | 
    
         
             
                        path,
         
     | 
| 
       202 
207 
     | 
    
         
             
                        methods=endpoint_methods,
         
     | 
| 
         @@ -211,6 +216,7 @@ class CBV: 
     | 
|
| 
       211 
216 
     | 
    
         
             
                def info(
         
     | 
| 
       212 
217 
     | 
    
         
             
                    self,
         
     | 
| 
       213 
218 
     | 
    
         
             
                    *,
         
     | 
| 
      
 219 
     | 
    
         
            +
                    path: str | None = None,
         
     | 
| 
       214 
220 
     | 
    
         
             
                    methods: list[Methods | LiteralUpperMethods | LiteralLowerMethods]
         
     | 
| 
       215 
221 
     | 
    
         
             
                    | None = None,
         
     | 
| 
       216 
222 
     | 
    
         
             
                    tags: list[str | Enum] | None = None,
         
     | 
| 
         @@ -223,6 +229,7 @@ class CBV: 
     | 
|
| 
       223 
229 
     | 
    
         
             
                    state = self._state
         
     | 
| 
       224 
230 
     | 
    
         
             
                    initial_state = self._initial_state
         
     | 
| 
       225 
231 
     | 
    
         
             
                    data: dict[_CBVEndpointParamName, Any] = {
         
     | 
| 
      
 232 
     | 
    
         
            +
                        "path": path,
         
     | 
| 
       226 
233 
     | 
    
         
             
                        "methods": methods,
         
     | 
| 
       227 
234 
     | 
    
         
             
                        "tags": tags,
         
     | 
| 
       228 
235 
     | 
    
         
             
                        "dependencies": dependencies,
         
     | 
| 
         @@ -299,6 +306,13 @@ class CBV: 
     | 
|
| 
       299 
306 
     | 
    
         | 
| 
       300 
307 
     | 
    
         
             
                    update_parameters(collect_cls_dependencies, *parameters)
         
     | 
| 
       301 
308 
     | 
    
         | 
| 
      
 309 
     | 
    
         
            +
                    def new_fn(method_name, kwargs):
         
     | 
| 
      
 310 
     | 
    
         
            +
                        instance = self._build_cls(cls)
         
     | 
| 
      
 311 
     | 
    
         
            +
                        dependencies = kwargs.pop(collect_cls_dependencies.__name__)
         
     | 
| 
      
 312 
     | 
    
         
            +
                        for dep_name, dep_value in dependencies.items():
         
     | 
| 
      
 313 
     | 
    
         
            +
                            setattr(instance, dep_name, dep_value)
         
     | 
| 
      
 314 
     | 
    
         
            +
                        return getattr(instance, method_name)
         
     | 
| 
      
 315 
     | 
    
         
            +
             
     | 
| 
       302 
316 
     | 
    
         
             
                    def decorator(method: Callable):
         
     | 
| 
       303 
317 
     | 
    
         
             
                        method_name = method.__name__
         
     | 
| 
       304 
318 
     | 
    
         | 
| 
         @@ -314,13 +328,18 @@ class CBV: 
     | 
|
| 
       314 
328 
     | 
    
         | 
| 
       315 
329 
     | 
    
         
             
                        update_parameters(sign_cls_fn, *(parameters[1:]))
         
     | 
| 
       316 
330 
     | 
    
         | 
| 
      
 331 
     | 
    
         
            +
                        if inspect.iscoroutinefunction(method):
         
     | 
| 
      
 332 
     | 
    
         
            +
             
     | 
| 
      
 333 
     | 
    
         
            +
                            @wraps(sign_cls_fn)
         
     | 
| 
      
 334 
     | 
    
         
            +
                            async def awrapper(*args, **kwargs):
         
     | 
| 
      
 335 
     | 
    
         
            +
                                fn = new_fn(method_name, kwargs)
         
     | 
| 
      
 336 
     | 
    
         
            +
                                return await fn(*args, **kwargs)
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
                            return awrapper
         
     | 
| 
      
 339 
     | 
    
         
            +
             
     | 
| 
       317 
340 
     | 
    
         
             
                        @wraps(sign_cls_fn)
         
     | 
| 
       318 
341 
     | 
    
         
             
                        def wrapper(*args, **kwargs):
         
     | 
| 
       319 
     | 
    
         
            -
                             
     | 
| 
       320 
     | 
    
         
            -
                            dependencies = kwargs.pop(collect_cls_dependencies.__name__)
         
     | 
| 
       321 
     | 
    
         
            -
                            for dep_name, dep_value in dependencies.items():
         
     | 
| 
       322 
     | 
    
         
            -
                                setattr(instance, dep_name, dep_value)
         
     | 
| 
       323 
     | 
    
         
            -
                            fn = getattr(instance, method_name)
         
     | 
| 
      
 342 
     | 
    
         
            +
                            fn = new_fn(method_name, kwargs)
         
     | 
| 
       324 
343 
     | 
    
         
             
                            return fn(*args, **kwargs)
         
     | 
| 
       325 
344 
     | 
    
         | 
| 
       326 
345 
     | 
    
         
             
                        return wrapper
         
     | 
| 
         @@ -11,7 +11,7 @@ u_toolkit/object.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 
     | 
|
| 
       11 
11 
     | 
    
         
             
            u_toolkit/path.py,sha256=IkyIHcU9hKBCOZfF30FrKf4CfL-MH91fjeYF9EY7eos,128
         
     | 
| 
       12 
12 
     | 
    
         
             
            u_toolkit/signature.py,sha256=wXyGFgb_E68xevYWx7gIy9P5lVZmHUebpf2EGI_fCnw,2167
         
     | 
| 
       13 
13 
     | 
    
         
             
            u_toolkit/fastapi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         
     | 
| 
       14 
     | 
    
         
            -
            u_toolkit/fastapi/cbv.py,sha256= 
     | 
| 
      
 14 
     | 
    
         
            +
            u_toolkit/fastapi/cbv.py,sha256=WRp6jgwWFrdc_ujpUb9Pn6-BkkRfyEshVA_GsGFL8_s,10580
         
     | 
| 
       15 
15 
     | 
    
         
             
            u_toolkit/fastapi/config.py,sha256=kGpokR9XXr1KxMA1GVKYkCdKwqIQAIwOJ-v6sGbqzAQ,267
         
     | 
| 
       16 
16 
     | 
    
         
             
            u_toolkit/fastapi/exception.py,sha256=5E4wAJYwp0RJ4SEBVkchOgrgfwCgniQ8Mtg1O5sWUXE,3288
         
     | 
| 
       17 
17 
     | 
    
         
             
            u_toolkit/fastapi/helpers.py,sha256=BCMMLxa1c6BMA_rKq-hCi0iyEjrR3Z5rPMeTvgaVJB0,447
         
     | 
| 
         @@ -30,7 +30,7 @@ u_toolkit/sqlalchemy/type_vars.py,sha256=m2VeV41CBIK_1QX3w2kgz-n556sILAGZ-Kaz3TD 
     | 
|
| 
       30 
30 
     | 
    
         
             
            u_toolkit/sqlalchemy/orm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         
     | 
| 
       31 
31 
     | 
    
         
             
            u_toolkit/sqlalchemy/orm/fields.py,sha256=3zoYil23I6YLtc_59aHDt9w5l1NBTkePT9AfXI3DMiY,593
         
     | 
| 
       32 
32 
     | 
    
         
             
            u_toolkit/sqlalchemy/orm/models.py,sha256=V8vf4ps3phAmwxyaFYK7pw8Igz7h097o4QBjKB0gwC8,705
         
     | 
| 
       33 
     | 
    
         
            -
            u_toolkit-0.1. 
     | 
| 
       34 
     | 
    
         
            -
            u_toolkit-0.1. 
     | 
| 
       35 
     | 
    
         
            -
            u_toolkit-0.1. 
     | 
| 
       36 
     | 
    
         
            -
            u_toolkit-0.1. 
     | 
| 
      
 33 
     | 
    
         
            +
            u_toolkit-0.1.4.dist-info/METADATA,sha256=v6ehDmn-iQaNDZSx4KZgQDlWqKHvzKStbaRqH1IcYrw,365
         
     | 
| 
      
 34 
     | 
    
         
            +
            u_toolkit-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
         
     | 
| 
      
 35 
     | 
    
         
            +
            u_toolkit-0.1.4.dist-info/entry_points.txt,sha256=hTfAYCd5vvRiqgnJk2eBsoRIiIVB9pK8WZm3Q3jjKFU,45
         
     | 
| 
      
 36 
     | 
    
         
            +
            u_toolkit-0.1.4.dist-info/RECORD,,
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |