hypern 0.3.11__cp312-cp312-win_amd64.whl → 0.3.13__cp312-cp312-win_amd64.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.
hypern/__init__.py CHANGED
@@ -5,6 +5,9 @@ from hypern.ws import WebsocketRoute, WebSocketSession
5
5
  from .application import Hypern
6
6
  from .hypern import Request, Response
7
7
  from .response import FileResponse, HTMLResponse, JSONResponse, PlainTextResponse, RedirectResponse
8
+ from .hypern import BackgroundTask
9
+ from .hypern import BackgroundTasks
10
+ from .hypern import Scheduler
8
11
 
9
12
  __all__ = [
10
13
  "Hypern",
@@ -21,4 +24,7 @@ __all__ = [
21
24
  "PlainTextResponse",
22
25
  "RedirectResponse",
23
26
  "logger",
27
+ "BackgroundTask",
28
+ "BackgroundTasks",
29
+ "Scheduler",
24
30
  ]
hypern/application.py CHANGED
@@ -10,8 +10,9 @@ import psutil
10
10
  from typing_extensions import Annotated, Doc
11
11
 
12
12
  from hypern.args_parser import ArgsConfig
13
- from hypern.datastructures import Contact, HTTPMethod, Info, License
14
- from hypern.hypern import DatabaseConfig, FunctionInfo, MiddlewareConfig, Router, Server, WebsocketRouter
13
+ from hypern.datastructures import Contact, Info, License
14
+ from hypern.enum import HTTPMethod
15
+ from hypern.hypern import DatabaseConfig, FunctionInfo, MiddlewareConfig, Router, Server, WebsocketRouter, Scheduler
15
16
  from hypern.hypern import Route as InternalRoute
16
17
  from hypern.logging import logger
17
18
  from hypern.middleware import Middleware
@@ -19,7 +20,6 @@ from hypern.openapi import SchemaGenerator, SwaggerUI
19
20
  from hypern.processpool import run_processes
20
21
  from hypern.response import HTMLResponse, JSONResponse
21
22
  from hypern.routing import Route
22
- from hypern.scheduler import Scheduler
23
23
  from hypern.ws import WebsocketRoute
24
24
 
25
25
  AppType = TypeVar("AppType", bound="Hypern")
@@ -243,7 +243,7 @@ class Hypern:
243
243
  self.thread_config = ThreadConfigurator().get_config()
244
244
 
245
245
  for route in routes or []:
246
- self.router.extend_route(route(app=self).routes)
246
+ self.router.extend_route(route())
247
247
 
248
248
  for websocket_route in websockets or []:
249
249
  for route in websocket_route.routes:
@@ -438,6 +438,7 @@ class Hypern:
438
438
  self.args.max_blocking_threads = self.thread_config.max_blocking_threads
439
439
 
440
440
  if self.args.http2:
441
+ logger.info("HTTP/2 enabled")
441
442
  server.enable_http2()
442
443
 
443
444
  run_processes(
hypern/datastructures.py CHANGED
@@ -1,5 +1,4 @@
1
1
  from typing import Optional
2
- from enum import Enum
3
2
  from pydantic import BaseModel, AnyUrl
4
3
 
5
4
 
@@ -26,15 +25,3 @@ class Info(BaseModelWithConfig):
26
25
  contact: Optional[Contact] = None
27
26
  license: Optional[License] = None
28
27
  version: str
29
-
30
-
31
- class HTTPMethod(Enum):
32
- GET = "GET"
33
- POST = "POST"
34
- PUT = "PUT"
35
- DELETE = "DELETE"
36
- PATCH = "PATCH"
37
- OPTIONS = "OPTIONS"
38
- HEAD = "HEAD"
39
- TRACE = "TRACE"
40
- CONNECT = "CONNECT"
hypern/enum.py CHANGED
@@ -11,3 +11,15 @@ class ErrorCode(Enum):
11
11
  METHOD_NOT_ALLOW = "METHOD_NOT_ALLOW"
12
12
  UNAUTHORIZED = "UNAUTHORIZED"
13
13
  VALIDATION_ERROR = "VALIDATION_ERROR"
14
+
15
+
16
+ class HTTPMethod(Enum):
17
+ GET = "GET"
18
+ POST = "POST"
19
+ PUT = "PUT"
20
+ DELETE = "DELETE"
21
+ PATCH = "PATCH"
22
+ OPTIONS = "OPTIONS"
23
+ HEAD = "HEAD"
24
+ TRACE = "TRACE"
25
+ CONNECT = "CONNECT"
Binary file
hypern/processpool.py CHANGED
@@ -120,8 +120,6 @@ def initialize_event_loop(max_blocking_threads: int = 100) -> asyncio.AbstractEv
120
120
  loop = uvloop.new_event_loop()
121
121
  asyncio.set_event_loop(loop)
122
122
 
123
- loop.slow_callback_duration = 0.1 # Log warnings for slow callbacks
124
- loop.set_debug(False) # Disable debug mode
125
123
  return loop
126
124
 
127
125
 
@@ -2,12 +2,10 @@ from __future__ import annotations
2
2
 
3
3
  import typing
4
4
  from urllib.parse import quote
5
- from hypern.hypern import Response as InternalResponse, Header
5
+ from hypern.hypern import Response as InternalResponse, Header, BackgroundTask, BackgroundTasks
6
6
  import orjson
7
7
  import msgpack
8
8
 
9
- from hypern.background import BackgroundTask, BackgroundTasks
10
-
11
9
 
12
10
  class BaseResponse:
13
11
  media_type = None
hypern/routing/parser.py CHANGED
@@ -36,7 +36,7 @@ class ParamParser:
36
36
  return {k: v[0] for k, v in query_params.items()}
37
37
 
38
38
  def _parse_path_params(self) -> dict:
39
- return lambda: dict(self.request.path_params.items())
39
+ return dict(self.request.path_params.items())
40
40
 
41
41
  def _parse_form_data(self) -> dict:
42
42
  return self.request.json()
hypern/routing/route.py CHANGED
@@ -9,8 +9,10 @@ from pydantic import BaseModel
9
9
  from pydantic.fields import FieldInfo
10
10
 
11
11
  from hypern.auth.authorization import Authorization
12
- from hypern.datastructures import HTTPMethod
13
- from hypern.hypern import FunctionInfo, Request, Router
12
+
13
+ from hypern.enum import HTTPMethod
14
+ from hypern.hypern import FunctionInfo, Request
15
+
14
16
  from hypern.hypern import Route as InternalRoute
15
17
 
16
18
  from .dispatcher import dispatch
@@ -20,6 +22,16 @@ def get_field_type(field):
20
22
  return field.outer_type_
21
23
 
22
24
 
25
+ def join_url_paths(*parts):
26
+ first = parts[0]
27
+ parts = [part.strip("/") for part in parts]
28
+ starts_with_slash = first.startswith("/") if first else False
29
+ joined = "/".join(part for part in parts if part)
30
+ if starts_with_slash:
31
+ joined = "/" + joined
32
+ return joined
33
+
34
+
23
35
  def pydantic_to_swagger(model: type[BaseModel] | dict):
24
36
  if isinstance(model, dict):
25
37
  # Handle the case when a dict is passed instead of a Pydantic model
@@ -216,18 +228,16 @@ class Route:
216
228
  func_info = FunctionInfo(handler=handler, is_async=is_async)
217
229
  return InternalRoute(path=path, function=func_info, method=method)
218
230
 
219
- def __call__(self, app, *args: Any, **kwds: Any) -> Any:
220
- router = Router(self.path)
231
+ def __call__(self, *args: Any, **kwds: Any) -> Any:
232
+ routes = []
221
233
 
222
234
  # Validate handlers
223
235
  if not self.endpoint and not self.functional_handlers:
224
236
  raise ValueError(f"No handler found for route: {self.path}")
225
237
 
226
238
  # Handle functional routes
227
- for route in self.functional_handlers:
228
- router.add_route(route=route)
229
239
  if not self.endpoint:
230
- return router
240
+ return self.functional_handlers
231
241
 
232
242
  # Handle class-based routes
233
243
  for name, func in self.endpoint.__dict__.items():
@@ -235,15 +245,15 @@ class Route:
235
245
  sig = inspect.signature(func)
236
246
  doc = self.swagger_generate(sig, func.__doc__)
237
247
  endpoint_obj = self.endpoint()
238
- route = self.make_internal_route(path="/", handler=endpoint_obj.dispatch, method=name.upper())
248
+ route = self.make_internal_route(path=self.path, handler=endpoint_obj.dispatch, method=name.upper())
239
249
  route.doc = doc
240
- router.add_route(route=route)
250
+ routes.append(route)
241
251
  del endpoint_obj # free up memory
242
- return router
252
+ return routes
243
253
 
244
254
  def add_route(
245
255
  self,
246
- path: str,
256
+ func_path: str,
247
257
  method: str,
248
258
  ) -> Callable:
249
259
  def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
@@ -251,7 +261,7 @@ class Route:
251
261
  return await dispatch(func, request, inject)
252
262
 
253
263
  sig = inspect.signature(func)
254
- route = self.make_internal_route(path=path, handler=functional_wrapper, method=method.upper())
264
+ route = self.make_internal_route(path=join_url_paths(self.path, func_path), handler=functional_wrapper, method=method.upper())
255
265
  route.doc = self.swagger_generate(sig, func.__doc__)
256
266
 
257
267
  self.functional_handlers.append(route)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypern
3
- Version: 0.3.11
3
+ Version: 0.3.13
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -1,11 +1,10 @@
1
- hypern-0.3.11.dist-info/METADATA,sha256=-2r4DYRXkj0n9UAhfrPIHfyBjHmxUcDL9eUM4zLu5tw,4113
2
- hypern-0.3.11.dist-info/WHEEL,sha256=2fdNHxJvS2bAcI00delQ4QrnR7Oujl4cP2y-SRm5elU,96
3
- hypern-0.3.11.dist-info/licenses/LICENSE,sha256=qbYKAIJLS6jYg5hYncKE7OtWmqOtpVTvKNkwOa0Iwwg,1328
4
- hypern/application.py,sha256=EVa3bjUjgEmM7jDpGTVcFlBa7kk2m69QMlpdsp8AWpU,18068
1
+ hypern-0.3.13.dist-info/METADATA,sha256=20_i10D2lXPg98Ulw0ZTAYK2G6a60bmN3htkOiV-oJw,4113
2
+ hypern-0.3.13.dist-info/WHEEL,sha256=2fdNHxJvS2bAcI00delQ4QrnR7Oujl4cP2y-SRm5elU,96
3
+ hypern-0.3.13.dist-info/licenses/LICENSE,sha256=qbYKAIJLS6jYg5hYncKE7OtWmqOtpVTvKNkwOa0Iwwg,1328
4
+ hypern/application.py,sha256=wg2luKL569sf4--_ao1Swc1Eroz1w25xKI2urezS6Ss,18091
5
5
  hypern/args_parser.py,sha256=1v41RZT-35iY80I5OugjeFPXPr28HUvniQwu-29y1vw,2222
6
6
  hypern/auth/authorization.py,sha256=-NprZsI0np889ZN1fp-MiVFrPoMNzUtatBJaCMtkllM,32
7
7
  hypern/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- hypern/background.py,sha256=xy38nQZSJsYFRXr3-uFJeNW9E1GiXXOC7lSe5pC0eyE,124
9
8
  hypern/caching/backend.py,sha256=bfSEgJQxS3FDdj08CY4V9b9U3rwf4uy9gS46QmwA3Zc,829
10
9
  hypern/caching/redis_backend.py,sha256=SWYlJvr8qi2kS_grhxhqQBLEEATpFremT2XyXkio8h0,5968
11
10
  hypern/caching/strategies.py,sha256=qQjqgZLUX7KZjhwPD4SYUaMRewgCgsp6qa1FunK3Y0I,7288
@@ -22,8 +21,8 @@ hypern/database/sqlx/model.py,sha256=C8_rJA1Adw1yPWthjmAGh26hjTBuwwlEdtH45ADxvL0
22
21
  hypern/database/sqlx/query.py,sha256=db4gKmw_Lvud2xUe97Kec886vLVMRkjoqFasSHxZMiA,33346
23
22
  hypern/database/sqlx/__init__.py,sha256=dbSAz2nP0DPKK4Bb_jJdObSaSYQfgZ8D4U1TJdc4e7c,645
24
23
  hypern/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- hypern/datastructures.py,sha256=Pxr9KsZZTFfp0KC1-A4v5AkQfmrUyvVwxKuToQUOLoE,882
26
- hypern/enum.py,sha256=KcVziJj7vWvyie0r2rtxhrLzdtkZAsf0DY58oJ4tQl4,360
24
+ hypern/datastructures.py,sha256=UiE8N81lmakTE3S8UDNvZ49fV6gK2MTi6BRWZhTNRks,643
25
+ hypern/enum.py,sha256=9UTDaFsXFa4Ez0ijRKlkzjV-0P4FadIb4fy6a3Sth7g,576
27
26
  hypern/exceptions/base.py,sha256=5AgfyEea79JjKk5MeAIJ-wy44FG5XEU0Jn3KXKScPiI,2017
28
27
  hypern/exceptions/common.py,sha256=0E8wHRRTWjYOmtOCkTDvZ5NMwL6vRW6aiDD9X1eYA30,227
29
28
  hypern/exceptions/errors.py,sha256=oAaeTeMgJEpQHspwZDG7B36FD6u6MoLgsxxDTxD7opc,857
@@ -50,24 +49,23 @@ hypern/middleware/__init__.py,sha256=V-Gnv-Jf-14BVuA28z7PN7GBVQ9BBiBdab6-QnTPCfY
50
49
  hypern/openapi/schemas.py,sha256=hsqSPpwsOETQ5NoGiR9Ay0qEp6GxJ2xhh69rzwxx0CY,1598
51
50
  hypern/openapi/swagger.py,sha256=naqUY3rFAEYA1ZLIlmDsMYaol0yIm6TVebdkFa5cMTc,64
52
51
  hypern/openapi/__init__.py,sha256=4rEVD8pa0kdSpsy7ZkJ5JY0Z2XF0NGSKDMwYAd7YZpE,141
53
- hypern/processpool.py,sha256=qEsu9WXWc3_Cl0Frn1jGs7jUJho45zck5L5Ww81Vm70,3883
52
+ hypern/processpool.py,sha256=S5zMapUDnniSkv_XDtwhVp6tT2BVTVzw9YYATHGnMIc,3760
54
53
  hypern/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
54
  hypern/reload.py,sha256=nfaZCoChrQetHNtIqN4Xzi-a0v-irxSCMhwCK3bCEq0,1569
56
- hypern/response/response.py,sha256=Jrkpk5KOmE4WjsAh1G0hUuPHfOPxU6eeR3J2fRIhusU,4871
55
+ hypern/response/response.py,sha256=Ri6Pq7FWorHgV4zy3Ji5ve5sOmUS3L2JOzBSo7HIKtM,4839
57
56
  hypern/response/__init__.py,sha256=_w3u3TDNuYx5ejnnN1unqnTY8NlBgUATQi6wepEB_FQ,226
58
57
  hypern/routing/dispatcher.py,sha256=NAVjILlEJjYrixJZ4CO4N1CKkuqbk4TGZOjnQNTTEu4,2461
59
58
  hypern/routing/endpoint.py,sha256=RKVhvqOEGL9IKBXQ3KJgPi9bgJj9gfWC5BdZc5U_atc,1026
60
- hypern/routing/parser.py,sha256=0tJVVNwHC3pWDsehwH6SwJv8_gEuDjltVXrNQWbHyrU,3426
59
+ hypern/routing/parser.py,sha256=B6NPzrGFz7VzzllNZts2N7CEOm-9wi2VG_DLEqadRlk,3418
61
60
  hypern/routing/queue.py,sha256=NtFBbogU22ddyyX-CuQMip1XFDPZdMCVMIeUCQ-CR6Y,7176
62
- hypern/routing/route.py,sha256=kan47-UeL-OPwcpp0rEhmBaaum6hN7FUj13Y8pZDEYA,10256
61
+ hypern/routing/route.py,sha256=caUld17-fzXJLgf-N16zjX_X9-ArA6rEPFN-34gfTPQ,10486
63
62
  hypern/routing/__init__.py,sha256=U4xW5fDRsn03z4cVLT4dJHHGGU6SVxyv2DL86LXodeE,162
64
- hypern/scheduler.py,sha256=-k3tW2AGCnHYSthKXk-FOs_SCtWp3yIxQzwzUJMJsbo,67
65
63
  hypern/worker.py,sha256=ksJW8jWQg3HbIYnIZ5qdAmO-yh5hLpwvTT3dKkHR4Eo,9761
66
64
  hypern/ws/channel.py,sha256=0ns2qmeoFJOpGLXS_hqldhywDQm_DxHwj6KloQx4Q3I,3183
67
65
  hypern/ws/heartbeat.py,sha256=sWMXzQm6cbDHHA2NHc-gFjv7G_E56XtxswHQ93_BueM,2861
68
66
  hypern/ws/room.py,sha256=0_L6Nun0n007F0rfNY8yX5x_A8EuXuI67JqpMkJ4RNI,2598
69
67
  hypern/ws/route.py,sha256=fGQ2RC708MPOiiIHPUo8aZ-oK379TTAyQYm4htNA5jM,803
70
68
  hypern/ws/__init__.py,sha256=dhRoRY683_rfPfSPM5qUczfTuyYDeuLOCFxY4hIdKt8,131
71
- hypern/__init__.py,sha256=p3AtJQbsPs1RYEiN1thxH-k5UP8FfLeiJSoP0Vt3MDg,639
72
- hypern/hypern.cp312-win_amd64.pyd,sha256=IuM_asKI8qx6__66_wzT40P_TD_ma53w_WpdXaiikno,9590784
73
- hypern-0.3.11.dist-info/RECORD,,
69
+ hypern/__init__.py,sha256=uZ9JTG3WUCewhzarfVrZUlvMzzbiq6-J1jsVb7mp2XE,808
70
+ hypern/hypern.cp312-win_amd64.pyd,sha256=wNmgWN5t1yxbCB9ofm8uEa7rFNQKa0XTVpOa00ALYxY,9644544
71
+ hypern-0.3.13.dist-info/RECORD,,
hypern/background.py DELETED
@@ -1,4 +0,0 @@
1
- from .hypern import BackgroundTask
2
- from .hypern import BackgroundTasks
3
-
4
- __all__ = ["BackgroundTask", "BackgroundTasks"]
hypern/scheduler.py DELETED
@@ -1,5 +0,0 @@
1
- from .hypern import Scheduler
2
-
3
- __all__ = [
4
- "Scheduler",
5
- ]