Skip to content

Commit c4ca474

Browse files
committed
0.3.0a4 | Test cthon
1 parent 8529666 commit c4ca474

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

.github/workflows/test-lib-building.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
name: Build and Test Library
22

3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
3+
on: [push]
84

95
jobs:
106
build-and-test:
Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
T = TypeVar("T")
3434

3535

36-
class InputFilter(
36+
cdef class InputFilter(
3737
ConditionMixin,
3838
DataMixin,
3939
ErrorHandlingMixin,
@@ -47,19 +47,18 @@ class InputFilter(
4747
Base class for input filters.
4848
"""
4949

50-
__slots__ = (
51-
"__methods",
52-
"_fields",
53-
"_conditions",
54-
"_global_filters",
55-
"_global_validators",
56-
"_data",
57-
"_validated_data",
58-
"_errors",
59-
"_model_class",
60-
)
61-
62-
def __init__(self, methods: Optional[List[str]] = None) -> None:
50+
cdef:
51+
list __methods
52+
dict _fields
53+
list _conditions
54+
list _global_filters
55+
list _global_validators
56+
dict _data
57+
dict _validated_data
58+
dict _errors
59+
object _model_class
60+
61+
cpdef __init__(self, methods: Optional[List[str]] = None):
6362
self.__methods = methods or ["GET", "POST", "PATCH", "PUT", "DELETE"]
6463
self._fields: Dict[str, FieldModel] = {}
6564
self._conditions: List[BaseCondition] = []
@@ -71,7 +70,7 @@ def __init__(self, methods: Optional[List[str]] = None) -> None:
7170
self._model_class: Optional[Type[T]] = None
7271

7372
@final
74-
def isValid(self) -> bool:
73+
cpdef bint isValid(self):
7574
"""
7675
Checks if the object's state or its attributes meet certain
7776
conditions to be considered valid. This function is typically used to
@@ -147,9 +146,9 @@ def wrapper(
147146
return decorator
148147

149148
@final
150-
def validateData(
149+
cpdef dict validateData(
151150
self, data: Optional[Dict[str, Any]] = None
152-
) -> Dict[str, Any]:
151+
):
153152
"""
154153
Validates input data against defined field rules, including applying
155154
filters, validators, custom logic steps, and fallback mechanisms. The

setup.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
from setuptools import find_packages, setup
1+
from setuptools import setup, find_packages
2+
from setuptools.extension import Extension
3+
4+
try:
5+
from Cython.Build import cythonize
6+
USE_CYTHON = True
7+
except ImportError:
8+
USE_CYTHON = False
9+
10+
ext_modules = []
11+
if USE_CYTHON:
12+
ext_modules = cythonize([
13+
Extension(
14+
"flask_inputfilter.InputFilter",
15+
["flask_inputfilter/InputFilter.pyx"],
16+
extra_compile_args=["-O3"]
17+
)
18+
])
219

320
setup(
421
name="flask_inputfilter",
5-
version="0.3.0",
22+
version="0.3.0a4",
623
license="MIT",
724
author="Leander Cain Slotosch",
825
author_email="[email protected]",
@@ -11,9 +28,14 @@
1128
long_description=open("README.rst").read(),
1229
long_description_content_type="text/x-rst",
1330
url="https://github.com/LeanderCS/flask-inputfilter",
14-
packages=find_packages(
15-
include=["flask_inputfilter", "flask_inputfilter.*"]
16-
),
31+
packages=find_packages(include=["flask_inputfilter", "flask_inputfilter.*"]),
32+
package_data={
33+
"flask_inputfilter": ["*.pyx", "*.pxd"]
34+
},
35+
setup_requires=[
36+
"cython>=0.29.0",
37+
],
38+
ext_modules=ext_modules,
1739
install_requires=[
1840
"flask>=2.1",
1941
"typing_extensions>=3.6.2",

0 commit comments

Comments
 (0)