|
4 | 4 | import enum |
5 | 5 | from contextlib import suppress |
6 | 6 |
|
7 | | -import sqlalchemy as sa |
8 | 7 | from dateutil.parser import parse |
| 8 | +import sqlalchemy as sa |
9 | 9 | from django import forms as djangoforms |
10 | 10 | from django.conf import settings |
11 | 11 | from django.core import validators as djangovalidators |
@@ -166,7 +166,7 @@ def clean(self, value, instance): |
166 | 166 |
|
167 | 167 | def validate(self, value, instance): |
168 | 168 | """Validate value and raise ValidationError if necessary.""" |
169 | | - getattr(instance, "clean_" + self.name, bool)() |
| 169 | + getattr(instance, f"clean_{self.name}", bool)() |
170 | 170 |
|
171 | 171 | def run_validators(self, value): |
172 | 172 | """Run field's validators and raise ValidationError if necessary.""" |
@@ -194,9 +194,7 @@ def __init__(self, column, prop=None, parent=None, name=None): |
194 | 194 | self.field_kwargs["max_length"] = self.column.type.length |
195 | 195 |
|
196 | 196 | def to_python(self, value): |
197 | | - if value is None: |
198 | | - return value |
199 | | - return str(value).strip() |
| 197 | + return value if value is None else str(value).strip() |
200 | 198 |
|
201 | 199 |
|
202 | 200 | class text_column_info(string_column_info): |
@@ -324,9 +322,7 @@ def to_python(self, value): |
324 | 322 | return bool(value) |
325 | 323 | if value in ("t", "T"): |
326 | 324 | return True |
327 | | - if value in ("f", "F"): |
328 | | - return False |
329 | | - return self.coercer.to_python(value) |
| 325 | + return False if value in ("f", "F") else self.coercer.to_python(value) |
330 | 326 |
|
331 | 327 |
|
332 | 328 | class date_column_info(column_info): |
|
0 commit comments