mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 08:45:22 +02:00
Fix Pylint upgrade issues
* Remove unsupported pylint disable options
* star-args removed in Pylint 1.4.3
* abstract-class-little-used removed in Pylint 1.4.3
* Fixes new lint errors
* Copy dummy-variable-rgx expression to new ignored-argument-names expression to ignore unused funtion arguments
* Notable changes
* Refactor to satisfy Pylint no-else-return warning
* Fix Pylint inconsistent-return-statements warning
* Refactor to satisfy consider-iterating-dictionary
* Remove methods with only super call to satisfy useless-super-delegation
* Refactor too-many-nested-statements where possible
* Suppress type checked errors where member is dynamically added (notably derived from josepy.JSONObjectWithFields)
* Remove None default of func parameter for ExitHandler and ErrorHandler
Resolves #5973
This commit is contained in:
@@ -299,9 +299,8 @@ class Addr(object):
|
||||
# too long, truncate
|
||||
addr_list = addr_list[0:len(result)]
|
||||
append_to_end = False
|
||||
for i in range(0, len(addr_list)):
|
||||
block = addr_list[i]
|
||||
if len(block) == 0:
|
||||
for i, block in enumerate(addr_list):
|
||||
if not block:
|
||||
# encountered ::, so rest of the blocks should be
|
||||
# appended to the end
|
||||
append_to_end = True
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
import collections
|
||||
import itertools
|
||||
import logging
|
||||
|
||||
import pkg_resources
|
||||
import six
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
import zope.interface
|
||||
import zope.interface.verify
|
||||
|
||||
@@ -184,7 +183,11 @@ class PluginsRegistry(collections.Mapping):
|
||||
# This prevents deadlock caused by plugins acquiring a lock
|
||||
# and ensures at least one concurrent Certbot instance will run
|
||||
# successfully.
|
||||
self._plugins = OrderedDict(sorted(six.iteritems(plugins)))
|
||||
|
||||
# Pylint checks for super init, but also claims the super
|
||||
# has no __init__member
|
||||
# pylint: disable=super-init-not-called
|
||||
self._plugins = collections.OrderedDict(sorted(six.iteritems(plugins)))
|
||||
|
||||
@classmethod
|
||||
def find_all(cls):
|
||||
@@ -233,7 +236,6 @@ class PluginsRegistry(collections.Mapping):
|
||||
|
||||
def ifaces(self, *ifaces_groups):
|
||||
"""Filter plugins based on interfaces."""
|
||||
# pylint: disable=star-args
|
||||
return self.filter(lambda p_ep: p_ep.ifaces(*ifaces_groups))
|
||||
|
||||
def verify(self, ifaces):
|
||||
@@ -269,8 +271,7 @@ class PluginsRegistry(collections.Mapping):
|
||||
assert len(candidates) <= 1
|
||||
if candidates:
|
||||
return candidates[0]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
def __repr__(self):
|
||||
return "{0}({1})".format(
|
||||
|
||||
@@ -83,7 +83,7 @@ class DNSAuthenticator(common.Plugin):
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def _perform(self, domain, validation_domain_name, validation): # pragma: no cover
|
||||
def _perform(self, domain, validation_name, validation): # pragma: no cover
|
||||
"""
|
||||
Performs a dns-01 challenge by creating a DNS TXT record.
|
||||
|
||||
@@ -95,7 +95,7 @@ class DNSAuthenticator(common.Plugin):
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def _cleanup(self, domain, validation_domain_name, validation): # pragma: no cover
|
||||
def _cleanup(self, domain, validation_name, validation): # pragma: no cover
|
||||
"""
|
||||
Deletes the DNS TXT record which would have been created by `_perform_achall`.
|
||||
|
||||
|
||||
@@ -95,3 +95,4 @@ class LexiconClient(object):
|
||||
if not str(e).startswith('No domain found'):
|
||||
return errors.PluginError('Unexpected error determining zone identifier for {0}: {1}'
|
||||
.format(domain_name, e))
|
||||
return None
|
||||
|
||||
@@ -22,10 +22,6 @@ class DNSAuthenticatorTest(util.TempDirTestCase, dns_test_common.BaseAuthenticat
|
||||
_perform = mock.MagicMock()
|
||||
_cleanup = mock.MagicMock()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
# pylint: disable=protected-access
|
||||
super(DNSAuthenticatorTest._FakeDNSAuthenticator, self).__init__(*args, **kwargs)
|
||||
|
||||
def more_info(self): # pylint: disable=missing-docstring,no-self-use
|
||||
return 'A fake authenticator for testing.'
|
||||
|
||||
|
||||
@@ -137,8 +137,7 @@ class AuthenticatorTest(test_util.TempDirTestCase):
|
||||
self.auth.cleanup([achall])
|
||||
self.assertEqual(os.environ['CERTBOT_AUTH_OUTPUT'], 'foo')
|
||||
self.assertEqual(os.environ['CERTBOT_DOMAIN'], achall.domain)
|
||||
if (isinstance(achall.chall, challenges.HTTP01) or
|
||||
isinstance(achall.chall, challenges.DNS01)):
|
||||
if isinstance(achall.chall, (challenges.HTTP01, challenges.DNS01)):
|
||||
self.assertEqual(
|
||||
os.environ['CERTBOT_VALIDATION'],
|
||||
achall.validation(achall.account_key))
|
||||
|
||||
@@ -82,8 +82,7 @@ def pick_plugin(config, default, plugins, question, ifaces):
|
||||
plugin_ep = choose_plugin(list(six.itervalues(prepared)), question)
|
||||
if plugin_ep is None:
|
||||
return None
|
||||
else:
|
||||
return plugin_ep.init()
|
||||
return plugin_ep.init()
|
||||
elif len(prepared) == 1:
|
||||
plugin_ep = list(prepared.values())[0]
|
||||
logger.debug("Single candidate plugin: %s", plugin_ep)
|
||||
|
||||
@@ -225,7 +225,8 @@ class Authenticator(common.Plugin):
|
||||
try:
|
||||
return self._perform_single(achall)
|
||||
except errors.StandaloneBindError as error:
|
||||
_handle_perform_error(error)
|
||||
if not _handle_perform_error(error):
|
||||
raise
|
||||
|
||||
def _perform_single(self, achall):
|
||||
if isinstance(achall.chall, challenges.HTTP01):
|
||||
@@ -282,5 +283,5 @@ def _handle_perform_error(error):
|
||||
"Cancel", default=False)
|
||||
if not should_retry:
|
||||
raise errors.PluginError(msg)
|
||||
else:
|
||||
raise
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Tests for certbot.plugins.storage.PluginStorage"""
|
||||
import json
|
||||
import mock
|
||||
import os
|
||||
import unittest
|
||||
import mock
|
||||
|
||||
from certbot import errors
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ def get_prefixes(path):
|
||||
"""
|
||||
prefix = path
|
||||
prefixes = []
|
||||
while len(prefix) > 0:
|
||||
while prefix:
|
||||
prefixes.append(prefix)
|
||||
prefix, _ = os.path.split(prefix)
|
||||
# break once we hit '/'
|
||||
@@ -49,8 +49,7 @@ def path_surgery(cmd):
|
||||
|
||||
if util.exe_exists(cmd):
|
||||
return True
|
||||
else:
|
||||
expanded = " expanded" if any(added) else ""
|
||||
logger.warning("Failed to find executable %s in%s PATH: %s", cmd,
|
||||
expanded, path)
|
||||
return False
|
||||
expanded = " expanded" if any(added) else ""
|
||||
logger.warning("Failed to find executable %s in%s PATH: %s", cmd,
|
||||
expanded, path)
|
||||
return False
|
||||
|
||||
@@ -220,7 +220,7 @@ to serve all files under specified web root ({0})."""
|
||||
self.performed[root_path].remove(achall)
|
||||
|
||||
not_removed = []
|
||||
while len(self._created_dirs) > 0:
|
||||
while self._created_dirs:
|
||||
path = self._created_dirs.pop()
|
||||
try:
|
||||
os.rmdir(path)
|
||||
|
||||
Reference in New Issue
Block a user