Skip to content

Commit

Permalink
Fixed FLK-D200
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Collins committed Feb 11, 2020
1 parent 9174715 commit c5ed188
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 45 deletions.
4 changes: 1 addition & 3 deletions examples/nested_thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def noisy_pdf(self, x_value, mu=0.0, sigma=25.0):

@property
def data(self):
"""
Return a 1D data trace.
"""
"""Return a 1D data trace."""
return DataSet(self.x_range, [self.noisy_pdf(x) for x in self.x_range])


Expand Down
8 changes: 2 additions & 6 deletions examples/simple_thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ def noisy_pdf(self, x, mu=0.0, sigma=25.0):

@property
def data(self):
"""
Return a 1D data trace.
"""
"""Return a 1D data trace."""
return [self.noisy_pdf(x) for x in self.x_range]

def average_data(self, n: int):
"""
Average n-sets of data. Emulates a measurement that may take a while.
"""
"""Average n-sets of data. Emulates a measurement that may take a while."""
summed_data = self.data

for i in range(n):
Expand Down
12 changes: 3 additions & 9 deletions labthings/core/tasks/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ def __init__(self, target=None, name=None, args=None, kwargs=None, daemon=True):

@property
def id(self):
"""
Return ID of current TaskThread
"""
"""Return ID of current TaskThread"""
return self._ID

@property
Expand Down Expand Up @@ -112,9 +110,7 @@ def wrapped(*args, **kwargs):
return wrapped

def run(self):
"""
Overrides default threading.Thread run() method
"""
"""Overrides default threading.Thread run() method"""
logging.debug((self._args, self._kwargs))
try:
with self._running_lock:
Expand All @@ -128,9 +124,7 @@ def run(self):
del self._target, self._args, self._kwargs

def wait(self):
"""
Start waiting for the task to finish before returning
"""
"""Start waiting for the task to finish before returning"""
print("Joining thread {}".format(self))
self.join()
return self._return_value
Expand Down
8 changes: 2 additions & 6 deletions labthings/server/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ def __call__(self, viewcls):


class use_body:
"""
Gets the request body as a single value and adds it as a positional argument
"""
"""Gets the request body as a single value and adds it as a positional argument"""

def __init__(self, schema, **kwargs):
self.schema = schema
Expand Down Expand Up @@ -198,9 +196,7 @@ def wrapper(*args, **kwargs):


class use_args:
"""
Equivalent to webargs.flask_parser.use_args
"""
"""Equivalent to webargs.flask_parser.use_args"""

def __init__(self, schema, **kwargs):
self.schema = schema
Expand Down
4 changes: 1 addition & 3 deletions labthings/server/labthing.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,7 @@ def add_root_link(self, view, title, kwargs=None):

# Description
def rootrep(self):
"""
Root representation
"""
"""Root representation"""
# TODO: Allow custom root representations

rr = {
Expand Down
4 changes: 1 addition & 3 deletions labthings/server/spec/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ def map_to_properties(schema, spec: APISpec):


def field_to_property(field, spec: APISpec):
"""
Convert a single Marshmallow field into a JSON schema of that field
"""
"""Convert a single Marshmallow field into a JSON schema of that field"""
marshmallow_plugin = next(
plugin for plugin in spec.plugins if isinstance(plugin, MarshmallowPlugin)
)
Expand Down
12 changes: 3 additions & 9 deletions labthings/server/views/docs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,19 @@ class APISpecView(View):
"""

def get(self):
"""
OpenAPI v3 documentation
"""
"""OpenAPI v3 documentation"""
return current_labthing().spec.to_dict()


class SwaggerUIView(View):
"""
Swagger UI documentation
"""
"""Swagger UI documentation"""

def get(self):
return make_response(render_template("swagger-ui.html"))


class W3CThingDescriptionView(View):
"""
W3C-style Thing Description
"""
"""W3C-style Thing Description"""

def get(self):
return current_labthing().thing_description.to_dict()
Expand Down
4 changes: 1 addition & 3 deletions labthings/server/views/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@


class ExtensionList(View):
"""
List and basic documentation for all enabled Extensions
"""
"""List and basic documentation for all enabled Extensions"""

@marshal_with(ExtensionSchema(many=True))
def get(self):
Expand Down
4 changes: 1 addition & 3 deletions labthings/server/views/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
class TaskList(View):
@marshal_with(TaskSchema(many=True))
def get(self):
"""
List of all session tasks
"""
"""List of all session tasks"""
return tasks.tasks()


Expand Down

0 comments on commit c5ed188

Please sign in to comment.