Skip to content

Commit 3d9501a

Browse files
committed
31 | Add fallback for cython
1 parent 6af3323 commit 3d9501a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1471
-79
lines changed

.github/workflows/publish-to-pypi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Checkout code
1313
uses: actions/checkout@v4
1414

15-
- uses: actions/setup-python@v4
15+
- uses: actions/setup-python@v5
1616
with:
1717
python-version: 3.11
1818

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
uses: actions/cache@v4
1818
with:
1919
path: /tmp/.buildx-cache
20-
key: ${{ runner.os }}-docker-flask-inputfilter-env-${{ hashFiles('env_configs/Dockerfile') }}
20+
key: ${{ runner.os }}-docker-flask-inputfilter-env-${{ hashFiles('env_configs/env.Dockerfile') }}
2121
restore-keys: |
2222
${{ runner.os }}-docker-flask-inputfilter-env-
2323
2424
- name: Set up Docker Buildx
25-
uses: docker/setup-buildx-action@v2
25+
uses: docker/setup-buildx-action@v3
2626
with:
2727
driver-opts: image=moby/buildkit:latest
2828

@@ -32,7 +32,7 @@ jobs:
3232
--cache-from=type=local,src=/tmp/.buildx-cache \
3333
--cache-to=type=local,dest=/tmp/.buildx-cache,mode=max \
3434
-t flask-inputfilter-env \
35-
-f env_configs/Dockerfile \
35+
-f env_configs/env.Dockerfile \
3636
. --load
3737
3838
- name: Run tests in Docker

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

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ on:
77
pull_request:
88

99
jobs:
10-
build-and-test:
10+
build-and-test-pure:
1111
runs-on: ubuntu-latest
1212

1313
steps:
1414
- uses: actions/checkout@v4
1515

16-
- uses: actions/setup-python@v4
16+
- name: Remove g++ compiler
17+
run: sudo apt-get remove --purge -y g++
18+
19+
- uses: actions/setup-python@v5
1720
with:
1821
python-version: 3.11
1922

@@ -25,10 +28,43 @@ jobs:
2528
id: build
2629

2730
- name: Install built library
28-
run: pip install "$(ls dist/*.whl | head -n 1)[optional]"
31+
run: pip install "$(ls dist/*.tar.gz | head -n 1)[optional]"
2932

3033
- name: Verify library usage - Part I
31-
run: python -c "import flask_inputfilter.InputFilter"
34+
run: |
35+
python -c "import flask_inputfilter.InputFilter"
36+
python -c "from flask_inputfilter import InputFilter"
3237
3338
- name: Verify library usage - Part II
3439
run: pytest tests/
40+
41+
build-and-test-cython:
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Install compilers
48+
run: sudo apt-get install -y g++
49+
50+
- uses: actions/setup-python@v5
51+
with:
52+
python-version: 3.11
53+
54+
- name: Install build tools and test dependencies
55+
run: pip install build pytest
56+
57+
- name: Build the library
58+
run: python -m build
59+
id: build
60+
61+
- name: Install built library
62+
run: pip install "$(ls dist/*.tar.gz | head -n 1)[optional]"
63+
64+
- name: Verify library usage - Part I
65+
run: |
66+
python -c "import flask_inputfilter.InputFilter"
67+
python -c "from flask_inputfilter import InputFilter"
68+
69+
#- name: Verify library usage - Part II
70+
# run: pytest tests/

.github/workflows/test.yaml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions:
77
contents: read
88

99
jobs:
10-
build:
10+
build-and-test-pure:
1111
runs-on: ubuntu-latest
1212

1313
steps:
@@ -17,21 +17,21 @@ jobs:
1717
uses: actions/cache@v4
1818
with:
1919
path: /tmp/.buildx-cache
20-
key: ${{ runner.os }}-docker-flask-inputfilter-${{ hashFiles('Dockerfile') }}
20+
key: ${{ runner.os }}-docker-flask-inputfilter-pure-${{ hashFiles('env_configs/pure.Dockerfile') }}
2121
restore-keys: |
22-
${{ runner.os }}-docker-flask-inputfilter-
22+
${{ runner.os }}-docker-flask-inputfilter-pure-
2323
2424
- name: Set up Docker Buildx
25-
uses: docker/setup-buildx-action@v2
25+
uses: docker/setup-buildx-action@v3
2626
with:
2727
driver-opts: image=moby/buildkit:latest
2828

