From 923b505128c3bdd0c6937687b273fb93d63129fd Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Mar 2018 22:05:10 -0500 Subject: [PATCH] Feed the hobgoblins (delint). --- conftest.py | 8 ++++---- wolframalpha/__init__.py | 11 ++++++++--- wolframalpha/compat.py | 1 + wolframalpha/test_client.py | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/conftest.py b/conftest.py index 7273ccd..45039eb 100644 --- a/conftest.py +++ b/conftest.py @@ -8,10 +8,10 @@ import wolframalpha if six.PY2: - collect_ignore = [ - 'wolframalpha/pmxbot.py', - 'wolframalpha/test_pmxbot.py', - ] + collect_ignore = [ + 'wolframalpha/pmxbot.py', + 'wolframalpha/test_pmxbot.py', + ] @pytest.fixture(scope='session') diff --git a/wolframalpha/__init__.py b/wolframalpha/__init__.py index 62906ea..8eb536c 100644 --- a/wolframalpha/__init__.py +++ b/wolframalpha/__init__.py @@ -62,7 +62,7 @@ class ErrorHandler(object): self._handle_error() def _handle_error(self): - if not 'error' in self: + if 'error' not in self: return template = 'Error {error[code]}: {error[msg]}' @@ -97,7 +97,7 @@ class Assumption(Document): text = self.template.replace('${desc1}', self.description) try: text = text.replace('${word}', self.word) - except: + except Exception: pass return text[:text.index('. ') + 1] @@ -207,7 +207,12 @@ class Result(ErrorHandler, Document): """ The pods that hold the response to a simple, discrete query. """ - return (pod for pod in self.pods if pod.primary or pod.title=='Result') + return ( + pod + for pod in self.pods + if pod.primary + or pod.title == 'Result' + ) @property def details(self): diff --git a/wolframalpha/compat.py b/wolframalpha/compat.py index be52d21..ec61771 100644 --- a/wolframalpha/compat.py +++ b/wolframalpha/compat.py @@ -1,6 +1,7 @@ import six from six.moves import http_client + def fix_HTTPMessage(): """ Python 2 uses a deprecated method signature and doesn't provide the diff --git a/wolframalpha/test_client.py b/wolframalpha/test_client.py index 963fe63..fcbbd54 100644 --- a/wolframalpha/test_client.py +++ b/wolframalpha/test_client.py @@ -1,4 +1,4 @@ -#-*- coding: utf-8 -*- +# -*- coding: utf-8 -*- from __future__ import unicode_literals @@ -13,6 +13,7 @@ import wolframalpha def temp_result(client): return client.query('30 deg C in deg F') + def test_basic(temp_result): res = temp_result assert len(list(res.pods)) > 0