Skip to content

Commit 70476ba

Browse files
committed
Clean up unused imports, debug print statements
1 parent 754d482 commit 70476ba

File tree

3 files changed

+0
-18
lines changed

3 files changed

+0
-18
lines changed

flask_parameter_validation/parameter_types/parameter.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
Base Parameter class.
33
Should only be used as child class for other params.
44
"""
5-
import json
65
import re
76
from datetime import date, datetime, time
8-
97
import dateutil.parser as parser
108
import jsonschema
119
from jsonschema.exceptions import ValidationError as JSONSchemaValidationError
@@ -68,7 +66,6 @@ def func_helper(self, v):
6866

6967
# Validator
7068
def validate(self, value):
71-
print(f"Parameter#validate received {type(value)}")
7269
original_value_type_list = type(value) is list
7370
if type(value) is list:
7471
values = value
@@ -89,16 +86,13 @@ def validate(self, value):
8986
if self.json_schema is not None:
9087
try:
9188
jsonschema.validate(value, self.json_schema)
92-
print("JSON Schema Passed")
9389
except JSONSchemaValidationError as e:
9490
raise ValueError(f"failed JSON Schema validation: {e.args[0]}")
9591
elif type(value) is dict:
96-
print("dict validate path")
9792
if self.json_schema is not None:
9893
try:
9994
jsonschema.validate(value, self.json_schema)
10095
except JSONSchemaValidationError as e:
101-
print("Failed JSON Schema")
10296
raise ValueError(f"failed JSON Schema validation: {e.args[0]}")
10397
values = [value]
10498
else:
@@ -162,7 +156,6 @@ def validate(self, value):
162156

163157
def convert(self, value, allowed_types):
164158
"""Some parameter types require manual type conversion (see Query)"""
165-
print(f"Parameter#convert received {type(value)}")
166159
# Datetime conversion
167160
if None in allowed_types and value is None:
168161
return value
@@ -190,5 +183,4 @@ def convert(self, value, allowed_types):
190183
return date.fromisoformat(str(value))
191184
except ValueError:
192185
raise ValueError("date format does not match ISO 8601")
193-
print(f"Parameter#convert returned {type(value)}")
194186
return value

flask_parameter_validation/parameter_types/query.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def __init__(self, default=None, **kwargs):
1515

1616
def convert(self, value, allowed_types):
1717
"""Convert query parameters to corresponding types."""
18-
print(f"Query#convert received {type(value)}")
1918
if type(value) is str:
2019
# int conversion
2120
if int in allowed_types:
@@ -43,5 +42,4 @@ def convert(self, value, allowed_types):
4342
value = json.loads(value)
4443
except ValueError:
4544
raise ValueError(f"invalid JSON")
46-
print(f"Query#convert returned {type(value)}")
4745
return super().convert(value, allowed_types)

flask_parameter_validation/parameter_validation.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import asyncio
22
import functools
33
import inspect
4-
import json
54
import re
65
from inspect import signature
7-
86
from flask import request
97
from werkzeug.datastructures import ImmutableMultiDict
108
from werkzeug.exceptions import BadRequest
11-
129
from .exceptions import (InvalidParameterTypeError, MissingInputError,
1310
ValidationError)
1411
from .parameter_types import File, Form, Json, Query, Route
@@ -204,9 +201,6 @@ def validate(self, expected_input, all_request_inputs):
204201
user_inputs[count] = expected_delivery_type.convert(
205202
value, expected_input_types
206203
)
207-
for t in expected_input_types:
208-
print(f"Expected type: {t}")
209-
print(f"Appended value of type {type(user_inputs[count])} to user_inputs")
210204
except ValueError as e:
211205
raise ValidationError(str(e), expected_name, expected_input_type)
212206

@@ -220,8 +214,6 @@ def validate(self, expected_input, all_request_inputs):
220214
if type(user_input) is not list:
221215
validation_success = False
222216

223-
print(f"Validation Success? {validation_success}")
224-
225217
# Error if types don't match
226218
if not validation_success:
227219
if hasattr(

0 commit comments

Comments
 (0)