29-
- name: Build flask-inputfilter image with cache
29+
- name: Build flask-inputfilter-pure image with cache
3030
run: |
3131
docker buildx build \
3232
--cache-from=type=local,src=/tmp/.buildx-cache \
3333
--cache-to=type=local,dest=/tmp/.buildx-cache,mode=max \
34-
-t flask-inputfilter . --load
34+
-t flask-inputfilter-pure -f env_configs/pure.Dockerfile . --load
3535
3636
- name: Run tests in Docker and upload coverage to Coveralls
3737
env:
@@ -41,12 +41,48 @@ jobs:
4141
set -e # Exit immediately if a command exits with a non-zero status.
4242
set -u # Exit immediately if a variable is not defined.
4343
44-
docker run --rm -e COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }} flask-inputfilter sh -c "coverage run --source=flask_inputfilter -m pytest tests/ && coveralls"
44+
docker run --rm -e COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }} flask-inputfilter-pure sh -c "coverage run --source=flask_inputfilter -m pytest tests/ && coveralls"
4545
4646
- name: Run code style checks
4747
run: |
4848
set -x # Print commands and their arguments as they are executed
4949
set -e # Exit immediately if a command exits with a non-zero status
5050
set -u # Exit immediately if a variable is not defined
5151
52-
docker run --rm flask-inputfilter flake8
52+
docker run --rm flask-inputfilter-pure flake8
53+
54+
build-and-test-cython:
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Cache Docker layers
61+
uses: actions/cache@v4
62+
with:
63+
path: /tmp/.buildx-cache
64+
key: ${{ runner.os }}-docker-flask-inputfilter-cython-${{ hashFiles('env_configs/cython.Dockerfile') }}
65+
restore-keys: |
66+
${{ runner.os }}-docker-flask-inputfilter-cython-
67+
68+
- name: Set up Docker Buildx
69+
uses: docker/setup-buildx-action@v3
70+
with:
71+
driver-opts: image=moby/buildkit:latest
72+
73+
- name: Build flask-inputfilter-cython image with cache
74+
run: |
75+
docker buildx build \
76+
--cache-from=type=local,src=/tmp/.buildx-cache \
77+
--cache-to=type=local,dest=/tmp/.buildx-cache,mode=max \
78+
-t flask-inputfilter-cython -f env_configs/cython.Dockerfile . --load
79+
80+
- name: Run tests in Docker
81+
env:
82+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
83+
run: |
84+
set -x # Print commands and their arguments as they are executed.
85+
set -e # Exit immediately if a command exits with a non-zero status.
86+
set -u # Exit immediately if a variable is not defined.
87+
88+
docker run --rm flask-inputfilter-cython pytest

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
flask-inputfilter:
44
build:
55
context: .
6-
dockerfile: Dockerfile
6+
dockerfile: env_configs/cython.Dockerfile
77
container_name: flask-inputfilter
88
volumes:
99
- .:/app

docs/source/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ Changelog
33

44
All notable changes to this project will be documented in this file.
55

6+
[0.4.0a2] - 2025-04-17
7+
----------------------
8+
9+
Changed
10+
^^^^^^^
11+
- Added fallback for ``cython`` to use ``python`` if no c++ compiler is installed.
12+
- super().__init__() is now **ONLY** optional, if you are using the cython version.
13+
14+
615
[0.4.0a1] - 2025-04-17
716
----------------------
817

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project = "flask-inputfilter"
22
copyright = "2025, Leander Cain Slotosch"
33
author = "Leander Cain Slotosch"
4-
release = "0.4.0a1"
4+
release = "0.4.0a2"
55

66
extensions = ["sphinx_rtd_theme"]
77

