diff options
| author | Barry Warsaw | 2016-07-28 23:10:56 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2016-07-28 23:10:56 -0400 |
| commit | 90e84bee5f47cbcdb9e9c367c60a877e325ef3e7 (patch) | |
| tree | bb7d2df3af049c6e84d65fd25cc0258b6af6ebb9 | |
| parent | 86b25ba2e3bac0e034235d322c7c77080d737833 (diff) | |
| download | mailman-90e84bee5f47cbcdb9e9c367c60a877e325ef3e7.tar.gz mailman-90e84bee5f47cbcdb9e9c367c60a877e325ef3e7.tar.zst mailman-90e84bee5f47cbcdb9e9c367c60a877e325ef3e7.zip | |
44 files changed, 97 insertions, 92 deletions
diff --git a/src/mailman/app/moderator.py b/src/mailman/app/moderator.py index 8ce631941..c3347c1ff 100644 --- a/src/mailman/app/moderator.py +++ b/src/mailman/app/moderator.py @@ -243,7 +243,7 @@ def send_rejection(mlist, request, recip, comment, origmsg=None, lang=None): # As this message is going to the requester, try to set the language to # his/her language choice, if they are a member. Otherwise use the list's # preferred language. - display_name = mlist.display_name # noqa + display_name = mlist.display_name # noqa: F841 if lang is None: member = mlist.members.get_member(recip) lang = (mlist.preferred_language diff --git a/src/mailman/app/notifications.py b/src/mailman/app/notifications.py index 11a21a379..31a15d820 100644 --- a/src/mailman/app/notifications.py +++ b/src/mailman/app/notifications.py @@ -61,7 +61,7 @@ def send_welcome_message(mlist, member, language, text=''): list_name=mlist.display_name, list_requests=mlist.request_address, )) - digmode = ('' # noqa + digmode = ('' # noqa: F841 if member.delivery_mode is DeliveryMode.regular else _(' (Digest mode)')) msg = UserNotification( diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py index 3042623d1..a397c4fde 100644 --- a/src/mailman/app/subscriptions.py +++ b/src/mailman/app/subscriptions.py @@ -224,7 +224,7 @@ class SubscriptionWorkflow(Workflow): next_step = ( 'moderation_checks' if self.mlist.subscription_policy is - SubscriptionPolicy.confirm_then_moderate # noqa + SubscriptionPolicy.confirm_then_moderate # noqa: E131 else 'do_subscription') self.push(next_step) return diff --git a/src/mailman/bin/master.py b/src/mailman/bin/master.py index bc74ea6a5..543af4ff4 100644 --- a/src/mailman/bin/master.py +++ b/src/mailman/bin/master.py @@ -193,7 +193,7 @@ The master lock could not be acquired because it appears as though another master is already running.""") elif status is WatcherState.stale_lock: # Hostname matches but the process does not exist. - program = sys.argv[0] # noqa + program = sys.argv[0] # noqa: F841 message = _("""\ The master lock could not be acquired. It appears as though there is a stale master lock. Try re-running $program with the --force flag.""") @@ -299,33 +299,33 @@ class Loop: # Set up our signal handlers. Also set up a SIGALRM handler to # refresh the lock once per day. The lock lifetime is 1 day + 6 hours # so this should be plenty. - def sigalrm_handler(signum, frame): # noqa + def sigalrm_handler(signum, frame): # noqa: E301 self._lock.refresh() signal.alarm(SECONDS_IN_A_DAY) signal.signal(signal.SIGALRM, sigalrm_handler) signal.alarm(SECONDS_IN_A_DAY) # SIGHUP tells the runners to close and reopen their log files. - def sighup_handler(signum, frame): # noqa + def sighup_handler(signum, frame): # noqa: E301 reopen() for pid in self._kids: os.kill(pid, signal.SIGHUP) log.info('Master watcher caught SIGHUP. Re-opening log files.') signal.signal(signal.SIGHUP, sighup_handler) # SIGUSR1 is used by 'mailman restart'. - def sigusr1_handler(signum, frame): # noqa + def sigusr1_handler(signum, frame): # noqa: E301 for pid in self._kids: os.kill(pid, signal.SIGUSR1) log.info('Master watcher caught SIGUSR1. Exiting.') signal.signal(signal.SIGUSR1, sigusr1_handler) # SIGTERM is what init will kill this process with when changing run # levels. It's also the signal 'mailman stop' uses. - def sigterm_handler(signum, frame): # noqa + def sigterm_handler(signum, frame): # noqa: E301 for pid in self._kids: os.kill(pid, signal.SIGTERM) log.info('Master watcher caught SIGTERM. Exiting.') signal.signal(signal.SIGTERM, sigterm_handler) # SIGINT is what control-C gives. - def sigint_handler(signum, frame): # noqa + def sigint_handler(signum, frame): # noqa: E301 for pid in self._kids: os.kill(pid, signal.SIGINT) log.info('Master watcher caught SIGINT. Restarting.') diff --git a/src/mailman/bin/runner.py b/src/mailman/bin/runner.py index be41dcd96..591f5ee31 100644 --- a/src/mailman/bin/runner.py +++ b/src/mailman/bin/runner.py @@ -187,7 +187,7 @@ def main(): for shortname in sorted(descriptions): classname = descriptions[shortname] spaces = longest - len(shortname) - name = (' ' * spaces) + shortname # noqa + name = (' ' * spaces) + shortname # noqa: F841 print(_('$name runs $classname')) sys.exit(0) diff --git a/src/mailman/chains/reject.py b/src/mailman/chains/reject.py index 6711538b7..27fce8d4e 100644 --- a/src/mailman/chains/reject.py +++ b/src/mailman/chains/reject.py @@ -64,9 +64,9 @@ reasons: The original message as received by Mailman is attached. """).format( - list_name=mlist.display_name, # noqa - reasons=NEWLINE.join(reasons) # noqa - )) # noqa + list_name=mlist.display_name, # noqa: E122 + reasons=NEWLINE.join(reasons) + )) bounce_message(mlist, msg, error) log.info('REJECT: %s', msg.get('message-id', 'n/a')) notify(RejectEvent(mlist, msg, msgdata, self)) diff --git a/src/mailman/chains/tests/test_accept.py b/src/mailman/chains/tests/test_accept.py index 9b7a25fab..07ed958b0 100644 --- a/src/mailman/chains/tests/test_accept.py +++ b/src/mailman/chains/tests/test_accept.py @@ -60,7 +60,7 @@ Subject: Ignore config.chains['mine'] = MyChain() self.addCleanup(config.chains.pop, 'mine') hits = None - def handler(event): # noqa + def handler(event): # noqa: E301 nonlocal hits if isinstance(event, AcceptEvent): hits = event.msg['x-mailman-rule-hits'] diff --git a/src/mailman/chains/tests/test_headers.py b/src/mailman/chains/tests/test_headers.py index 6cd37c988..e21fa452d 100644 --- a/src/mailman/chains/tests/test_headers.py +++ b/src/mailman/chains/tests/test_headers.py @@ -167,7 +167,7 @@ class TestHeaderChain(unittest.TestCase): [('foo', 'a+', LinkAction.jump, 'reject'), ('bar', 'b+', LinkAction.jump, 'discard'), ('baz', 'z+', LinkAction.jump, 'accept'), - ]) # noqa + ]) # noqa: E124 @configuration('antispam', header_checks=""" Foo: foo @@ -217,7 +217,7 @@ A message body. # This event subscriber records the event that occurs when the message # is processed by the owner chain, which holds its for approval. events = [] - def record_holds(event): # noqa + def record_holds(event): # noqa: E301 if not isinstance(event, HoldEvent): return events.append(event) @@ -225,7 +225,7 @@ A message body. # Set the site-wide antispam action to hold the message. with configuration('antispam', header_checks=""" Spam: [*]{3,} - """, jump_chain='hold'): # noqa + """, jump_chain='hold'): # noqa: E125 process(self._mlist, msg, {}, start_chain='header-match') self.assertEqual(len(events), 1) event = events[0] @@ -234,7 +234,7 @@ A message body. self.assertEqual(event.mlist, self._mlist) self.assertEqual(event.msg, msg) events = [] - def record_discards(event): # noqa + def record_discards(event): # noqa: E301 if not isinstance(event, DiscardEvent): return events.append(event) @@ -243,7 +243,7 @@ A message body. msg.replace_header('Message-Id', '<bee>') with configuration('antispam', header_checks=""" Spam: [*]{3,} - """, jump_chain='discard'): # noqa + """, jump_chain='discard'): # noqa: E125 process(self._mlist, msg, {}, start_chain='header-match') self.assertEqual(len(events), 1) event = events[0] @@ -262,7 +262,7 @@ A message body. header_matches = IHeaderMatchList(self._mlist) header_matches.append('Header2', 'b+') header_matches.append('Header3', 'c+') - def get_links(): # noqa + def get_links(): # noqa: E301 return [ link for link in chain.get_links(self._mlist, Message(), {}) if link.rule.name != 'any' diff --git a/src/mailman/chains/tests/test_owner.py b/src/mailman/chains/tests/test_owner.py index 004c0200a..70328303b 100644 --- a/src/mailman/chains/tests/test_owner.py +++ b/src/mailman/chains/tests/test_owner.py @@ -50,7 +50,7 @@ Message-ID: <ant> # This event subscriber records the event that occurs when the message # is processed by the owner chain. events = [] - def catch_event(event): # noqa + def catch_event(event): # noqa: E301 if isinstance(event, AcceptOwnerEvent): events.append(event) with event_subscribers(catch_event): diff --git a/src/mailman/commands/cli_control.py b/src/mailman/commands/cli_control.py index a99a62dbc..af22c3b06 100644 --- a/src/mailman/commands/cli_control.py +++ b/src/mailman/commands/cli_control.py @@ -93,7 +93,7 @@ class Start: self.parser.error( _('A previous run of GNU Mailman did not exit ' 'cleanly. Try using --force.')) - def log(message): # noqa + def log(message): # noqa: E301 if not args.quiet: print(message) # Try to find the path to a valid, existing configuration file, and diff --git a/src/mailman/commands/cli_lists.py b/src/mailman/commands/cli_lists.py index 9813da29c..f5e6d724a 100644 --- a/src/mailman/commands/cli_lists.py +++ b/src/mailman/commands/cli_lists.py @@ -90,7 +90,7 @@ class Lists: if not args.quiet: print(_('No matching mailing lists found')) return - count = len(mailing_lists) # noqa + count = len(mailing_lists) # noqa: F841 if not args.quiet: print(_('$count matching mailing lists found:')) # Calculate the longest identifier. @@ -199,7 +199,7 @@ class Create: invalid_owners = [owner for owner in args.owners if not validator.is_valid(owner)] if invalid_owners: - invalid = COMMASPACE.join(sorted(invalid_owners)) # noqa + invalid = COMMASPACE.join(sorted(invalid_owners)) # noqa: F841 self.parser.error(_('Illegal owner addresses: $invalid')) return try: diff --git a/src/mailman/commands/cli_qfile.py b/src/mailman/commands/cli_qfile.py index 0ed078ff3..f6502f14a 100644 --- a/src/mailman/commands/cli_qfile.py +++ b/src/mailman/commands/cli_qfile.py @@ -80,7 +80,7 @@ class QFile: else: printer.pprint(obj) print(_('[----- end pickle -----]')) - count = len(m) # noqa + count = len(m) # noqa: F841 banner = _("The variable 'm' contains $count objects") if args.interactive: interact(banner=banner) diff --git a/src/mailman/commands/cli_status.py b/src/mailman/commands/cli_status.py index dae9cfe0a..6b4abe45e 100644 --- a/src/mailman/commands/cli_status.py +++ b/src/mailman/commands/cli_status.py @@ -50,7 +50,7 @@ class Status: message = _('GNU Mailman is stopped (stale pid: $pid)') else: hostname, pid, tempfile = lock.details - fqdn_name = socket.getfqdn() # noqa + fqdn_name = socket.getfqdn() # noqa: F841 assert status is WatcherState.host_mismatch, ( 'Invalid enum value: %s' % status) message = _('GNU Mailman is in an unexpected state ' diff --git a/src/mailman/commands/cli_withlist.py b/src/mailman/commands/cli_withlist.py index d3df6dad7..306fb846a 100644 --- a/src/mailman/commands/cli_withlist.py +++ b/src/mailman/commands/cli_withlist.py @@ -207,7 +207,7 @@ class Withlist: # Set the tab completion. with ExitStack() as resources: try: # pragma: no cover - import readline, rlcompleter # noqa + import readline, rlcompleter # noqa: F401, E401 except ImportError: # pragma: no cover print(_('readline not available'), file=sys.stderr) pass diff --git a/src/mailman/commands/eml_help.py b/src/mailman/commands/eml_help.py index 8166effea..4ca2d72a4 100644 --- a/src/mailman/commands/eml_help.py +++ b/src/mailman/commands/eml_help.py @@ -66,7 +66,7 @@ class Help: print(wrap(command.description), file=results) return ContinueProcessing.yes else: - printable_arguments = SPACE.join(arguments) # noqa + printable_arguments = SPACE.join(arguments) # noqa: F841 print(_('$self.name: too many arguments: $printable_arguments'), file=results) return ContinueProcessing.no diff --git a/src/mailman/commands/eml_membership.py b/src/mailman/commands/eml_membership.py index 8168e98fa..7d3704e14 100644 --- a/src/mailman/commands/eml_membership.py +++ b/src/mailman/commands/eml_membership.py @@ -92,7 +92,7 @@ used. return ContinueProcessing.yes joins.add(email) results.joins = joins - person = formataddr((display_name, email)) # noqa + person = formataddr((display_name, email)) # noqa: F841 # Is this person already a member of the list? Search for all # matching memberships. members = getUtility(ISubscriptionService).find_members( @@ -187,7 +187,7 @@ You may be asked to confirm your request.""") file=results) return ContinueProcessing.no member.unsubscribe() - person = formataddr((user.display_name, email)) # noqa + person = formataddr((user.display_name, email)) # noqa: F841 print(_('$person left $mlist.fqdn_listname'), file=results) return ContinueProcessing.yes diff --git a/src/mailman/commands/tests/test_shell.py b/src/mailman/commands/tests/test_shell.py index 12e78c1ab..3540056f8 100644 --- a/src/mailman/commands/tests/test_shell.py +++ b/src/mailman/commands/tests/test_shell.py @@ -28,7 +28,7 @@ from mailman.testing.layers import ConfigLayer from unittest.mock import patch try: - import readline # noqa + import readline # noqa: F401 has_readline = True except ImportError: has_readline = False diff --git a/src/mailman/config/tests/test_configuration.py b/src/mailman/config/tests/test_configuration.py index f4bccad83..24f2804fa 100644 --- a/src/mailman/config/tests/test_configuration.py +++ b/src/mailman/config/tests/test_configuration.py @@ -39,7 +39,7 @@ class TestConfiguration(unittest.TestCase): # Pushing a new configuration onto the stack triggers a # post-processing event. events = [] - def on_event(event): # noqa + def on_event(event): # noqa: E301 if isinstance(event, ConfigurationUpdatedEvent): # Record both the event and the top overlay. events.append(event.config.overlays[0].name) diff --git a/src/mailman/core/initialize.py b/src/mailman/core/initialize.py index 7446418d2..7b39465c5 100644 --- a/src/mailman/core/initialize.py +++ b/src/mailman/core/initialize.py @@ -40,7 +40,8 @@ from zope.configuration import xmlconfig # The test infrastructure uses this to prevent the search and loading of any # existing configuration file. Otherwise the existence of say a # ~/.mailman.cfg file can break tests. -public(INHIBIT_CONFIG_FILE=object()) +INHIBIT_CONFIG_FILE = object() +public(INHIBIT_CONFIG_FILE=INHIBIT_CONFIG_FILE) def search_for_configuration_file(): @@ -112,7 +113,7 @@ def initialize_1(config_path=None): # configuration file is searched for in the file system. if config_path is None: config_path = search_for_configuration_file() - elif config_path is INHIBIT_CONFIG_FILE: # noqa + elif config_path is INHIBIT_CONFIG_FILE: # For the test suite, force this back to not using a config file. config_path = None mailman.config.config.load(config_path) diff --git a/src/mailman/database/alembic/versions/7b254d88f122_members_and_list_moderation_action.py b/src/mailman/database/alembic/versions/7b254d88f122_members_and_list_moderation_action.py index c393528d9..6b4d7bfd1 100644 --- a/src/mailman/database/alembic/versions/7b254d88f122_members_and_list_moderation_action.py +++ b/src/mailman/database/alembic/versions/7b254d88f122_members_and_list_moderation_action.py @@ -85,7 +85,7 @@ def upgrade(): def downgrade(): connection = op.get_bind() for member in connection.execute(members_query.where( - member_table.c.moderation_action == None)).fetchall(): # noqa + member_table.c.moderation_action == None)).fetchall(): # noqa: E711 default_action = _get_default_action(connection, member) # Use the mailing list's default action connection.execute(member_table.update().where( diff --git a/src/mailman/database/model.py b/src/mailman/database/model.py index 6019b7488..c2ee90491 100644 --- a/src/mailman/database/model.py +++ b/src/mailman/database/model.py @@ -37,7 +37,7 @@ class ModelMeta: try: # Delete all the tables in reverse foreign key dependency # order. http://tinyurl.com/on8dy6f - for table in reversed(Model.metadata.sorted_tables): # noqa + for table in reversed(Model.metadata.sorted_tables): connection.execute(table.delete()) except: transaction.rollback() @@ -46,4 +46,5 @@ class ModelMeta: transaction.commit() -public(Model=declarative_base(cls=ModelMeta)) +Model = declarative_base(cls=ModelMeta) +public(Model=Model) diff --git a/src/mailman/database/postgresql.py b/src/mailman/database/postgresql.py index 5d42c59f8..b1095e45f 100644 --- a/src/mailman/database/postgresql.py +++ b/src/mailman/database/postgresql.py @@ -41,8 +41,8 @@ class PostgreSQLDatabase(SABaseDatabase): for table in tables: for column in table.primary_key: if (column.autoincrement - and isinstance(column.type, Integer) # noqa - and not column.foreign_keys): # noqa + and isinstance(column.type, Integer) # noqa: W503 + and not column.foreign_keys): # noqa: W503 store.execute("""\ SELECT setval('"{0}_{1}_seq"', coalesce(max("{1}"), 1), max("{1}") IS NOT null) diff --git a/src/mailman/database/sqlite.py b/src/mailman/database/sqlite.py index 409545d74..08700bfb2 100644 --- a/src/mailman/database/sqlite.py +++ b/src/mailman/database/sqlite.py @@ -37,7 +37,7 @@ class SQLiteDatabase(SABaseDatabase): path = os.path.normpath(parts.path) fd = os.open( path, - os.O_WRONLY | os.O_NONBLOCK | os.O_CREAT, # noqa + os.O_WRONLY | os.O_NONBLOCK | os.O_CREAT, 0o666) # Ignore errors if fd > 0: diff --git a/src/mailman/database/tests/test_migrations.py b/src/mailman/database/tests/test_migrations.py index d61154ee2..88a2a30ab 100644 --- a/src/mailman/database/tests/test_migrations.py +++ b/src/mailman/database/tests/test_migrations.py @@ -130,7 +130,7 @@ class TestMigrations(unittest.TestCase): sa.sql.column('value', sa.Unicode), sa.sql.column('pended_id', sa.Integer), ) - def get_from_db(): # noqa + def get_from_db(): # noqa: E301 results = {} for i in range(1, 6): query = sa.sql.select( @@ -227,7 +227,7 @@ class TestMigrations(unittest.TestCase): self.assertTrue(os.path.exists(bee.data_path)) def test_7b254d88f122_moderation_action(self): - mailinglist_table = sa.sql.table( # noqa + sa.sql.table( 'mailinglist', sa.sql.column('id', sa.Integer), sa.sql.column('list_id', sa.Unicode), diff --git a/src/mailman/handlers/acknowledge.py b/src/mailman/handlers/acknowledge.py index f493c4aa6..c7035de67 100644 --- a/src/mailman/handlers/acknowledge.py +++ b/src/mailman/handlers/acknowledge.py @@ -60,7 +60,7 @@ class Acknowledge: if 'lang' in msgdata else member.preferred_language) # Now get the acknowledgement template. - display_name = mlist.display_name # noqa + display_name = mlist.display_name # noqa: F841 template = getUtility(ITemplateLoader).get( 'list:user:notice:post', mlist, language=language.code) diff --git a/src/mailman/handlers/cook_headers.py b/src/mailman/handlers/cook_headers.py index 23a65cdcd..297155d90 100644 --- a/src/mailman/handlers/cook_headers.py +++ b/src/mailman/handlers/cook_headers.py @@ -98,7 +98,7 @@ def process(mlist, msg, msgdata): # A convenience function, requires nested scopes. pair is (name, addr) new = [] d = {} - def add(pair): # noqa + def add(pair): # noqa: E301 lcaddr = pair[1].lower() if lcaddr in d: return @@ -137,10 +137,10 @@ def process(mlist, msg, msgdata): # above code? # Also skip Cc if this is an anonymous list as list posting address # is already in From and Reply-To in this case. - if (mlist.personalize is Personalization.full and - mlist.reply_goes_to_list is not - ReplyToMunging.point_to_list and # noqa - not mlist.anonymous_list): + if (mlist.personalize is Personalization.full + and mlist.reply_goes_to_list is not # noqa: W503 + ReplyToMunging.point_to_list + and not mlist.anonymous_list): # noqa: W503 # Watch out for existing Cc headers, merge, and remove dups. Note # that RFC 2822 says only zero or one Cc header is allowed. new = [] diff --git a/src/mailman/model/tests/test_domain.py b/src/mailman/model/tests/test_domain.py index dc0d3b5bf..fb7896c6e 100644 --- a/src/mailman/model/tests/test_domain.py +++ b/src/mailman/model/tests/test_domain.py @@ -122,7 +122,7 @@ class TestDomainManager(unittest.TestCase): self.assertEqual( sorted(owner.addresses[0].email for owner in domain.owners), ['anne@example.com', 'bart@example.com']) - def sort_key(owner): # noqa + def sort_key(owner): # noqa: E301 return owner.addresses[0].email self.assertEqual(sorted(domain.owners, key=sort_key), [anne, bart]) diff --git a/src/mailman/model/tests/test_preferences.py b/src/mailman/model/tests/test_preferences.py index 2b9eeba96..cd8313ed4 100644 --- a/src/mailman/model/tests/test_preferences.py +++ b/src/mailman/model/tests/test_preferences.py @@ -41,7 +41,7 @@ class TestPreferences(unittest.TestCase): for name in IPreferences.names(): attribute = IPreferences.getDescriptionFor(name) if (not isinstance(attribute, Method) - and isinstance(attribute, Attribute)): # noqa + and isinstance(attribute, Attribute)): # noqa: W503 attributes.append(name) values = { 'acknowledge_posts': True, diff --git a/src/mailman/model/tests/test_requests.py b/src/mailman/model/tests/test_requests.py index 4135dbc4e..3d4f64783 100644 --- a/src/mailman/model/tests/test_requests.py +++ b/src/mailman/model/tests/test_requests.py @@ -104,7 +104,7 @@ Something else. # value in a descending counter. request_ids = [] counter = count(200, -1) - def id_hacker(session, flush_context, instances): # noqa + def id_hacker(session, flush_context, instances): # noqa: E301 for instance in session.new: if isinstance(instance, _Request): instance.id = next(counter) diff --git a/src/mailman/mta/deliver.py b/src/mailman/mta/deliver.py index caca18aef..a5a4e2433 100644 --- a/src/mailman/mta/deliver.py +++ b/src/mailman/mta/deliver.py @@ -90,15 +90,15 @@ def deliver(mlist, msg, msgdata): if size is None: size = len(msg.as_string()) substitutions = dict( - msgid = msg.get('message-id', 'n/a'), # noqa - listname = mlist.fqdn_listname, # noqa - sender = original_sender, # noqa - recip = len(original_recipients), # noqa - size = size, # noqa - time = t1 - t0, # noqa - refused = len(refused), # noqa - smtpcode = 'n/a', # noqa - smtpmsg = 'n/a', # noqa + msgid = msg.get('message-id', 'n/a'), # noqa: E221, E251 + listname = mlist.fqdn_listname, # noqa: E221, E251 + sender = original_sender, # noqa: E221, E251 + recip = len(original_recipients), # noqa: E221, E251 + size = size, # noqa: E221, E251 + time = t1 - t0, # noqa: E221, E251 + refused = len(refused), # noqa: E221, E251 + smtpcode = 'n/a', # noqa: E221, E251 + smtpmsg = 'n/a', # noqa: E221, E251 ) template = config.logging.smtp.every if template.lower() != 'no': @@ -141,9 +141,9 @@ def deliver(mlist, msg, msgdata): template = config.logging.smtp.failure if template.lower() != 'no': substitutions.update( - recip = recipient, # noqa - smtpcode = code, # noqa - smtpmsg = smtp_message, # noqa + recip = recipient, # noqa: E221, E251 + smtpcode = code, # noqa: E221, E251 + smtpmsg = smtp_message, # noqa: E221, E251 ) log.info('%s', expand(template, mlist, substitutions)) # Return the results diff --git a/src/mailman/rest/tests/test_paginate.py b/src/mailman/rest/tests/test_paginate.py index cd8b2217e..5f28d093a 100644 --- a/src/mailman/rest/tests/test_paginate.py +++ b/src/mailman/rest/tests/test_paginate.py @@ -48,7 +48,7 @@ class TestPaginateHelper(unittest.TestCase): class Resource(CollectionMixin): def _get_collection(self, request): return ['one', 'two', 'three', 'four', 'five'] - def _resource_as_dict(self, res): # noqa + def _resource_as_dict(self, res): # noqa: E301 return {'value': res} return Resource() diff --git a/src/mailman/rest/users.py b/src/mailman/rest/users.py index ede435ad8..c405a1ede 100644 --- a/src/mailman/rest/users.py +++ b/src/mailman/rest/users.py @@ -55,7 +55,7 @@ class ListOfDomainOwners(GetterSetter): def get(self, domain, attribute): assert attribute == 'owner', ( 'Unexpected attribute: {}'.format(attribute)) - def sort_key(owner): # noqa + def sort_key(owner): # noqa: E301 return owner.addresses[0].email return sorted(domain.owners, key=sort_key) diff --git a/src/mailman/rules/moderation.py b/src/mailman/rules/moderation.py index b6b33f720..20b238eab 100644 --- a/src/mailman/rules/moderation.py +++ b/src/mailman/rules/moderation.py @@ -145,7 +145,7 @@ class NonmemberModeration: checklist = getattr(mlist, legacy_attribute_name) for addr in checklist: if ((addr.startswith('^') and re.match(addr, sender)) - or addr == sender): # noqa + or addr == sender): # noqa: W503 # The reason will get translated at the point of use. reason = 'The sender is in the nonmember {} list' _record_action(msgdata, action, sender, diff --git a/src/mailman/runners/command.py b/src/mailman/runners/command.py index 00f6f416b..ba10988e3 100644 --- a/src/mailman/runners/command.py +++ b/src/mailman/runners/command.py @@ -169,9 +169,9 @@ class CommandRunner(Runner): # Include just a few key pieces of information from the original: the # sender, date, and message id. print(_('- Original message details:'), file=results) - subject = msg.get('subject', 'n/a') # noqa - date = msg.get('date', 'n/a') # noqa - from_ = msg.get('from', 'n/a') # noqa + subject = msg.get('subject', 'n/a') # noqa: F841 + date = msg.get('date', 'n/a') # noqa: F841 + from_ = msg.get('from', 'n/a') # noqa: F841 print(_(' From: $from_'), file=results) print(_(' Subject: $subject'), file=results) print(_(' Date: $date'), file=results) diff --git a/src/mailman/runners/rest.py b/src/mailman/runners/rest.py index 0100b0db9..36b03aa5a 100644 --- a/src/mailman/runners/rest.py +++ b/src/mailman/runners/rest.py @@ -50,7 +50,7 @@ class RESTRunner(Runner): # server. self._server = make_server() self._event = threading.Event() - def stopper(event, server): # noqa + def stopper(event, server): # noqa: E301 event.wait() server.shutdown() self._thread = threading.Thread( diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index a57d883c7..6496484ca 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -244,7 +244,7 @@ def get_nntp_server(cleanups): cleanups.append(patcher.stop) nntpd = server_class() # A class for more convenient access to the posted message. - class NNTPProxy: # noqa + class NNTPProxy: # noqa: E301 def get_message(self): args = nntpd.post.call_args return specialized_message_from_string(args[0][0].read()) diff --git a/src/mailman/testing/nose.py b/src/mailman/testing/nose.py index f88ac409a..6a2e0d6ba 100644 --- a/src/mailman/testing/nose.py +++ b/src/mailman/testing/nose.py @@ -42,7 +42,7 @@ class NosePlugin(Plugin): super().__init__() self.patterns = [] self.stderr = False - def set_stderr(ignore): # noqa + def set_stderr(ignore): # noqa: E301 self.stderr = True self.addArgument(self.patterns, 'P', 'pattern', 'Add a test matching pattern') diff --git a/src/mailman/tests/test_configfile.py b/src/mailman/tests/test_configfile.py index 9406d9ca2..0112f78bd 100644 --- a/src/mailman/tests/test_configfile.py +++ b/src/mailman/tests/test_configfile.py @@ -116,7 +116,7 @@ class TestConfigFileSearchWithChroot(TestConfigFileBase): # system that we can write to and test is to hack os.path.exists() to # prepend a temporary directory onto the path it tests. self._os_path_exists = os.path.exists - def exists(path): # noqa + def exists(path): # noqa: E301 # Strip off the leading slash, otherwise we'll end up with path. return self._os_path_exists(self._make_fake(path)) os.path.exists = exists 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 diff --git a/src/mailman/version.py b/src/mailman/version.py index 6a86a5768..db0610b08 100644 --- a/src/mailman/version.py +++ b/src/mailman/version.py @@ -23,10 +23,10 @@ CODENAME = 'Between The Wheels' # And as a hex number in the manner of PY_VERSION_HEX. ALPHA = 0xa -BETA = 0xb # noqa +BETA = 0xb # noqa: E221 GAMMA = 0xc # Release candidates. -RC = GAMMA # noqa +RC = GAMMA # noqa: E221 FINAL = 0xf MAJOR_REV = 3 @@ -37,7 +37,7 @@ REL_LEVEL = ALPHA REL_SERIAL = 1 HEX_VERSION = ((MAJOR_REV << 24) | (MINOR_REV << 16) | (MICRO_REV << 8) | - (REL_LEVEL << 4) | (REL_SERIAL << 0)) # noqa + (REL_LEVEL << 4) | (REL_SERIAL << 0)) # noqa: E221 # queue/*.pck schema version number. |
