summaryrefslogtreecommitdiff
path: root/src/mailman/utilities
diff options
context:
space:
mode:
authorBarry Warsaw2016-07-28 23:10:56 -0400
committerBarry Warsaw2016-07-28 23:10:56 -0400
commit90e84bee5f47cbcdb9e9c367c60a877e325ef3e7 (patch)
treebb7d2df3af049c6e84d65fd25cc0258b6af6ebb9 /src/mailman/utilities
parent86b25ba2e3bac0e034235d322c7c77080d737833 (diff)
downloadmailman-90e84bee5f47cbcdb9e9c367c60a877e325ef3e7.tar.gz
mailman-90e84bee5f47cbcdb9e9c367c60a877e325ef3e7.tar.zst
mailman-90e84bee5f47cbcdb9e9c367c60a877e325ef3e7.zip
Rebase mailman/mailman!180 and cleanup # noqa
Diffstat (limited to 'src/mailman/utilities')
-rw-r--r--src/mailman/utilities/datetime.py19
-rw-r--r--src/mailman/utilities/interact.py2
-rw-r--r--src/mailman/utilities/tests/test_interact.py2
-rw-r--r--src/mailman/utilities/tests/test_templates.py10
-rw-r--r--src/mailman/utilities/tests/test_uid.py2
5 files changed, 19 insertions, 16 deletions
diff --git a/src/mailman/utilities/datetime.py b/src/mailman/utilities/datetime.py
index d2481ecbc..9bb772b3f 100644
--- a/src/mailman/utilities/datetime.py
+++ b/src/mailman/utilities/datetime.py
@@ -52,7 +52,8 @@ class UTC(datetime.tzinfo):
return ZERO
-public(utc=UTC())
+utc = UTC()
+public(utc=utc)
_missing = object()
@@ -67,7 +68,7 @@ class DateFactory:
# We can't automatically fast-forward because some tests require us to
# stay on the same day for a while, e.g. autorespond.txt.
if tz is _missing:
- tz = utc # noqa
+ tz = utc
# Storm cannot yet handle datetimes with tz suffixes. Assume we're
# using UTC datetimes everywhere, so set the tzinfo to None. This
# does *not* change the actual time values. LP: #280708
@@ -86,7 +87,7 @@ class DateFactory:
@classmethod
def reset(cls):
cls.predictable_now = datetime.datetime(2005, 8, 1, 7, 49, 23,
- tzinfo=utc) # noqa
+ tzinfo=utc)
cls.predictable_today = cls.predictable_now.date()
@classmethod
@@ -95,8 +96,10 @@ class DateFactory:
cls.predictable_today = cls.predictable_now.date()
-public(factory=DateFactory())
-factory.reset() # noqa
-public(today=factory.today) # noqa
-public(now=factory.now) # noqa
-layers.MockAndMonkeyLayer.register_reset(factory.reset) # noqa
+factory = DateFactory()
+public(factory=factory)
+factory.reset()
+
+public(today=factory.today)
+public(now=factory.now)
+layers.MockAndMonkeyLayer.register_reset(factory.reset)
diff --git a/src/mailman/utilities/interact.py b/src/mailman/utilities/interact.py
index 904d1b579..fec980b80 100644
--- a/src/mailman/utilities/interact.py
+++ b/src/mailman/utilities/interact.py
@@ -53,7 +53,7 @@ def interact(upframe=True, banner=DEFAULT_BANNER, overrides=None):
interp = code.InteractiveConsole(namespace)
# Try to import the readline module, but don't worry if it's unavailable.
with suppress(ImportError):
- import readline # noqa
+ import readline # noqa: F401
# Mimic the real interactive interpreter's loading of any $PYTHONSTARTUP
# file. Note that if the startup file is not prepared to be exec'd more
# than once, this could cause a problem.
diff --git a/src/mailman/utilities/tests/test_interact.py b/src/mailman/utilities/tests/test_interact.py
index d3803ab28..d6a2fcf0d 100644
--- a/src/mailman/utilities/tests/test_interact.py
+++ b/src/mailman/utilities/tests/test_interact.py
@@ -77,7 +77,7 @@ class TestInteract(unittest.TestCase):
self.assertEqual(stderr[0], 'Welcome')
def test_interact_no_upframe(self):
- upframed = False # noqa
+ upframed = False # noqa: F841
fp = self._enter(NamedTemporaryFile('w', encoding='utf-8'))
self._enter(hackenv('PYTHONSTARTUP', fp.name))
print('print(upframed)', file=fp)
diff --git a/src/mailman/utilities/tests/test_templates.py b/src/mailman/utilities/tests/test_templates.py
index 4e05f13c6..a2b364c1a 100644
--- a/src/mailman/utilities/tests/test_templates.py
+++ b/src/mailman/utilities/tests/test_templates.py
@@ -77,7 +77,7 @@ class TestSearchOrder(unittest.TestCase):
def test_fully_specified_search_order(self):
search_order = self._stripped_search_order('foo.txt', self.mlist, 'it')
# For convenience.
- def nexteq(path): # noqa
+ def nexteq(path): # noqa: E301
self.assertEqual(next(search_order), path)
# 1: Use the given language argument
nexteq('/v/templates/lists/l.example.com/it/foo.txt')
@@ -107,7 +107,7 @@ class TestSearchOrder(unittest.TestCase):
def test_no_language_argument_search_order(self):
search_order = self._stripped_search_order('foo.txt', self.mlist)
# For convenience.
- def nexteq(path): # noqa
+ def nexteq(path): # noqa: E301
self.assertEqual(next(search_order), path)
# 1: Use mlist.preferred_language
nexteq('/v/templates/lists/l.example.com/de/foo.txt')
@@ -132,7 +132,7 @@ class TestSearchOrder(unittest.TestCase):
def test_no_mailing_list_argument_search_order(self):
search_order = self._stripped_search_order('foo.txt', language='it')
# For convenience.
- def nexteq(path): # noqa
+ def nexteq(path): # noqa: E301
self.assertEqual(next(search_order), path)
# 1: Use the given language argument
nexteq('/v/templates/site/it/foo.txt')
@@ -148,7 +148,7 @@ class TestSearchOrder(unittest.TestCase):
def test_no_optional_arguments_search_order(self):
search_order = self._stripped_search_order('foo.txt')
# For convenience.
- def nexteq(path): # noqa
+ def nexteq(path): # noqa: E301
self.assertEqual(next(search_order), path)
# 1: Use the site's default language
nexteq('/v/templates/site/fr/foo.txt')
@@ -180,7 +180,7 @@ class TestFind(unittest.TestCase):
self.mlist.preferred_language = 'xx'
self.fp = None
# Populate the template directories with a few fake templates.
- def write(text, path): # noqa
+ def write(text, path): # noqa: E301
os.makedirs(os.path.dirname(path))
with open(path, 'w') as fp:
fp.write(text)
diff --git a/src/mailman/utilities/tests/test_uid.py b/src/mailman/utilities/tests/test_uid.py
index c081ac2c5..fd00ddfff 100644
--- a/src/mailman/utilities/tests/test_uid.py
+++ b/src/mailman/utilities/tests/test_uid.py
@@ -54,7 +54,7 @@ class TestUID(unittest.TestCase):
def test_uid_record_try_again(self):
called = False
- def record_second(ignore): # noqa
+ def record_second(ignore): # noqa: E301
nonlocal called
if not called:
called = True