Skip to content
Snippets Groups Projects
  1. Feb 22, 2023
  2. Feb 20, 2023
  3. Feb 17, 2023
  4. Feb 16, 2023
    • David Robertson's avatar
      Use mypy 1.0 (#15052) · ffc2ee52
      David Robertson authored
      * Update mypy and mypy-zope
      * 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)
      
      * Avoid empty body warnings, sometimes by marking methods as abstract
      
      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]
      ```
      
      * 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]
      ```
      
      * 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]
      ```
      
      * 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]
      ````
      
      * Drive-by improvement to `wrapping_logic` annotation
      
      * Workaround false "unreachable" positives
      
      See https://github.com/Shoobx/mypy-zope/issues/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]
      ```
      
      * Changelog
      
      * Tweak DBAPI2 Protocol to be accepted by mypy 1.0
      
      Some extra context in:
      - https://github.com/matrix-org/python-canonicaljson/pull/57
      - https://github.com/python/mypy/issues/6002
      - https://mypy.readthedocs.io/en/latest/common_issues.html#covariant-subtyping-of-mutable-protocol-members-is-rejected
      
      * Pull in updated canonicaljson lib
      
      so the protocol check just works
      
      * Improve comments in opentracing
      
      I tried to workaround the ignores but found it too much trouble.
      
      I think the corresponding issue is
      https://github.com/python/mypy/issues/12909. The mypy repo has a PR
      claiming to fix this (https://github.com/python/mypy/pull/14677) which
      might mean this gets resolved soon?
      
      * Better annotation for INTERACTIVE_AUTH_CHECKERS
      
      * Drive-by AUTH_TYPE annotation, to remove an ignore
      Unverified
      ffc2ee52
    • Patrick Cloke's avatar
      Update intentional mentions (MSC3952) to depend on `exact_event_match` (MSC3758). (#15037) · 979f237b
      Patrick Cloke authored
      This replaces the specific `is_room_mention` push rule condition
      used in MSC3952 with the generic `exact_event_match` push rule
      condition from MSC3758.
      
      No functionality changes due to this.
      Unverified
      979f237b
  5. Feb 14, 2023
  6. Feb 10, 2023
  7. Feb 09, 2023
    • Shay's avatar
      Add a class UnpersistedEventContext to allow for the batching up of storing state groups (#14675) · 03bccd54
      Shay authored
      
      * add class UnpersistedEventContext
      
      * modify create new client event to create unpersistedeventcontexts
      
      * persist event contexts after creation
      
      * fix tests to persist unpersisted event contexts
      
      * cleanup
      
      * misc lints + cleanup
      
      * changelog + fix comments
      
      * lints
      
      * fix batch insertion?
      
      * reduce redundant calculation
      
      * add unpersisted event classes
      
      * rework compute_event_context, split into function that returns unpersisted event context and then persists it
      
      * use calculate_context_info to create unpersisted event contexts
      
      * update typing
      
      * $%#^&*
      
      * black
      
      * fix comments and consolidate classes, use attr.s for class
      
      * requested changes
      
      * lint
      
      * requested changes
      
      * requested changes
      
      * refactor to be stupidly explicit
      
      * clearer renaming and flow
      
      * make partial state non-optional
      
      * update docstrings
      
      ---------
      
      Co-authored-by: default avatarErik Johnston <erik@matrix.org>
      Unverified
      03bccd54
    • Patrick Cloke's avatar
      Respond correctly to unknown methods on known endpoints (#14605) · d22c1c86
      Patrick Cloke authored
      Respond with a 405 error if a request is received on a known endpoint,
      but to an unknown method, per MSC3743.
      Unverified
      d22c1c86
    • David Robertson's avatar
      Proper types for `tests.module_api` (#15031) · 7081bb56
      David Robertson authored
      * -> None for test methods
      
      * A first batch of type fixes
      
      * Introduce common parent test case
      
      * Fixup that big test method
      
      * tests.module_api passes mypy
      
      * Changelog
      Unverified
      7081bb56
  8. Feb 08, 2023
  9. Feb 07, 2023
  10. Feb 06, 2023
  11. Feb 03, 2023
  12. Feb 01, 2023
  13. Jan 31, 2023
    • Sean Quah's avatar
      Make sqlite database migrations transactional again, part two (#14926) · 6d14fdc2
      Sean Quah authored
      
      #14910 fixed the regression introduced by #13873 where sqlite database
      migrations would no longer run inside a transaction. However, it
      committed the transaction before Synapse updated its bookkeeping of
      which migrations have been run, which means that migrations may be run
      again after they have completed successfully.
      
      Leave the transaction open at the end of `executescript`, to restore the
      old, correct behaviour. Also make the PostgreSQL behaviour consistent
      with SQLite.
      
      Fixes #14909.
      
      Signed-off-by: default avatarSean Quah <seanq@matrix.org>
      Unverified
      6d14fdc2
  14. Jan 30, 2023
    • David Robertson's avatar
      Handle malformed values of `notification.room` in power level events (#14942) · 510d4b06
      David Robertson authored
      * Better test for bad values in power levels events
      
      The previous test only checked that Synapse didn't raise an exception,
      but didn't check that we had correctly interpreted the value of the
      dodgy power level.
      
      It also conflated two things: bad room notification levels, and bad user
      levels. There _is_ logic for converting the latter to integers, but we
      should test it separately.
      
      * Check we ignore types that don't convert to int
      
      * Handle `None` values in `notifications.room`
      
      * Changelog
      
      * Also test that bad values are rejected by event auth
      
      * Docstring
      
      * linter scripttttttttt
      Unverified
      510d4b06
  15. Jan 27, 2023
    • Patrick Cloke's avatar
      Implement MSC3952: Intentional mentions (#14823) · 2a51f3ec
      Patrick Cloke authored
      MSC3952 defines push rules which searches for mentions in a list of
      Matrix IDs in the event body, instead of searching the entire event
      body for display name / local part.
      
      This is implemented behind an experimental configuration flag and
      does not yet implement the backwards compatibility pieces of the MSC.
      Unverified
      2a51f3ec
Loading