Skip to content

Commit

Permalink
Merge pull request #1396 from twisted/9971-stricter-mypy
Browse files Browse the repository at this point in the history
Use a stricter Mypy to prevent regressions
  • Loading branch information
wsanchez committed Sep 24, 2020
2 parents f9ce660 + ccb6d02 commit f4018a5
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 8 deletions.
225 changes: 219 additions & 6 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,234 @@ ignore_missing_imports = True

# Increase our expectations

check_untyped_defs = True
disallow_incomplete_defs = True
disallow_untyped_defs = True
no_implicit_optional = True
show_column_numbers = True
show_error_codes = True
strict_optional = True
warn_no_return = True
warn_redundant_casts = True
warn_return_any = True
warn_unreachable = True
warn_unused_ignores = True

# Enable these over time
# Disable some checks until the effected modules fully adopt mypy

disallow_untyped_defs = False
check_untyped_defs = False
disallow_incomplete_defs = False
no_implicit_optional = False
warn_return_any = False
[mypy-twisted._threads.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.application.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.application.runner.test.test_runner]
allow_incomplete_defs = True

[mypy-twisted.conch.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.conch.insults.insults]
warn_return_any = False

[mypy-twisted.conch.ssh.channel]
warn_return_any = False

[mypy-twisted.conch.ssh.keys]
warn_return_any = False

[mypy-twisted.cred.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.enterprise.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.internet.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.internet._sslverify]
warn_return_any = False

[mypy-twisted.internet.abstract]
allow_incomplete_defs = True
warn_return_any = False

[mypy-twisted.internet.base]
allow_incomplete_defs = True
warn_return_any = False

[mypy-twisted.internet.interfaces]
allow_incomplete_defs = True

[mypy-twisted.internet.iocpreactor.tcp]
warn_return_any = False

[mypy-twisted.internet.posixbase]
allow_incomplete_defs = True

[mypy-twisted.internet.protocol]
allow_incomplete_defs = True

[mypy-twisted.internet.task]
allow_incomplete_defs = True

[mypy-twisted.internet.tcp]
warn_return_any = False

[mypy-twisted.internet.test.test_base]
allow_incomplete_defs = True

[mypy-twisted.internet.testing]
allow_incomplete_defs = True

[mypy-twisted.logger.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.mail.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.mail._except]
warn_return_any = False

[mypy-twisted.mail.imap4]
warn_return_any = False

[mypy-twisted.mail.smtp]
warn_return_any = False

[mypy-twisted.mail.relaymanager]
allow_incomplete_defs = True

[mypy-twisted.names.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.names._rfc1982]
warn_return_any = False

[mypy-twisted.names.dns]
warn_return_any = False

[mypy-twisted.names.test.test_dns]
warn_return_any = False

[mypy-twisted.pair.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.persisted.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.plugin.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.plugins.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.positioning.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.protocols.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.protocols.amp]
warn_return_any = False

[mypy-twisted.protocols.sip]
warn_return_any = False

[mypy-twisted.protocols.test.test_basic]
allow_incomplete_defs = True

[mypy-twisted.python.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.python._setup]
allow_incomplete_defs = True
warn_return_any = False

[mypy-twisted.python.compat]
allow_incomplete_defs = True
warn_return_any = False

[mypy-twisted.python.modules]
warn_return_any = False

[mypy-twisted.python.urlpath]
warn_return_any = False

[mypy-twisted.python.usage]
warn_return_any = False

[mypy-twisted.runner.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.scripts.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.spread.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.tap.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.test.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.test.test_plugin]
allow_incomplete_defs = True

[mypy-twisted.web.test.test_util]
allow_incomplete_defs = True

[mypy-twisted.trial.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.web.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.web.error]
warn_return_any = False

[mypy-twisted.web.util]
allow_incomplete_defs = True

[mypy-twisted.words.*]
allow_untyped_defs = True
check_untyped_defs = False

[mypy-twisted.words.im.basesupport]
allow_incomplete_defs = True

[mypy-twisted.words.im.locals]
warn_return_any = False

[mypy-twisted.words.protocols.jabber.jid]
warn_return_any = False

[mypy-twisted.words.xish.domish]
warn_return_any = False

# Disable warn_unreachable for some modules until we clean them up

Expand Down
4 changes: 2 additions & 2 deletions src/twisted/internet/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


from socket import AF_INET, AF_INET6, inet_pton, error
from typing import List, Sequence
from typing import List, Optional, Sequence

from zope.interface import implementer

Expand Down Expand Up @@ -174,7 +174,7 @@ class FileDescriptor(_ConsumerMixin, _LogOwner):

SEND_LIMIT = 128 * 1024

def __init__(self, reactor: interfaces.IReactorFDSet = None):
def __init__(self, reactor: Optional[interfaces.IReactorFDSet] = None):
"""
@param reactor: An L{IReactorFDSet} provider which this descriptor will
use to get readable and writeable event notifications. If no value
Expand Down
Empty file.

0 comments on commit f4018a5

Please sign in to comment.