Skip to content

Commit

Permalink
Get mypy running with clean output (certbot#5864)
Browse files Browse the repository at this point in the history
Fixes certbot#5849.

* extract mypy flags into mypy.ini file

* Get mypy running with clean output
  • Loading branch information
ohemorange authored and bmw committed Apr 13, 2018
1 parent a708504 commit 6253acf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def test_cleanup(self):


class DigitalOceanClientTest(unittest.TestCase):
id = 1

id_num = 1
record_prefix = "_acme-challenge"
record_name = record_prefix + "." + DOMAIN
record_content = "bar"
Expand All @@ -70,7 +71,7 @@ def test_add_txt_record(self):

domain_mock = mock.MagicMock()
domain_mock.name = DOMAIN
domain_mock.create_new_domain_record.return_value = {'domain_record': {'id': self.id}}
domain_mock.create_new_domain_record.return_value = {'domain_record': {'id': self.id_num}}

self.manager.get_all_domains.return_value = [wrong_domain_mock, domain_mock]

Expand Down
2 changes: 1 addition & 1 deletion certbot/crypto_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import six
import zope.component
from cryptography.hazmat.backends import default_backend
from cryptography import x509
from cryptography import x509 # type: ignore

from acme import crypto_util as acme_crypto_util

Expand Down
5 changes: 3 additions & 2 deletions certbot/tests/cert_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,12 @@ def test_report_human_readable(self, mock_revoked):
cert.is_test_cert = False
parsed_certs = [cert]

mock_config = mock.MagicMock(certname=None, lineagename=None)
# pylint: disable=protected-access
get_report = lambda: cert_manager._report_human_readable(mock_config, parsed_certs)

mock_config = mock.MagicMock(certname=None, lineagename=None)
# pylint: disable=protected-access
get_report = lambda: cert_manager._report_human_readable(mock_config, parsed_certs)

out = get_report()
self.assertTrue("INVALID: EXPIRED" in out)

Expand Down
2 changes: 1 addition & 1 deletion certbot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# the dict are attempted to be cleaned up at program exit. If the
# program exits before the lock is cleaned up, it is automatically
# released, but the file isn't deleted.
_LOCKS = OrderedDict()
_LOCKS = OrderedDict() # type: OrderedDict[str, lock.LockFile]


def run_script(params, log=logger.error):
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
python_version = 2.7
ignore_missing_imports = True
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ basepython = python3
commands =
{[base]pip_install} .[dev3]
{[base]install_packages}
mypy --py2 --ignore-missing-imports {[base]source_paths}
mypy {[base]source_paths}

[testenv:apacheconftest]
#basepython = python2.7
Expand Down

0 comments on commit 6253acf

Please sign in to comment.