docs/source/guides/frontend_validation.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Example implementation
2424
2525
class UpdateZipcodeInputFilter(InputFilter):
2626
def __init__(self):
27+
super().__init__()
2728
2829
self.add(
2930
'id',

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Definition
6363
6464
class UpdateZipcodeInputFilter(InputFilter):
6565
def __init__(self):
66+
super().__init__()
6667
6768
self.add(
6869
'id',

docs/source/options/condition.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Example
2020
2121
class TestInputFilter(InputFilter):
2222
def __init__(self):
23+
super().__init__()
2324
2425
self.add(
2526
'username',
@@ -88,6 +89,7 @@ Validates that the length of the array from ``first_array_field`` is equal to th
8889
8990
class ArrayLengthFilter(InputFilter):
9091
def __init__(self):
92+
super().__init__()
9193
9294
self.add(
9395
'list1',
@@ -127,6 +129,7 @@ Validates that the array in ``longer_field`` has more elements than the array in
127129
128130
class ArrayComparisonFilter(InputFilter):
129131
def __init__(self):
132+
super().__init__()
130133
131134
self.add(
132135
'list1',
@@ -168,6 +171,7 @@ Executes the provided callable with the input data. The condition passes if the
168171
169172
class CustomFilter(InputFilter):
170173
def __init__(self):
174+
super().__init__()
171175
172176
self.add(
173177
'age',
@@ -201,6 +205,7 @@ Validates that the values of ``first_field`` and ``second_field`` are equal. Fai
201205
202206
class EqualFieldsFilter(InputFilter):
203207
def __init__(self):
208+
super().__init__()
204209
205210
self.add(
206211
'password'
@@ -237,6 +242,7 @@ Counts the number of specified fields present in the data and validates that the
237242
238243
class ExactFieldsFilter(InputFilter):
239244
def __init__(self):
245+
super().__init__()
240246
241247
self.add(
242248
'field1'
@@ -278,6 +284,7 @@ Validates that exactly ``n`` fields among the specified ones have the given valu
278284
279285
class MatchFieldsFilter(InputFilter):
280286
def __init__(self):
287+
super().__init__()
281288
282289
self.add(
283290
'field1'
@@ -313,6 +320,7 @@ Validates that only one field among the specified fields exists in the input dat
313320
314321
class OneFieldFilter(InputFilter):
315322
def __init__(self):
323+
super().__init__()
316324
317325
self.add(
318326
'email'
@@ -349,6 +357,7 @@ Validates that exactly one of the specified fields has the given value.
349357
350358
class OneMatchFilter(InputFilter):
351359
def __init__(self):
360+
super().__init__()
352361
353362
self.add(
354363
'option1'
@@ -386,6 +395,7 @@ Validates that the integer value from ``bigger_field`` is greater than the value
386395
387396
class NumberComparisonFilter(InputFilter):
388397
def __init__(self):
398+
super().__init__()
389399
390400
self.add(
391401
'field_should_be_bigger',
@@ -424,6 +434,7 @@ Validates that the count of the specified fields present is greater than or equa
424434
425435
class MinimumFieldsFilter(InputFilter):
426436
def __init__(self):
437+
super().__init__()
427438
428439
self.add(
429440
'field1'
@@ -465,6 +476,7 @@ Validates that the count of fields matching the given value is greater than or e
465476
466477
class MinimumMatchFilter(InputFilter):
467478
def __init__(self):
479+
super().__init__()
468480
469481
self.add(
470482
'field1'
@@ -501,6 +513,7 @@ Validates that the values of ``first_field`` and ``second_field`` are not equal.
501513
502514
class DifferenceFilter(InputFilter):
503515
def __init__(self):
516+
super().__init__()
504517
505518
self.add(
506519
'field1'
@@ -536,6 +549,7 @@ Validates that at least one field from the specified list is present. Fails if n
536549
537550
class OneFieldRequiredFilter(InputFilter):
538551
def __init__(self):
552+
super().__init__()
539553
540554
self.add(
541555
'email'
@@ -572,6 +586,7 @@ Validates that at least one field from the specified list has the given value.
572586
573587
class OneMatchRequiredFilter(InputFilter):
574588
def __init__(self):
589+
super().__init__()
575590
576591
self.add(
577592
'option1'
@@ -609,6 +624,7 @@ If the value of ``condition_field`` matches the specified value (or is in the sp
609624
610625
class ConditionalRequiredFilter(InputFilter):
611626
def __init__(self):
627+
super().__init__()
612628
613629
self.add(
614630
'status'
@@ -651,6 +667,7 @@ Validates that the string in ``longer_field`` has a greater length than the stri
651667
652668
class StringLengthFilter(InputFilter):
653669
def __init__(self):
670+
super().__init__()
654671
655672
self.add(
656673
'description'
@@ -687,6 +704,7 @@ Validates that the date in ``smaller_date_field`` is earlier than the date in ``
687704
688705
class DateOrderFilter(InputFilter):
689706
def __init__(self):
707+
super().__init__()
690708
691709
self.add(
692710
'start_date'

0 commit comments

Comments
 (0)