diff --git a/Pipfile b/Pipfile index 37dd311..fc9e227 100644 --- a/Pipfile +++ b/Pipfile @@ -7,6 +7,10 @@ name = "pypi" [packages] +pycodestyle = "*" +"flake8" = "*" +isort = "*" +pylint = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..17c7507 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,130 @@ +{ + "_meta": { + "hash": { + "sha256": "834caa6d9bfa065f9bfe5a970fc5311438d6c7cd489fc33508059a58128d7a10" + }, + "host-environment-markers": { + "implementation_name": "cpython", + "implementation_version": "3.6.2", + "os_name": "posix", + "platform_machine": "x86_64", + "platform_python_implementation": "CPython", + "platform_release": "16.7.0", + "platform_system": "Darwin", + "platform_version": "Darwin Kernel Version 16.7.0: Wed Oct 4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64", + "python_full_version": "3.6.2", + "python_version": "3.6", + "sys_platform": "darwin" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.6" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "astroid": { + "hashes": [ + "sha256:badf6917ef7eb0ade0ea6eae347aed1e3f8f4c9375a02916f5cc450b3c8a64c0", + "sha256:71dadba2110008e2c03f9fde662ddd2053db3c0489d0e03c94e828a0399edd4f" + ], + "version": "==1.6.0" + }, + "flake8": { + "hashes": [ + "sha256:c7841163e2b576d435799169b78703ad6ac1bbb0f199994fc05f700b2a90ea37", + "sha256:7253265f7abd8b313e3892944044a365e3f4ac3fcdcfb4298f55ee9ddf188ba0" + ], + "version": "==3.5.0" + }, + "isort": { + "hashes": [ + "sha256:cd5d3fc2c16006b567a17193edf4ed9830d9454cbeb5a42ac80b36ea00c23db4", + "sha256:79f46172d3a4e2e53e7016e663cc7a8b538bec525c36675fcfd2767df30b3983" + ], + "version": "==4.2.15" + }, + "lazy-object-proxy": { + "hashes": [ + "sha256:209615b0fe4624d79e50220ce3310ca1a9445fd8e6d3572a896e7f9146bbf019", + "sha256:1b668120716eb7ee21d8a38815e5eb3bb8211117d9a90b0f8e21722c0758cc39", + "sha256:cb924aa3e4a3fb644d0c463cad5bc2572649a6a3f68a7f8e4fbe44aaa6d77e4c", + "sha256:2c1b21b44ac9beb0fc848d3993924147ba45c4ebc24be19825e57aabbe74a99e", + "sha256:320ffd3de9699d3892048baee45ebfbbf9388a7d65d832d7e580243ade426d2b", + "sha256:2df72ab12046a3496a92476020a1a0abf78b2a7db9ff4dc2036b8dd980203ae6", + "sha256:27ea6fd1c02dcc78172a82fc37fcc0992a94e4cecf53cb6d73f11749825bd98b", + "sha256:e5b9e8f6bda48460b7b143c3821b21b452cb3a835e6bbd5dd33aa0c8d3f5137d", + "sha256:7661d401d60d8bf15bb5da39e4dd72f5d764c5aff5a86ef52a042506e3e970ff", + "sha256:61a6cf00dcb1a7f0c773ed4acc509cb636af2d6337a08f362413c76b2b47a8dd", + "sha256:bd6292f565ca46dee4e737ebcc20742e3b5be2b01556dafe169f6c65d088875f", + "sha256:933947e8b4fbe617a51528b09851685138b49d511af0b6c0da2539115d6d4514", + "sha256:d0fc7a286feac9077ec52a927fc9fe8fe2fabab95426722be4c953c9a8bede92", + "sha256:7f3a2d740291f7f2c111d86a1c4851b70fb000a6c8883a59660d95ad57b9df35", + "sha256:5276db7ff62bb7b52f77f1f51ed58850e315154249aceb42e7f4c611f0f847ff", + "sha256:94223d7f060301b3a8c09c9b3bc3294b56b2188e7d8179c762a1cda72c979252", + "sha256:6ae6c4cb59f199d8827c5a07546b2ab7e85d262acaccaacd49b62f53f7c456f7", + "sha256:f460d1ceb0e4a5dcb2a652db0904224f367c9b3c1470d5a7683c0480e582468b", + "sha256:e81ebf6c5ee9684be8f2c87563880f93eedd56dd2b6146d8a725b50b7e5adb0f", + "sha256:81304b7d8e9c824d058087dcb89144842c8e0dea6d281c031f59f0acf66963d4", + "sha256:ddc34786490a6e4ec0a855d401034cbd1242ef186c20d79d2166d6a4bd449577", + "sha256:7bd527f36a605c914efca5d3d014170b2cb184723e423d26b1fb2fd9108e264d", + "sha256:ab3ca49afcb47058393b0122428358d2fbe0408cf99f1b58b295cfeb4ed39109", + "sha256:7cb54db3535c8686ea12e9535eb087d32421184eacc6939ef15ef50f83a5e7e2", + "sha256:0ce34342b419bd8f018e6666bfef729aec3edf62345a53b537a4dcc115746a33", + "sha256:e34b155e36fa9da7e1b7c738ed7767fc9491a62ec6af70fe9da4a057759edc2d", + "sha256:50e3b9a464d5d08cc5227413db0d1c4707b6172e4d4d915c1c70e4de0bbff1f5", + "sha256:27bf62cb2b1a2068d443ff7097ee33393f8483b570b475db8ebf7e1cba64f088", + "sha256:eb91be369f945f10d3a49f5f9be8b3d0b93a4c2be8f8a5b83b0571b8123e0a7a" + ], + "version": "==1.3.1" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "pycodestyle": { + "hashes": [ + "sha256:6c4245ade1edfad79c3446fadfc96b0de2759662dc29d07d80a6f27ad1ca6ba9", + "sha256:682256a5b318149ca0d2a9185d365d8864a768a28db66a84a2ea946bcc426766" + ], + "version": "==2.3.1" + }, + "pyflakes": { + "hashes": [ + "sha256:08bd6a50edf8cffa9fa09a463063c425ecaaf10d1eb0335a7e8b1401aef89e6f", + "sha256:8d616a382f243dbf19b54743f280b80198be0bca3a5396f1d2e1fca6223e8805" + ], + "version": "==1.6.0" + }, + "pylint": { + "hashes": [ + "sha256:c8e59da0f2f9990eb00aad1c1de16cd7809315842ebccc3f65ca9df46213df3b", + "sha256:3035e44e37cd09919e9edad5573af01d7c6b9c52a0ebb4781185ae7ab690458b" + ], + "version": "==1.8.1" + }, + "six": { + "hashes": [ + "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb", + "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9" + ], + "version": "==1.11.0" + }, + "wrapt": { + "hashes": [ + "sha256:d4d560d479f2c21e1b5443bbd15fe7ec4b37fe7e53d335d3b9b0a7b1226fe3c6" + ], + "version": "==1.10.11" + } + }, + "develop": {} +} diff --git a/linters.sh b/linters.sh new file mode 100755 index 0000000..96db1ca --- /dev/null +++ b/linters.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +echo "> running pycodestyle..." +pycodestyle --max-line-length=99 --exclude='.eggs,build,dist' . +if [ $? != 0 ] +then + exit 1 +else + echo "pycodestyle looks good!" +fi +echo + +echo "> running flake8..." +flake8 --exclude='.eggs,build,dist' --max-line-length=99 +if [ $? != 0 ] +then + exit 1 +else + echo "flake8 looks good!" +fi +echo + +echo "> running pylint..." +pylint marshmallow_arrow + +if [ $? != 0 ] && [ $? != 32 ]; then + echo "Exit code: $?" + exit 1 +else + echo "pylint looks good!" +fi +echo + +echo "> running isort..." +isort -c +if [ $? != 0 ]; then + exit 1 +else + echo "isort looks good!" +fi +echo diff --git a/marshmallow_arrow/__init__.py b/marshmallow_arrow/__init__.py index a380d8f..d6364b4 100644 --- a/marshmallow_arrow/__init__.py +++ b/marshmallow_arrow/__init__.py @@ -1,3 +1,5 @@ +"""Provides Arrow field for Marshmallow.""" + import arrow from marshmallow import fields @@ -21,7 +23,7 @@ def _serialize(self, value, attr, obj): return value.isoformat() - def _deserialize(self, value, attr, obj): + def _deserialize(self, value, attr, data): if not value: raise self.fail('invalid_object') diff --git a/pre-commit b/pre-commit new file mode 100644 index 0000000..b55a20f --- /dev/null +++ b/pre-commit @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "> let's make sure we're not on master..." +branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` +if [ "$branch" == "master" ] +then + echo "Cannot commit to master, please create a dev branch." + exit 1 +else + echo "$branch ok, continuing..." +fi +echo + +. ./linters.sh diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..de5134e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,8 @@ +[flake8] +max-line-length=100 + +[metadata] +description-file = README.md + +[pycodestyle] +max-line-length=100 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ac3cd2c --- /dev/null +++ b/setup.py @@ -0,0 +1,35 @@ +"""A Marshmallow Custom Field for Arrow objects.""" + +from setuptools import setup + +setup( + name='Marshmallow-Arrow', + version='1.0', + url='https://github.com/youversion/marshmallow_arrow', + download_url='https://github.com/youversion/marshmallow_arrow/archive/master.zip', + license='MIT', + author='Alex Ronoquillo', + author_email='developers@youversion.com', + description='A Marshmallow Custom Field for Arrow objects.', + long_description=__doc__, + packages=['marshmallow_arrow'], + zip_safe=False, + include_package_data=True, + platforms='any', + install_requires=[ + 'arrow', + 'marshmallow' + ], + classifiers=[ + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', + 'Topic :: Software Development :: Libraries :: Python Modules' + ], + keywords=['marshmallow', 'arrow'], + test_suite='tests', +) diff --git a/tests/test_arrow_field.py b/tests/test_arrow_field.py index 5ca56be..c4a1ec0 100644 --- a/tests/test_arrow_field.py +++ b/tests/test_arrow_field.py @@ -1,5 +1,6 @@ import arrow from marshmallow import Schema, fields + from marshmallow_arrow import ArrowField @@ -19,7 +20,6 @@ def test_deserialization(): birthday = arrow.utcnow().isoformat() schema = CalendarEventSchema() data, errors = schema.load({'name': 'Birthday Party', 'start_datetime': birthday}) - print(data) assert errors == {} assert isinstance(data['start_datetime'], arrow.Arrow) assert data['start_datetime'].isoformat() == birthday @@ -53,7 +53,6 @@ def test_serialization(): birthday_event = CalendarEvent('Birthday Party', birthday) schema = CalendarEventSchema() result = schema.dump(birthday_event) - print(result.data) assert result.data['start_datetime'] == birthday.isoformat()