Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Use mypy 1.0 #15052

Merged
merged 19 commits into from Feb 16, 2023
Merged

Use mypy 1.0 #15052

merged 19 commits into from Feb 16, 2023

Commits on Feb 10, 2023

  1. Update mypy and mypy-zope

    David Robertson committed Feb 10, 2023
    Copy the full SHA
    325daae View commit details
    Browse the repository at this point in the history
  2. Suppress false positives from modules not implementing Protocols

    Not sure why mypy is flagging these up now? Could be a mypy bug
    
    ```
    synapse/__init__.py:67: error: Argument 1 to "set_json_library" has incompatible type Module; expected "JsonLibrary"  [arg-type]
    synapse/__init__.py:67: note: Following member(s) of "Module json" have conflicts:
    synapse/__init__.py:67: note:     JSONEncoder: expected "Encoder", got "Type[JSONEncoder]"
    
    synapse/storage/engines/postgres.py:38: error: Argument 1 to "__init__" of "BaseDatabaseEngine" has incompatible type Module; expected "DBAPI2Module"  [arg-type]
    synapse/storage/engines/postgres.py:38: note: Following member(s) of "Module psycopg2" have conflicts:
    synapse/storage/engines/postgres.py:38: note:     DataError: expected "Type[Exception]", got "Type[DataError]"
    synapse/storage/engines/postgres.py:38: note:     DatabaseError: expected "Type[Exception]", got "Type[DatabaseError]"
    synapse/storage/engines/postgres.py:38: note:     <9 more conflict(s) not shown>
    synapse/__init__.py:67: error: Argument 1 to "set_json_library" has incompatible type Module; expected "JsonLibrary"  [arg-type]
    
    synapse/storage/engines/sqlite.py:29: error: Argument 1 to "__init__" of "BaseDatabaseEngine" has incompatible type Module; expected "DBAPI2Module"  [arg-type]
    synapse/storage/engines/sqlite.py:29: note: Following member(s) of "Module sqlite3" have conflicts:
    synapse/storage/engines/sqlite.py:29: note:     DataError: expected "Type[Exception]", got "Type[DataError]"
    synapse/storage/engines/sqlite.py:29: note:     DatabaseError: expected "Type[Exception]", got "Type[DatabaseError]"
    synapse/storage/engines/sqlite.py:29: note:     <9 more conflict(s) not shown>
    ```
    David Robertson committed Feb 10, 2023
    Copy the full SHA
    408935c View commit details
    Browse the repository at this point in the history
  3. Remove unused ignores

    These used to suppress
    
    ```
    synapse/storage/engines/__init__.py:28: error: "__new__" must return a
    class instance (got "NoReturn")  [misc]
    ```
    
    and
    
    ```
    synapse/http/matrixfederationclient.py:1270: error: "BaseException" has no attribute "reasons"  [attr-defined]
    ```
    
    (note that we check `hasattr(e, "reasons")` above)
    David Robertson committed Feb 10, 2023
    Copy the full SHA
    d584aeb View commit details
    Browse the repository at this point in the history
  4. Avoid empty body warnings

    E.g.
    
    ```
    tests/handlers/test_register.py:58: error: Missing return statement  [empty-body]
    tests/handlers/test_register.py:108: error: Missing return statement  [empty-body]
    ```
    David Robertson committed Feb 10, 2023
    Copy the full SHA
    07d96ca View commit details
    Browse the repository at this point in the history
  5. Suppress false positive about JaegerConfig

    Complaint was
    
    ```
    synapse/logging/opentracing.py:450: error: Function "Type[Config]" could always be true in boolean context  [truthy-function]
    ```
    David Robertson committed Feb 10, 2023
    Copy the full SHA
    1f00d57 View commit details
    Browse the repository at this point in the history
  6. Fix not calling is_state()

    Oops!
    
    ```
    tests/rest/client/test_third_party_rules.py:428: error: Function "Callable[[], bool]" could always be true in boolean context  [truthy-function]
    ```
    David Robertson committed Feb 10, 2023
    Copy the full SHA
    57861a8 View commit details
    Browse the repository at this point in the history
  7. Suppress false positives from ParamSpecs

    ````
    synapse/logging/opentracing.py:971: error: Argument 2 to "_custom_sync_async_decorator" has incompatible type "Callable[[Arg(Callable[P, R], 'func'), **P], _GeneratorContextManager[None]]"; expected "Callable[[Callable[P, R], **P], _GeneratorContextManager[None]]"  [arg-type]
    synapse/logging/opentracing.py:1017: error: Argument 2 to "_custom_sync_async_decorator" has incompatible type "Callable[[Arg(Callable[P, R], 'func'), **P], _GeneratorContextManager[None]]"; expected "Callable[[Callable[P, R], **P], _GeneratorContextManager[None]]"  [arg-type]
    ````
    David Robertson committed Feb 10, 2023
    Copy the full SHA
    9d1d8a6 View commit details
    Browse the repository at this point in the history
  8. Drive-by improvement to wrapping_logic annotation

    David Robertson committed Feb 10, 2023
    Copy the full SHA
    b63789a View commit details
    Browse the repository at this point in the history
  9. Workaround false "unreachable" positives

    See Shoobx/mypy-zope#91
    
    ```
    tests/http/test_proxyagent.py:626: error: Statement is unreachable  [unreachable]
    tests/http/test_proxyagent.py:762: error: Statement is unreachable  [unreachable]
    tests/http/test_proxyagent.py:826: error: Statement is unreachable  [unreachable]
    tests/http/test_proxyagent.py:838: error: Statement is unreachable  [unreachable]
    tests/http/test_proxyagent.py:845: error: Statement is unreachable  [unreachable]
    tests/http/federation/test_matrix_federation_agent.py:151: error: Statement is unreachable  [unreachable]
    tests/http/federation/test_matrix_federation_agent.py:452: error: Statement is unreachable  [unreachable]
    tests/logging/test_remote_handler.py:60: error: Statement is unreachable  [unreachable]
    tests/logging/test_remote_handler.py:93: error: Statement is unreachable  [unreachable]
    tests/logging/test_remote_handler.py:127: error: Statement is unreachable  [unreachable]
    tests/logging/test_remote_handler.py:152: error: Statement is unreachable  [unreachable]
    ```
    David Robertson committed Feb 10, 2023
    Copy the full SHA
    212897e View commit details
    Browse the repository at this point in the history
  10. Changelog

    David Robertson committed Feb 10, 2023
    Copy the full SHA
    a7c2bc3 View commit details
    Browse the repository at this point in the history
  11. Linter fixes

    David Robertson committed Feb 10, 2023
    Copy the full SHA
    852b3fc View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2023

  1. Make UserInteractiveAuthChecker an ABC

    I had to add two new linter ignores here, but it did detect an
    incomplete subclass in the tests.
    David Robertson committed Feb 15, 2023
    Copy the full SHA
    8395cc8 View commit details
    Browse the repository at this point in the history
  2. Make Responder an ABC

    David Robertson committed Feb 15, 2023
    Copy the full SHA
    f351967 View commit details
    Browse the repository at this point in the history
  3. Mark EventSource as an ABC

    David Robertson committed Feb 15, 2023
    Copy the full SHA
    29dd442 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    e9329dc View commit details
    Browse the repository at this point in the history
  5. Pull in updated canonicaljson lib

    so the protocol check just works
    David Robertson committed Feb 15, 2023
    Copy the full SHA
    029cfaf View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2023

  1. Improve comments in opentracing

    I tried to workaround the ignores but found it too much trouble.
    
    I think the corresponding issue is
    python/mypy#12909. The mypy repo has a PR
    claiming to fix this (python/mypy#14677) which
    might mean this gets resolved soon?
    David Robertson committed Feb 16, 2023
    Copy the full SHA
    14db7d4 View commit details
    Browse the repository at this point in the history
  2. Better annotation for INTERACTIVE_AUTH_CHECKERS

    David Robertson committed Feb 16, 2023
    Copy the full SHA
    b739beb View commit details
    Browse the repository at this point in the history
  3. Drive-by AUTH_TYPE annotation, to remove an ignore

    David Robertson committed Feb 16, 2023
    Copy the full SHA
    7612a88 View commit details
    Browse the repository at this point in the history