Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes to avoid flake8 errors #18

Merged
merged 6 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.py[co]
.DS_Store

# Packages
*.egg
Expand Down
2 changes: 1 addition & 1 deletion examples/examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions picas/batchid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions picas/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .documents import Document
from .picaslogger import picaslogger


class CouchDB:

"""Client class to handle communication with the CouchDB back-end."""
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion picas/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ class Task(Document):
'error': [],
}


def __init__(self, task=None):
if task is None:
task = {}
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[metadata]
description-file = README.md

[flake8]
max-line-length = 199
15 changes: 5 additions & 10 deletions tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -27,17 +26,14 @@ 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')

# def test_no_id(self):
lnauta marked this conversation as resolved.
Show resolved Hide resolved
# doc = Document({'someattr': 1})
# self.assertRaises(AttributeError, getattr(doc), 'id')
# self.assertRaises(AttributeError, getattr(doc), 'rev')

def test_empty(self):
Document({})


def test_attachment(self):
doc = Document()
data = b"This is it"
Expand All @@ -48,15 +44,14 @@ 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)
doc.put_attachment(jsonfile, b'{}')
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)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_executors.py → tests/test_executers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest

from picas.executors import execute
from picas.executers import execute


class TestExecutors(unittest.TestCase):

Expand Down
1 change: 1 addition & 0 deletions tests/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from picas.generators import TokenGenerator


class TestGenerators(unittest.TestCase):

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions tests/test_modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from picas.documents import Task
from picas.modifiers import BasicTokenModifier


class TestModifier(unittest.TestCase):

def setUp(self):
Expand Down