Skip to content

Commit

Permalink
Refactor regex to pattern in param functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfkny committed Nov 12, 2024
1 parent 82d7bd6 commit 482516f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions ninja/params/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, TypeVar
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Pattern, TypeVar, Union

from typing_extensions import Annotated

Expand Down Expand Up @@ -86,7 +86,7 @@ def P(
le: Optional[float] = None,
min_length: Optional[int] = None,
max_length: Optional[int] = None,
regex: Optional[str] = None,
pattern: Union[str, Pattern[str], None] = None,
example: Any = None,
examples: Optional[Dict[str, Any]] = None,
deprecated: Optional[bool] = None,
Expand All @@ -104,7 +104,7 @@ def P(
le=le,
min_length=min_length,
max_length=max_length,
regex=regex,
pattern=pattern,
example=example,
examples=examples,
deprecated=deprecated,
Expand Down
30 changes: 15 additions & 15 deletions ninja/params/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# what it basically does makes function XXX that create instance of models.XXX
# and annotates function with result = Any
# idea from https://github.com/tiangolo/fastapi/blob/master/fastapi/param_functions.py
from typing import Any, Dict, Optional
from typing import Any, Dict, Optional, Pattern, Union

from ninja.params import models

Expand All @@ -20,7 +20,7 @@ def Path( # noqa: N802
le: Optional[float] = None,
min_length: Optional[int] = None,
max_length: Optional[int] = None,
regex: Optional[str] = None,
pattern: Union[str, Pattern[str], None] = None,
example: Any = None,
examples: Optional[Dict[str, Any]] = None,
deprecated: Optional[bool] = None,
Expand All @@ -38,7 +38,7 @@ def Path( # noqa: N802
le=le,
min_length=min_length,
max_length=max_length,
regex=regex,
pattern=pattern,
example=example,
examples=examples,
deprecated=deprecated,
Expand All @@ -59,7 +59,7 @@ def Query( # noqa: N802
le: Optional[float] = None,
min_length: Optional[int] = None,
max_length: Optional[int] = None,
regex: Optional[str] = None,
pattern: Union[str, Pattern[str], None] = None,
example: Any = None,
examples: Optional[Dict[str, Any]] = None,
deprecated: Optional[bool] = None,
Expand All @@ -77,7 +77,7 @@ def Query( # noqa: N802
le=le,
min_length=min_length,
max_length=max_length,
regex=regex,
pattern=pattern,
example=example,
examples=examples,
deprecated=deprecated,
Expand All @@ -98,7 +98,7 @@ def Header( # noqa: N802
le: Optional[float] = None,
min_length: Optional[int] = None,
max_length: Optional[int] = None,
regex: Optional[str] = None,
pattern: Union[str, Pattern[str], None] = None,
example: Any = None,
examples: Optional[Dict[str, Any]] = None,
deprecated: Optional[bool] = None,
Expand All @@ -116,7 +116,7 @@ def Header( # noqa: N802
le=le,
min_length=min_length,
max_length=max_length,
regex=regex,
pattern=pattern,
example=example,
examples=examples,
deprecated=deprecated,
Expand All @@ -137,7 +137,7 @@ def Cookie( # noqa: N802
le: Optional[float] = None,
min_length: Optional[int] = None,
max_length: Optional[int] = None,
regex: Optional[str] = None,
pattern: Union[str, Pattern[str], None] = None,
example: Any = None,
examples: Optional[Dict[str, Any]] = None,
deprecated: Optional[bool] = None,
Expand All @@ -155,7 +155,7 @@ def Cookie( # noqa: N802
le=le,
min_length=min_length,
max_length=max_length,
regex=regex,
pattern=pattern,
example=example,
examples=examples,
deprecated=deprecated,
Expand All @@ -176,7 +176,7 @@ def Body( # noqa: N802
le: Optional[float] = None,
min_length: Optional[int] = None,
max_length: Optional[int] = None,
regex: Optional[str] = None,
pattern: Union[str, Pattern[str], None] = None,
example: Any = None,
examples: Optional[Dict[str, Any]] = None,
deprecated: Optional[bool] = None,
Expand All @@ -194,7 +194,7 @@ def Body( # noqa: N802
le=le,
min_length=min_length,
max_length=max_length,
regex=regex,
pattern=pattern,
example=example,
examples=examples,
deprecated=deprecated,
Expand All @@ -215,7 +215,7 @@ def Form( # noqa: N802
le: Optional[float] = None,
min_length: Optional[int] = None,
max_length: Optional[int] = None,
regex: Optional[str] = None,
pattern: Union[str, Pattern[str], None] = None,
example: Any = None,
examples: Optional[Dict[str, Any]] = None,
deprecated: Optional[bool] = None,
Expand All @@ -233,7 +233,7 @@ def Form( # noqa: N802
le=le,
min_length=min_length,
max_length=max_length,
regex=regex,
pattern=pattern,
example=example,
examples=examples,
deprecated=deprecated,
Expand All @@ -254,7 +254,7 @@ def File( # noqa: N802
le: Optional[float] = None,
min_length: Optional[int] = None,
max_length: Optional[int] = None,
regex: Optional[str] = None,
pattern: Union[str, Pattern[str], None] = None,
example: Any = None,
examples: Optional[Dict[str, Any]] = None,
deprecated: Optional[bool] = None,
Expand All @@ -272,7 +272,7 @@ def File( # noqa: N802
le=le,
min_length=min_length,
max_length=max_length,
regex=regex,
pattern=pattern,
example=example,
examples=examples,
deprecated=deprecated,
Expand Down

0 comments on commit 482516f

Please sign in to comment.