From be2373d554290a560916b938d19fa544a7e9c24e Mon Sep 17 00:00:00 2001 From: novirium Date: Mon, 23 Dec 2019 16:19:46 +0800 Subject: [PATCH] Flake8 setup and dev install --- preserve.py | 12 ++++++------ pytest.ini | 2 ++ setup.py | 9 +++++++++ tests/test_preserve.py | 3 ++- 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 pytest.ini diff --git a/preserve.py b/preserve.py index d1e0072..5614a1f 100644 --- a/preserve.py +++ b/preserve.py @@ -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. 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 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): """ Decorator to mark class as preservable and keep track of associated names - and classes. + and classes. 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 - ``DIRECT``, skipping the ``__init__`` method and setting all + ``DIRECT``, skipping the ``__init__`` method and setting all attributes as they were. name: The string used to indentify this class in the preserved dict. Must be unique among all ``@preservable`` classes. Defaults to the @@ -79,7 +79,7 @@ def preserve(target_obj): Args: 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. Returns: @@ -121,7 +121,7 @@ def restore(obj_jam): ``@preservable`` classes according to their ``restore_method``. 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. """ if isinstance(obj_jam, (str, int, float, bool, type(None))): diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..d9ba717 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +flake8-max-line-length = 99 \ No newline at end of file diff --git a/setup.py b/setup.py index 2dc7205..1740a3a 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,15 @@ setup(name='preserve', license='MIT', packages=[], py_modules=['preserve'], + extras_require={ + 'dev': [ + 'pylint', + 'autopep8', + 'pytest', + 'pytest-flake8', + 'pytest-cov' + ] + }, long_description=open('README.md').read(), long_description_content_type='text/markdown' ) diff --git a/tests/test_preserve.py b/tests/test_preserve.py index ac99938..da39d8f 100644 --- a/tests/test_preserve.py +++ b/tests/test_preserve.py @@ -19,7 +19,8 @@ class PreservableClass(PlainClass): @pytest.fixture 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):