From 041518e760fec398065c79cce6223041e169a383 Mon Sep 17 00:00:00 2001 From: James Turk Date: Thu, 10 Nov 2022 21:31:18 -0600 Subject: [PATCH] cleanup flake8 --- saucebrush/filters.py | 6 +++--- saucebrush/sources.py | 1 - saucebrush/tests/emitters.py | 6 +++--- saucebrush/tests/filters.py | 7 +++---- saucebrush/tests/recipes.py | 1 - saucebrush/tests/sources.py | 5 +---- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/saucebrush/filters.py b/saucebrush/filters.py index 0607b20..3d3b79d 100644 --- a/saucebrush/filters.py +++ b/saucebrush/filters.py @@ -203,7 +203,7 @@ class ConditionalPathFilter(Filter): ##################### -## Generic Filters ## +# Generic Filters # ##################### @@ -518,7 +518,7 @@ class UniqueIDValidator(UniqueID): ########################### -## Commonly Used Filters ## +# Commonly Used Filters # ########################### @@ -535,7 +535,7 @@ class PhoneNumberCleaner(FieldFilter): def __init__(self, keys, number_format="%s%s%s.%s%s%s.%s%s%s%s"): super(PhoneNumberCleaner, self).__init__(keys) self._number_format = number_format - self._num_re = re.compile("\d") + self._num_re = re.compile(r"\d") def process_field(self, item): nums = self._num_re.findall(item) diff --git a/saucebrush/sources.py b/saucebrush/sources.py index bbbf40e..f784083 100644 --- a/saucebrush/sources.py +++ b/saucebrush/sources.py @@ -4,7 +4,6 @@ All sources must implement the iterable interface and return python dictionaries. """ -from __future__ import unicode_literals import string from saucebrush import utils diff --git a/saucebrush/tests/emitters.py b/saucebrush/tests/emitters.py index 5404df0..1a6a22b 100644 --- a/saucebrush/tests/emitters.py +++ b/saucebrush/tests/emitters.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals from contextlib import closing from io import StringIO import os @@ -72,7 +71,7 @@ class EmitterTestCase(unittest.TestCase): import cStringIO # if Python 2.x then use old cStringIO io = cStringIO.StringIO() - except: + except Exception: io = StringIO() # if Python 3.x then use StringIO with closing(io) as output: @@ -82,7 +81,8 @@ class EmitterTestCase(unittest.TestCase): def test_sqlite_emitter(self): - import sqlite3, tempfile + import sqlite3 + import tempfile with closing(tempfile.NamedTemporaryFile(suffix=".db")) as f: db_path = f.name diff --git a/saucebrush/tests/filters.py b/saucebrush/tests/filters.py index 17c97c1..cfbd277 100644 --- a/saucebrush/tests/filters.py +++ b/saucebrush/tests/filters.py @@ -1,5 +1,4 @@ import unittest -import operator import types from saucebrush.filters import ( Filter, @@ -133,7 +132,7 @@ class FilterTestCase(unittest.TestCase): # ensure only even numbers remain self.assertEqual(list(result), [0, 2, 4, 6, 8]) - ### Tests for Subrecord + # Tests for Subrecord def test_subrecord_filter_list(self): data = [ @@ -209,7 +208,7 @@ class FilterTestCase(unittest.TestCase): def test_conditional_path(self): - predicate = lambda r: r["a"] == 1 + predicate = lambda r: r["a"] == 1 # noqa # double b if a == 1, otherwise double c cpf = ConditionalPathFilter(predicate, FieldDoubler("b"), FieldDoubler("c")) @@ -221,7 +220,7 @@ class FilterTestCase(unittest.TestCase): self.assert_filter_result(cpf, expected_data) - ### Tests for Generic Filters + # Tests for Generic Filters def test_field_modifier(self): # another version of FieldDoubler diff --git a/saucebrush/tests/recipes.py b/saucebrush/tests/recipes.py index 100ec9f..dae3668 100644 --- a/saucebrush/tests/recipes.py +++ b/saucebrush/tests/recipes.py @@ -1,4 +1,3 @@ -import doctest import unittest from saucebrush import Recipe, run_recipe, SaucebrushError, OvercookedError from saucebrush.filters import Filter diff --git a/saucebrush/tests/sources.py b/saucebrush/tests/sources.py index 032bea4..189cb9d 100644 --- a/saucebrush/tests/sources.py +++ b/saucebrush/tests/sources.py @@ -1,5 +1,4 @@ -from __future__ import unicode_literals -from io import BytesIO, StringIO +from io import StringIO import unittest from saucebrush.sources import ( @@ -85,8 +84,6 @@ class SourceTestCase(unittest.TestCase): try: - import lxml - hts = HtmlTableSource(content, "thetable") self.assertEqual(list(hts), [{"a": "1", "b": "2", "c": "3"}])