mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-24 19:32:53 +03:00
Fix some flake8/pycodestyle issues
This commit is contained in:
parent
2f7314d105
commit
19f0ddb336
@ -55,7 +55,7 @@ class LocalizedFieldForm(forms.MultiValueField):
|
|||||||
for field, widget in zip(self.fields, self.widget.widgets):
|
for field, widget in zip(self.fields, self.widget.widgets):
|
||||||
widget.is_required = field.required
|
widget.is_required = field.required
|
||||||
|
|
||||||
def compress(self, value: List[str]) -> value_class:
|
def compress(self, value: List[str]) -> LocalizedValue:
|
||||||
"""Compresses the values from individual fields into a single
|
"""Compresses the values from individual fields into a single
|
||||||
:see:LocalizedValue instance.
|
:see:LocalizedValue instance.
|
||||||
|
|
||||||
@ -123,13 +123,8 @@ class LocalizedFileFieldForm(LocalizedFieldForm, forms.FileField):
|
|||||||
clean_data = []
|
clean_data = []
|
||||||
errors = []
|
errors = []
|
||||||
if not value or isinstance(value, (list, tuple)):
|
if not value or isinstance(value, (list, tuple)):
|
||||||
if (
|
is_empty = [v for v in value if v not in self.empty_values]
|
||||||
not value
|
if (not value or not is_empty) and (not initial or not is_empty):
|
||||||
or not [v for v in value if v not in self.empty_values]
|
|
||||||
) and (
|
|
||||||
not initial
|
|
||||||
or not [v for v in initial if v not in self.empty_values]
|
|
||||||
):
|
|
||||||
if self.required:
|
if self.required:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
self.error_messages["required"], code="required"
|
self.error_messages["required"], code="required"
|
||||||
@ -143,6 +138,7 @@ class LocalizedFileFieldForm(LocalizedFieldForm, forms.FileField):
|
|||||||
field_value = value[i]
|
field_value = value[i]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
field_value = None
|
field_value = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
field_initial = initial[i]
|
field_initial = initial[i]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
# Analysis
|
# Analysis
|
||||||
black==19.3b0
|
black==19.3b0
|
||||||
flake8==3.7.7
|
flake8==3.7.7
|
||||||
pycodestyle==2.5.0
|
|
||||||
autoflake==1.3
|
autoflake==1.3
|
||||||
autopep8==1.4.4
|
autopep8==1.4.4
|
||||||
isort==4.3.20
|
isort==4.3.20
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
[flake8]
|
[flake8]
|
||||||
ignore = E252,E501
|
ignore = E252,E501,W503
|
||||||
exclude = env,.tox,.git,config/settings,*/migrations/*,*/static/CACHE/*,docs,node_modules
|
exclude = env,.tox,.git,config/settings,*/migrations/*,*/static/CACHE/*,docs,node_modules
|
||||||
|
|
||||||
[pycodestyle]
|
|
||||||
ignore = E501
|
|
||||||
exclude=env,.tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules
|
|
||||||
|
|
||||||
[isort]
|
[isort]
|
||||||
line_length=80
|
line_length=80
|
||||||
multi_line_output=3
|
multi_line_output=3
|
||||||
|
7
setup.py
7
setup.py
@ -62,10 +62,7 @@ setup(
|
|||||||
cmdclass={
|
cmdclass={
|
||||||
"lint": create_command(
|
"lint": create_command(
|
||||||
"Lints the code",
|
"Lints the code",
|
||||||
[
|
[["flake8", "setup.py", "localized_fields", "tests"]],
|
||||||
["flake8", "setup.py", "localized_fields", "tests"],
|
|
||||||
["pycodestyle", "setup.py", "localized_fields", "tests"],
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
"lint_fix": create_command(
|
"lint_fix": create_command(
|
||||||
"Lints the code",
|
"Lints the code",
|
||||||
@ -131,13 +128,11 @@ setup(
|
|||||||
),
|
),
|
||||||
"verify": create_command(
|
"verify": create_command(
|
||||||
"Verifies whether the code is auto-formatted and has no linting errors",
|
"Verifies whether the code is auto-formatted and has no linting errors",
|
||||||
[
|
|
||||||
[
|
[
|
||||||
["python", "setup.py", "format_verify"],
|
["python", "setup.py", "format_verify"],
|
||||||
["python", "setup.py", "format_docstrings_verify"],
|
["python", "setup.py", "format_docstrings_verify"],
|
||||||
["python", "setup.py", "sort_imports_verify"],
|
["python", "setup.py", "sort_imports_verify"],
|
||||||
["python", "setup.py", "lint"],
|
["python", "setup.py", "lint"],
|
||||||
]
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
"test": create_command(
|
"test": create_command(
|
||||||
|
@ -82,4 +82,4 @@ class LocalizedFieldWidgetTestCase(TestCase):
|
|||||||
|
|
||||||
widget = LocalizedFieldWidget()
|
widget = LocalizedFieldWidget()
|
||||||
output = widget.render(name="title", value=None)
|
output = widget.render(name="title", value=None)
|
||||||
assert bool(re.search("<label (.|\n|\t)*>\w+<\/label>", output))
|
assert bool(re.search(r"<label (.|\n|\t)*>\w+<\/label>", output))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user