Flake8 setup and dev install

master
Tom Wilson 6 years ago
parent 3ae568a38a
commit be2373d554

@ -5,7 +5,7 @@ Preserve is a simple framework to painlessly convert your python objects and
data structures into a nested structure containing only primitive types. data structures into a nested structure containing only primitive types.
While intended for use in serialisation, Preserve stops short of the actual While intended for use in serialisation, Preserve stops short of the actual
serialisation bit - you can then use whatever method you prefer to dump serialisation bit - you can then use whatever method you prefer to dump
the nested primitive structure to JSON, TOML, or some other message packing the nested primitive structure to JSON, TOML, or some other message packing
or storage system - most of which handle all primitive types by default. or storage system - most of which handle all primitive types by default.
@ -41,12 +41,12 @@ to class instances.
def preservable(cls, restore_method=RestoreMethod.DIRECT, name=None): def preservable(cls, restore_method=RestoreMethod.DIRECT, name=None):
""" """
Decorator to mark class as preservable and keep track of associated names Decorator to mark class as preservable and keep track of associated names
and classes. and classes.
Args: Args:
restore_method: One of the available preserve.RestoreMethod values. restore_method: One of the available preserve.RestoreMethod values.
Sets the method used for restoring this class. Defaults to Sets the method used for restoring this class. Defaults to
``DIRECT``, skipping the ``__init__`` method and setting all ``DIRECT``, skipping the ``__init__`` method and setting all
attributes as they were. attributes as they were.
name: The string used to indentify this class in the preserved dict. name: The string used to indentify this class in the preserved dict.
Must be unique among all ``@preservable`` classes. Defaults to the Must be unique among all ``@preservable`` classes. Defaults to the
@ -79,7 +79,7 @@ def preserve(target_obj):
Args: Args:
target_obj: The object to be preserved. This object and all its nested target_obj: The object to be preserved. This object and all its nested
contents must either be primitive types or objects of a contents must either be primitive types or objects of a
``@preservable`` class. ``@preservable`` class.
Returns: Returns:
@ -121,7 +121,7 @@ def restore(obj_jam):
``@preservable`` classes according to their ``restore_method``. ``@preservable`` classes according to their ``restore_method``.
Args: Args:
obj_jam: The data structure to restore, usually the result of a obj_jam: The data structure to restore, usually the result of a
``preserve()`` call. ``preserve()`` call.
""" """
if isinstance(obj_jam, (str, int, float, bool, type(None))): if isinstance(obj_jam, (str, int, float, bool, type(None))):

@ -0,0 +1,2 @@
[pytest]
flake8-max-line-length = 99

@ -9,6 +9,15 @@ setup(name='preserve',
license='MIT', license='MIT',
packages=[], packages=[],
py_modules=['preserve'], py_modules=['preserve'],
extras_require={
'dev': [
'pylint',
'autopep8',
'pytest',
'pytest-flake8',
'pytest-cov'
]
},
long_description=open('README.md').read(), long_description=open('README.md').read(),
long_description_content_type='text/markdown' long_description_content_type='text/markdown'
) )

@ -19,7 +19,8 @@ class PreservableClass(PlainClass):
@pytest.fixture @pytest.fixture
def primitive_data(): def primitive_data():
return {'key1': ["item1", {"d2k1": "val1", "d2k2": 2}, {"d3k1": "val1", "d3k2": True}, "test str"]} return {'key1': ["item1", {"d2k1": "val1", "d2k2": 2},
{"d3k1": "val1", "d3k2": True}, "test str"]}
def obj_attrs_and_type_equal(obj1, obj2): def obj_attrs_and_type_equal(obj1, obj2):

Loading…
Cancel
Save