[tahoe-lafs-trac-stream] [Tahoe-LAFS] #3399: Evaluate adding mypy checks to code checks

Tahoe-LAFS trac at tahoe-lafs.org
Fri Sep 18 19:52:38 UTC 2020


#3399: Evaluate adding mypy checks to code checks
-----------------------------+------------------------------
     Reporter:  jaraco       |      Owner:
         Type:  enhancement  |     Status:  new
     Priority:  normal       |  Milestone:  Support Python 3
    Component:  unknown      |    Version:  n/a
   Resolution:               |   Keywords:
Launchpad Bug:               |
-----------------------------+------------------------------

Comment (by jaraco):

 Fantastic suggestion. Digging deeper into the interfaces implementations,
 I noticed that many of them are in fact zope interfaces. In 471c88c70,
 I've simply added that plugin and enabled it and the errors dropped from
 242 to 142 (exactly 100? that's suspicious o_O).

 {{{
 typechecks installed: mypy==0.782,mypy-extensions==0.4.3,mypy-zope==0.2.7
 ,typed-ast==1.4.1,typing-
 extensions==3.7.4.3,zope.event==4.5.0,zope.interface==5.1.0,zope.schema==6.0.0
 typechecks run-test-pre: PYTHONHASHSEED='2059477720'
 typechecks run-test: commands[0] | mypy src
 src/allmydata/util/pollmixin.py:26: error: Need type annotation for
 '_poll_should_ignore_these_errors' (hint:
 "_poll_should_ignore_these_errors: List[<type>] = ...")
 src/allmydata/test/test_python3.py:50: error:
 "Callable[[Python3PortingEffortTests], Any]" has no attribute "todo"
 src/allmydata/test/check_load.py:47: error: Need type annotation for
 'last_stats' (hint: "last_stats: Dict[<type>, <type>] = ...")
 src/allmydata/test/check_load.py:56: error: Incompatible types in
 assignment (expression has type "float", target has type "int")
 src/allmydata/interfaces.py:59: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:67: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:110: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:683: error: Cannot determine consistent method
 resolution order (MRO) for "IVerifierURI"
 src/allmydata/interfaces.py:750: error: Interface methods should not have
 'self' argument
 src/allmydata/interfaces.py:758: error: Interface methods should not have
 'self' argument
 src/allmydata/interfaces.py:2845: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:2863: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:2880: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:2883: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:2889: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:2896: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:2909: error: Method must have at least one
 argument
 src/allmydata/interfaces.py:2939: error: Method must have at least one
 argument
 src/allmydata/web/private.py:64: error: zope.interface.implementer accepts
 interface, not allmydata.web.private.IToken.
 src/allmydata/web/private.py:64: error: Make sure you have stubs for all
 packages that provide interfaces for allmydata.web.private.IToken class
 hierarchy.
 src/allmydata/introducer/interfaces.py:45: error: Method must have at
 least one argument
 src/allmydata/codec.py:23: error: 'CRSEncoder' is missing following
 'ICodecEncoder' interface members: encode_proposal.
 src/allmydata/util/fileutil.py:312: error: Name '_getfullpathname' already
 defined on line 310
 src/allmydata/storage/immutable.py:193: error: zope.interface.implementer
 accepts interface, not allmydata.interfaces.RIBucketWriter.
 src/allmydata/storage/immutable.py:193: error: Make sure you have stubs
 for all packages that provide interfaces for
 allmydata.interfaces.RIBucketWriter class hierarchy.
 src/allmydata/storage/immutable.py:292: error: zope.interface.implementer
 accepts interface, not allmydata.interfaces.RIBucketReader.
 src/allmydata/storage/immutable.py:292: error: Make sure you have stubs
 for all packages that provide interfaces for
 allmydata.interfaces.RIBucketReader class hierarchy.
 src/allmydata/storage/crawler.py:22: error: Name 'pickle' already defined
 (possibly by an import)
 src/allmydata/introducer/client.py:20: error: zope.interface.implementer
 accepts interface, not
 allmydata.introducer.interfaces.RIIntroducerSubscriberClient_v2.
 src/allmydata/introducer/client.py:20: error: Make sure you have stubs for
 all packages that provide interfaces for
 allmydata.introducer.interfaces.RIIntroducerSubscriberClient_v2 class
 hierarchy.
 src/allmydata/introducer/client.py:159: error: Signature of
 "IntroducerClient" incompatible with "subscribe_to" of supertype
 "IIntroducerClient"
 src/allmydata/introducer/client.py:200: error: Signature of
 "IntroducerClient" incompatible with "publish" of supertype
 "IIntroducerClient"
 src/allmydata/stats.py:126: error: zope.interface.implementer accepts
 interface, not allmydata.interfaces.RIStatsProvider.
 src/allmydata/stats.py:126: error: Make sure you have stubs for all
 packages that provide interfaces for allmydata.interfaces.RIStatsProvider
 class hierarchy.
 src/allmydata/stats.py:179: error: zope.interface.implementer accepts
 interface, not allmydata.interfaces.RIStatsGatherer.
 src/allmydata/stats.py:179: error: Make sure you have stubs for all
 packages that provide interfaces for allmydata.interfaces.RIStatsGatherer
 class hierarchy.
 src/allmydata/node.py:712: error: Need type annotation for
 'GENERATED_FILES' (hint: "GENERATED_FILES: List[<type>] = ...")
 src/allmydata/windows/fixups.py:220: error: Name 'unichr' is not defined
 src/allmydata/test/test_iputil.py:136: error: "Callable[[ListAddresses],
 Any]" has no attribute "timeout"
 src/allmydata/web/status.py:1327: error: Name 'cmp' is not defined
 src/allmydata/web/status.py:1335: error: Name 'cmp' is not defined
 src/allmydata/test/test_stats.py:9: error: Incompatible types in
 assignment (expression has type "float", base class "CPUUsageMonitor"
 defined the type as "int")
 src/allmydata/storage/server.py:39: error: zope.interface.implementer
 accepts interface, not allmydata.interfaces.RIStorageServer.
 src/allmydata/storage/server.py:39: error: Make sure you have stubs for
 all packages that provide interfaces for
 allmydata.interfaces.RIStorageServer class hierarchy.
 src/allmydata/uri.py:491: error: '_DirectoryBaseURI' is missing following
 'IURI' interface members: is_readonly, get_readonly.
 src/allmydata/uri.py:726: error: Incompatible types in assignment
 (expression has type "Type[CHKFileVerifierURI]", base class
 "DirectoryURIVerifier" defined the type as "Type[SSKVerifierURI]")
 src/allmydata/immutable/literal.py:10: error: '_ImmutableFileNodeBase' is
 missing following 'allmydata.interfaces.IFilesystemNode' interface
 members: get_storage_index, get_size, get_cap, get_readcap,
 get_repair_cap, get_verify_cap, get_uri, get_current_size.
 src/allmydata/immutable/literal.py:10: error: '_ImmutableFileNodeBase' is
 missing following 'allmydata.interfaces.IReadable' interface members:
 download_to_data, read.
 src/allmydata/immutable/literal.py:10: error: '_ImmutableFileNodeBase' is
 missing following 'allmydata.interfaces.IFileNode' interface members:
 get_best_readable_version, download_best_version,
 get_size_of_best_version.
 src/allmydata/immutable/literal.py:10: error: '_ImmutableFileNodeBase' is
 missing following 'ICheckable' interface members: check, check_and_repair.
 src/allmydata/immutable/encode.py:78: error: 'Encoder' is missing
 following 'IEncoder' interface members: set_size.
 src/allmydata/scripts/run_common.py:70: error: List item 0 has
 incompatible type "Tuple[str, str, None, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/debug.py:21: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/debug.py:419: error: Incompatible types in
 assignment (expression has type "str", base class "BaseOptions" defined
 the type as "None")
 src/allmydata/scripts/debug.py:613: error: Incompatible types in
 assignment (expression has type "str", base class "BaseOptions" defined
 the type as "None")
 src/allmydata/scripts/debug.py:661: error: Incompatible types in
 assignment (expression has type "str", base class "BaseOptions" defined
 the type as "None")
 src/allmydata/scripts/debug.py:875: error: Incompatible types in
 assignment (expression has type "str", base class "BaseOptions" defined
 the type as "None")
 src/allmydata/scripts/create_node.py:147: error: Incompatible types in
 assignment (expression has type "str", base class "BaseOptions" defined
 the type as "None")
 src/allmydata/scripts/create_node.py:154: error: List item 0 has
 incompatible type "Tuple[str, str, None, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/create_node.py:155: error: List item 1 has
 incompatible type "Tuple[str, str, None, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/create_node.py:156: error: List item 2 has
 incompatible type "Tuple[str, str, str, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/create_node.py:158: error: List item 3 has
 incompatible type "Tuple[str, str, None, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/create_node.py:160: error: List item 4 has
 incompatible type "Tuple[str, None, int, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/create_node.py:161: error: List item 5 has
 incompatible type "Tuple[str, None, int, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/create_node.py:162: error: List item 6 has
 incompatible type "Tuple[str, None, int, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/create_node.py:163: error: List item 7 has
 incompatible type "Tuple[str, None, None, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/create_node.py:199: error: Incompatible types in
 assignment (expression has type "str", base class "BaseOptions" defined
 the type as "None")
 src/allmydata/immutable/upload.py:319: error: 'PeerSelector' is missing
 following 'IPeerSelector' interface members: confirm_share_allocation,
 add_peers.
 src/allmydata/immutable/upload.py:1411: error: zope.interface.implementer
 accepts interface, not allmydata.interfaces.RIEncryptedUploadable.
 src/allmydata/immutable/upload.py:1411: error: Make sure you have stubs
 for all packages that provide interfaces for
 allmydata.interfaces.RIEncryptedUploadable class hierarchy.
 src/allmydata/control.py:58: error: zope.interface.implementer accepts
 interface, not allmydata.interfaces.RIControlClient.
 src/allmydata/control.py:58: error: Make sure you have stubs for all
 packages that provide interfaces for allmydata.interfaces.RIControlClient
 class hierarchy.
 src/allmydata/scripts/tahoe_start.py:20: error: List item 0 has
 incompatible type "Tuple[str, str, None, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/stats_gatherer.py:15: error: List item 0 has
 incompatible type "Tuple[str, None, None, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/stats_gatherer.py:16: error: List item 1 has
 incompatible type "Tuple[str, None, None, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/stats_gatherer.py:17: error: List item 2 has
 incompatible type "Tuple[str, None, None, str]"; expected
 "List[Optional[str]]"
 src/allmydata/scripts/stats_gatherer.py:27: error: Incompatible types in
 assignment (expression has type "str", base class "BaseOptions" defined
 the type as "None")
 src/allmydata/mutable/filenode.py:554: error: Signature of
 "MutableFileNode" incompatible with "upload" of supertype
 "IMutableFileNode"
 src/allmydata/mutable/filenode.py:702: error: 'MutableFileVersion' is
 missing following 'IMutableFileVersion' interface members: get_servermap.
 src/allmydata/mutable/filenode.py:941: error: Signature of
 "MutableFileVersion" incompatible with "download_to_data" of supertype
 "allmydata.interfaces.IReadable"
 src/allmydata/immutable/offloaded.py:125: error:
 zope.interface.implementer accepts interface, not
 allmydata.interfaces.RICHKUploadHelper.
 src/allmydata/immutable/offloaded.py:125: error: Make sure you have stubs
 for all packages that provide interfaces for
 allmydata.interfaces.RICHKUploadHelper class hierarchy.
 src/allmydata/immutable/offloaded.py:450: error: 'LocalCiphertextReader'
 is missing following 'IEncryptedUploadable' interface members:
 set_upload_status.
 src/allmydata/immutable/offloaded.py:486: error:
 zope.interface.implementer accepts interface, not
 allmydata.interfaces.RIHelper.
 src/allmydata/immutable/offloaded.py:486: error: Make sure you have stubs
 for all packages that provide interfaces for allmydata.interfaces.RIHelper
 class hierarchy.
 src/allmydata/frontends/ftpd.py:2: error: Module 'types' has no attribute
 'NoneType'
 src/allmydata/dirnode.py:557: error: Signature of "DirectoryNode"
 incompatible with "set_uri" of supertype "IDirectoryNode"
 src/allmydata/web/directory.py:1217: error: Incompatible types in
 assignment (expression has type "str", base class "MultiFormatResource"
 defined the type as "None")
 src/allmydata/web/directory.py:1274: error: Incompatible types in
 assignment (expression has type "str", base class "MultiFormatResource"
 defined the type as "None")
 src/allmydata/scripts/cli.py:54: error: List item 0 has incompatible type
 "Tuple[str, None, None, str]"; expected "List[Optional[str]]"
 src/allmydata/scripts/cli.py:65: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:75: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:84: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:88: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:107: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:150: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:155: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:168: error: List item 0 has incompatible type
 "Tuple[str, None, None, str]"; expected "List[Optional[str]]"
 src/allmydata/scripts/cli.py:186: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:198: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:226: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:261: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:270: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:289: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:375: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:392: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:408: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:420: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:435: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/scripts/cli.py:452: error: Incompatible types in assignment
 (expression has type "str", base class "BaseOptions" defined the type as
 "None")
 src/allmydata/frontends/sftpd.py:3: error: Module 'types' has no attribute
 'NoneType'
 src/allmydata/scripts/runner.py:65: error: Unsupported operand types for +
 ("List[List[Union[Type[BaseOptions], str, None]]]" and "List[Tuple[str,
 None, Type[InviteOptions], str]]")
 src/allmydata/scripts/runner.py:110: error: Module has no attribute
 "dispatch"
 src/allmydata/introducer/server.py:130: error: zope.interface.implementer
 accepts interface, not
 allmydata.introducer.interfaces.RIIntroducerPublisherAndSubscriberService_v2.
 src/allmydata/introducer/server.py:130: error: Make sure you have stubs
 for all packages that provide interfaces for
 allmydata.introducer.interfaces.RIIntroducerPublisherAndSubscriberService_v2
 class hierarchy.
 src/allmydata/test/storage_plugin.py:41: error: Method must have at least
 one argument
 src/allmydata/test/storage_plugin.py:49: error: zope.interface.implementer
 accepts interface, not allmydata.interfaces.IFoolscapStoragePlugin.
 src/allmydata/test/storage_plugin.py:49: error: Make sure you have stubs
 for all packages that provide interfaces for
 allmydata.interfaces.IFoolscapStoragePlugin class hierarchy.
 src/allmydata/test/storage_plugin.py:106: error:
 zope.interface.implementer accepts interface, not
 allmydata.test.storage_plugin.RIDummy.
 src/allmydata/test/storage_plugin.py:106: error: Make sure you have stubs
 for all packages that provide interfaces for
 allmydata.test.storage_plugin.RIDummy class hierarchy.
 src/allmydata/test/storage_plugin.py:117: error: 'DummyStorageClient' is
 missing following 'IStorageServer' interface members: get_version,
 allocate_buckets, add_lease, renew_lease, get_buckets, slot_readv,
 slot_testv_and_readv_and_writev, advise_corrupt_share.
 src/allmydata/test/common.py:395: error: 'FakeCHKFileNode' is missing
 following 'allmydata.interfaces.IFilesystemNode' interface members:
 get_readcap.
 src/allmydata/test/common.py:533: error: 'FakeMutableFileNode' is missing
 following 'IMutableFileNode' interface members: download_version, upload.
 src/allmydata/test/test_storage_client.py:508: error: On Python 3
 '{}'.format(b'abc') produces "b'abc'"; use !r if this is a desired
 behavior
 src/allmydata/test/test_helper.py:88: error: Need type annotation for
 'introducer_clients' (hint: "introducer_clients: List[<type>] = ...")
 src/allmydata/test/no_network.py:142: error: 'NoNetworkServer' is missing
 following 'IServer' interface members: start_connecting.
 src/allmydata/test/no_network.py:180: error: 'NoNetworkStorageBroker' is
 missing following 'IStorageBroker' interface members: get_all_connections,
 get_all_connectors, get_all_peerids, get_all_connections_for,
 get_permuted_peers.
 src/allmydata/test/check_memory.py:495: error: Module has no attribute
 "maxint"
 src/allmydata/test/check_memory.py:497: error: Module has no attribute
 "maxint"
 src/allmydata/test/check_memory.py:501: error: Module has no attribute
 "maxint"
 src/allmydata/test/test_sftp.py:17: error: Name 'conch_interfaces' already
 defined on line 12
 src/allmydata/test/test_sftp.py:18: error: Name 'sftp' already defined on
 line 13
 src/allmydata/test/test_sftp.py:19: error: Incompatible import of "sftpd"
 (imported name has type Module, local name has type "object")
 src/allmydata/test/test_sftp.py:23: error: Incompatible types in
 assignment (expression has type "None", variable has type "ImportError")
 src/allmydata/test/test_encode.py:176: error: Incompatible types in
 assignment (expression has type "float", variable has type "int")
 src/allmydata/test/test_dirnode.py:1529: error: 'FakeMutableFile' is
 missing following 'allmydata.interfaces.IFilesystemNode' interface
 members: get_readcap, get_repair_cap, get_verify_cap, get_readonly_uri,
 get_storage_index, get_size, get_current_size.
 src/allmydata/test/test_dirnode.py:1529: error: 'FakeMutableFile' is
 missing following 'allmydata.interfaces.IFileNode' interface members:
 get_best_readable_version, get_size_of_best_version.
 src/allmydata/test/test_dirnode.py:1529: error: 'FakeMutableFile' is
 missing following 'IMutableFileNode' interface members:
 get_best_mutable_version, overwrite, get_servermap, download_version,
 upload, get_version.
 src/allmydata/test/test_deepcheck.py:919: error: Name 'unicode' is not
 defined
 src/allmydata/test/test_checker.py:65: error: 'FakeServer' is missing
 following 'IServer' interface members: start_connecting, get_rref,
 get_storage_server.
 src/allmydata/test/test_checker.py:78: error: 'FakeCheckResults' is
 missing following 'ICheckResults' interface members: get_uri,
 get_happiness, get_encoding_needed, get_encoding_expected,
 get_share_counter_good, get_share_counter_wrong, get_incompatible_shares,
 get_servers_responding, get_host_counter_good_shares,
 get_version_counter_recoverable, get_version_counter_unrecoverable,
 get_sharemap, get_report.
 src/allmydata/test/test_checker.py:109: error: 'FakeCheckAndRepairResults'
 is missing following 'ICheckAndRepairResults' interface members:
 get_storage_index_string.
 Found 142 errors in 48 files (checked 291 source files)
 ERROR: InvocationError for command /Users/jaraco/code/public/tahoe-
 lafs/.tox/typechecks/bin/mypy src (exited with code 1)
 ___________________________________ summary
 ____________________________________
 ERROR:   typechecks: commands failed

 }}}

 Still some errors remain about "Method must have at least one argument.",
 suggesting that the interface detection is being missed on some
 interfaces, but now at a more manageable level.

--
Ticket URL: <https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3399#comment:7>
Tahoe-LAFS <https://Tahoe-LAFS.org>
secure decentralized storage


More information about the tahoe-lafs-trac-stream mailing list