diff --git a/.gitignore b/.gitignore index a02076f..d76a7ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.py[co] +.DS_Store # Packages *.egg diff --git a/examples/examples.ipynb b/examples/examples.ipynb index 8291ec3..c385b1b 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -138,7 +138,7 @@ "from picas.clients import CouchDB\n", "from picas.iterators import TaskViewIterator, EndlessViewIterator\n", "from picas.modifiers import BasicTokenModifier\n", - "from picas.executors import execute\n", + "from picas.executers import execute\n", "from picas.util import Timer\n", "\n", "class ExampleActor(RunActor):\n", diff --git a/picas/batchid.py b/picas/batchid.py index cf19c29..6f0b542 100644 --- a/picas/batchid.py +++ b/picas/batchid.py @@ -5,6 +5,7 @@ from os import environ + def add_batch_management_id(doc): """ Add job number id of the batch system to a token/document diff --git a/picas/clients.py b/picas/clients.py index 2c5f545..2b0dcb2 100644 --- a/picas/clients.py +++ b/picas/clients.py @@ -16,6 +16,7 @@ from .documents import Document from .picaslogger import picaslogger + class CouchDB: """Client class to handle communication with the CouchDB back-end.""" @@ -186,8 +187,9 @@ def delete_documents(self, docs): try: self.delete(doc) except ResourceConflict as ex: - picaslogger.info(f"Could not delete document {doc.id} (rev {doc.rev}) " - "due to resource conflict: {str(ex)}", file=sys.stderr) + picaslogger.info( + f"Could not delete document {doc.id} (rev {doc.rev}) due to resource conflict: {str(ex)}", + file=sys.stderr) result[i] = False except Exception as ex: picaslogger.info(f"Could not delete document {str(doc)}: {str(ex)}", file=sys.stderr) diff --git a/picas/documents.py b/picas/documents.py index eebf9b3..5961a90 100644 --- a/picas/documents.py +++ b/picas/documents.py @@ -191,7 +191,6 @@ class Task(Document): 'error': [], } - def __init__(self, task=None): if task is None: task = {} diff --git a/picas/executors.py b/picas/executers.py similarity index 100% rename from picas/executors.py rename to picas/executers.py diff --git a/setup.cfg b/setup.cfg index b88034e..c40b046 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,5 @@ [metadata] description-file = README.md + +[flake8] +max-line-length = 199 diff --git a/tests/test_document.py b/tests/test_document.py index 047bb8f..674b07e 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -18,7 +18,6 @@ class TestTask(unittest.TestCase): def setUp(self): self.task = Task({'_id': test_id}) - def test_create(self): doc = Document({'_id': test_id}) self.assertEqual(doc.id, test_id) @@ -27,17 +26,17 @@ def test_create(self): self.assertEqual(doc.id, test_other_id) self.assertEqual(doc.value, {'_id': test_other_id}) - def test_no_id(self): doc = Document({'someattr': 1}) - self.assertRaises(AttributeError, getattr(doc), 'id') - self.assertRaises(AttributeError, getattr(doc), 'rev') + with self.assertRaises(AttributeError): + getattr(doc, 'id') + with self.assertRaises(AttributeError): + getattr(doc, 'rev') def test_empty(self): Document({}) - def test_attachment(self): doc = Document() data = b"This is it" @@ -48,7 +47,7 @@ def test_attachment(self): self.assertEqual(attach['content_type'], 'text/plain') self.assertEqual(attach['data'], data) self.assertEqual(doc['_attachments'][textfile]['data'], - base64.b64encode(data).decode()) + base64.b64encode(data).decode()) doc.remove_attachment(textfile) self.assertTrue(textfile not in doc['_attachments']) self.assertEqual(attach['data'], data) @@ -56,13 +55,12 @@ def test_attachment(self): attach = doc.get_attachment(jsonfile) self.assertEqual(attach['content_type'], 'application/json') - def test_id(self): self.assertEqual(self.task.id, test_id) self.assertEqual(self.task.value['_id'], test_id) self.assertEqual(self.task['_id'], test_id) - def test_no_id(self): + def test_id_len(self): t = Task() self.assertTrue(len(t.id) > 10) diff --git a/tests/test_executors.py b/tests/test_executers.py similarity index 88% rename from tests/test_executors.py rename to tests/test_executers.py index 9a2c65c..127b0b1 100644 --- a/tests/test_executors.py +++ b/tests/test_executers.py @@ -1,6 +1,7 @@ import unittest -from picas.executors import execute +from picas.executers import execute + class TestExecutors(unittest.TestCase): diff --git a/tests/test_generators.py b/tests/test_generators.py index d72320b..a4c3c8d 100644 --- a/tests/test_generators.py +++ b/tests/test_generators.py @@ -2,6 +2,7 @@ from picas.generators import TokenGenerator + class TestGenerators(unittest.TestCase): def setUp(self): diff --git a/tests/test_iterators.py b/tests/test_iterators.py index e561392..5f0c189 100644 --- a/tests/test_iterators.py +++ b/tests/test_iterators.py @@ -17,7 +17,7 @@ def test_taskviewiterator(self): self.assertEqual(len(self.db.saved), 1) def stop_function(self, stop_value=2): - self.stop_value=stop_value + self.stop_value = stop_value return len(self.db.saved) == stop_value def test_endlessviewiterator(self): diff --git a/tests/test_modifiers.py b/tests/test_modifiers.py index 4be0e86..b5574c8 100644 --- a/tests/test_modifiers.py +++ b/tests/test_modifiers.py @@ -3,6 +3,7 @@ from picas.documents import Task from picas.modifiers import BasicTokenModifier + class TestModifier(unittest.TestCase): def setUp(self):