Skip to content

Commit

Permalink
Apply default black line length
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Dec 18, 2018
1 parent 90f0e85 commit cc788f3
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ force_grid_wrap = false
include_trailing_comma = true

lines_after_imports = 2
line_length = 79
line_length = 88
2 changes: 0 additions & 2 deletions .pylint.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ disable=
cell-var-from-loop,
cyclic-import,

max-line-length = 79

[REPORTS]

score=no
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ docs: mkdocs uml ## Generate documentation and UML
.PHONY: mkdocs
mkdocs: install $(MKDOCS_INDEX)
$(MKDOCS_INDEX): mkdocs.yml docs/*.md
mkdir -p docs/about
cd docs && ln -sf ../README.md index.md
cd docs/about && ln -sf ../../CHANGELOG.md changelog.md
cd docs/about && ln -sf ../../CONTRIBUTING.md contributing.md
cd docs/about && ln -sf ../../LICENSE.md license.md
@ mkdir -p docs/about
@ cd docs && ln -sf ../README.md index.md
@ cd docs/about && ln -sf ../../CHANGELOG.md changelog.md
@ cd docs/about && ln -sf ../../CONTRIBUTING.md contributing.md
@ cd docs/about && ln -sf ../../LICENSE.md license.md
poetry run mkdocs build --clean --strict

.PHONY: mkdocs-live
Expand Down
4 changes: 1 addition & 3 deletions datafiles/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,7 @@ def to_preserialization_data(cls, python_value, *, skip=Missing):

elif isinstance(python_value, set):
data.extend(
sorted(
convert(item, skip=Missing) for item in python_value
)
sorted(convert(item, skip=Missing) for item in python_value)
)

else:
Expand Down
28 changes: 7 additions & 21 deletions datafiles/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ def _get_data(self, include_default_values: Trilean = None) -> Dict:

for field in dataclasses.fields(converter.DATACLASS):
if field.name not in value:
log.debug(
f'Added missing nested attribute: {field.name}'
)
log.debug(f'Added missing nested attribute: {field.name}')
value[field.name] = None

data[name] = converter.to_preserialization_data(
Expand All @@ -129,9 +127,7 @@ def _get_data(self, include_default_values: Trilean = None) -> Dict:
data.pop(name)

else:
log.debug(
f"Converting '{name}' value with {converter}: {value!r}"
)
log.debug(f"Converting '{name}' value with {converter}: {value!r}")
data[name] = converter.to_preserialization_data(value)

log.debug(f'Preserialized object data: {data}')
Expand Down Expand Up @@ -187,9 +183,7 @@ def _set_dataclass_value(self, data, name, converter, first_load):
for field in dataclasses.fields(converter.DATACLASS):
if field.name not in nested_data: # type: ignore
nested_data[field.name] = None # type: ignore
dataclass = converter.to_python_value(
nested_data, target=dataclass
)
dataclass = converter.to_python_value(nested_data, target=dataclass)
elif first_load:
return

Expand All @@ -206,9 +200,7 @@ def _set_dataclass_value(self, data, name, converter, first_load):
name2,
dataclass.datafile._get_default_field_value(name2),
)
value = converter2.to_python_value(
_value, target=getattr(dataclass, name2)
)
value = converter2.to_python_value(_value, target=getattr(dataclass, name2))
log.debug(f"'{name2}' as Python: {value!r}")
setattr(dataclass, name2, value)

Expand All @@ -229,18 +221,14 @@ def _set_attribute_value(self, data, name, converter, first_load):
)

if init_value != default_value and not issubclass(converter, List):
log.debug(
f"Keeping non-default '{name}' init value: {init_value!r}"
)
log.debug(f"Keeping non-default '{name}' init value: {init_value!r}")
return

if file_value is Missing:
if default_value is Missing:
value = converter.to_python_value(None, target=init_value)
else:
value = converter.to_python_value(
default_value, target=init_value
)
value = converter.to_python_value(default_value, target=init_value)
else:
value = converter.to_python_value(file_value, target=init_value)

Expand All @@ -253,9 +241,7 @@ def _get_default_field_value(self, name):
if not isinstance(field.default, Missing):
return field.default

if not isinstance(
field.default_factory, Missing # type: ignore
):
if not isinstance(field.default_factory, Missing): # type: ignore
return field.default_factory() # type: ignore

if not field.init and hasattr(self._instance, '__post_init__'):
Expand Down
4 changes: 1 addition & 3 deletions datafiles/tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ def when_existing_dict(expect):
def with_existing_dataclass(expect):
orginal = MyDataclass(foobar=1)

value = MyDataclassConverter.to_python_value(
{'foobar': 2}, target=orginal
)
value = MyDataclassConverter.to_python_value({'foobar': 2}, target=orginal)

expect(value) == MyDataclass(foobar=2)
expect(id(value)) == id(orginal)
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ jupyter = "^1.0"

[tool.black]

line-length = 79
py36 = true
skip-string-normalization = true


[build-system]

requires = ["poetry>=0.12"]
Expand Down

0 comments on commit cc788f3

Please sign in to comment.